MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / RunDedicatedServer

Method RunDedicatedServer

Sources/Main.cpp:853–886  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

851
852#if defined(WITH_MULTIPLAYER) && defined(WITH_THREADS) && !defined(DEATH_TARGET_EMSCRIPTEN)
853void GameEventHandler::RunDedicatedServer(StringView configPath)
854{
855 if (PreferencesCache::FirstRun) {
856 // Save the preferences immediately if the config file doesn't exist
857 PreferencesCache::Save();
858 }
859
860 ServerInitialization serverInit;
861 if (!configPath.empty()) {
862 serverInit.Configuration = NetworkManager::LoadServerConfigurationFromFile(configPath);
863 } else {
864 serverInit.Configuration = NetworkManager::CreateDefaultServerConfiguration();
865 }
866 serverInit.InitialLevel.IsLocalSession = false;
867 serverInit.InitialLevel.IsReforged = PreferencesCache::EnableReforgedGameplay;
868 serverInit.Configuration.GameMode = MpGameMode::Cooperation;
869 if (!serverInit.Configuration.Playlist.empty()) {
870 if (serverInit.Configuration.PlaylistIndex < 0 || serverInit.Configuration.PlaylistIndex >= serverInit.Configuration.Playlist.size()) {
871 serverInit.Configuration.PlaylistIndex = 0;
872 }
873 if (serverInit.Configuration.RandomizePlaylist) {
874 Random().Shuffle<PlaylistEntry>(serverInit.Configuration.Playlist);
875 }
876 }
877
878 WaitForVerify();
879 if (!CreateServer(std::move(serverInit))) {
880 LOGE("Server cannot be started because of invalid configuration");
881 theApplication().Quit();
882 return;
883 }
884
885 StartProcessingStdin();
886}
887
888void GameEventHandler::StartProcessingStdin()
889{

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
QuitMethod · 0.45

Tested by

no test coverage detected