Exemplo n.º 1
0
/**
 * @brief Entry point of the dedicated game server
 */
int main(int /*argc*/, char ** /*argv[]*/)
{
    std::string homePath = System::HomePath();
    System::Initialize(); // default home path

    TLogInfo("Using home path: " + homePath);

    // Init lobby
    Lobby lobby;
    lobby.CreateTable("Console");
    Server server(lobby);

    ConsoleClient client;

    Log::SetLogPath(System::LogPath());
    Log::RegisterListener(client);

    ServerOptions options = ServerConfig::GetDefault();
    options.localHostOnly = true;

    server.Start(options); // Blocking call. On exit, quit the executable


#ifdef USE_WINDOWS_OS
    // Set the control handler so the app will be notified upon any special
    //   termination event.
    SetConsoleCtrlHandler ((PHANDLER_ROUTINE) ControlHandler, TRUE);

    (void) _set_invalid_parameter_handler(myInvalidParameterHandler);

#ifdef _MSC_VER
    // Disable the message box for assertions.
    _CrtSetReportMode(_CRT_ASSERT, 0);
#endif

#endif

    client.Run(options.game_tcp_port);

    server.Stop();
    client.Stop();

    return 0;
}