2020-08-18 20:42:30 +00:00
|
|
|
#include "CNLoginServer.hpp"
|
|
|
|
#include "CNShardServer.hpp"
|
|
|
|
#include "PlayerManager.hpp"
|
|
|
|
#include "ChatManager.hpp"
|
|
|
|
|
|
|
|
#include "settings.hpp"
|
|
|
|
|
2020-08-19 20:42:44 +00:00
|
|
|
#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS)
|
2020-08-18 20:42:30 +00:00
|
|
|
#include "mingw/mingw.thread.h"
|
|
|
|
#else
|
|
|
|
#include <thread>
|
|
|
|
#endif
|
|
|
|
#include <string>
|
|
|
|
|
2020-08-19 00:52:02 +00:00
|
|
|
void startShard(CNShardServer* server) {
|
|
|
|
server->start();
|
2020-08-18 20:42:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
#ifdef _WIN32
|
|
|
|
WSADATA wsaData;
|
|
|
|
if (WSAStartup(MAKEWORD(1,1), &wsaData) != 0) {
|
|
|
|
std::cerr << "OpenFusion: WSAStartup failed" << std::endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
settings::init();
|
|
|
|
std::cout << "[INFO] Intializing Packet Managers..." << std::endl;
|
|
|
|
PlayerManager::init();
|
|
|
|
ChatManager::init();
|
|
|
|
|
|
|
|
std::cout << "[INFO] Starting Server Threads..." << std::endl;
|
2020-08-19 01:34:39 +00:00
|
|
|
CNLoginServer loginServer(settings::LOGINPORT);
|
|
|
|
CNShardServer shardServer(settings::SHARDPORT);
|
2020-08-19 00:52:02 +00:00
|
|
|
|
|
|
|
std::thread shardThread(startShard, (CNShardServer*)&shardServer);
|
|
|
|
|
|
|
|
loginServer.start();
|
|
|
|
|
|
|
|
shardServer.kill();
|
|
|
|
shardThread.join();
|
2020-08-18 20:42:30 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
WSACleanup();
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|