diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 1a2db2570..ab7a0d17c 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -309,6 +309,7 @@ CServer::CServer() m_CurrentMapSize = 0; m_MapReload = 0; + m_ReloadedWhenEmpty = false; m_RconClientID = IServer::RCON_CID_SERV; m_RconAuthLevel = AUTHED_ADMIN; @@ -1701,6 +1702,17 @@ int CServer::Run() // wait for incoming data if (NonActive) { + if(g_Config.m_SvReloadWhenEmpty == 1) + { + m_MapReload = true; + g_Config.m_SvReloadWhenEmpty = 0; + } + else if(g_Config.m_SvReloadWhenEmpty == 2 && !m_ReloadedWhenEmpty) + { + m_MapReload = true; + m_ReloadedWhenEmpty = true; + } + if(g_Config.m_SvShutdownWhenEmpty) m_RunServer = false; else @@ -1708,6 +1720,8 @@ int CServer::Run() } else { + m_ReloadedWhenEmpty = false; + set_new_tick(); int64 t = time_get(); int x = (TickStartTime(m_CurrentGameTick+1) - t) * 1000000 / time_freq() + 1; diff --git a/src/engine/server/server.h b/src/engine/server/server.h index 01f86930f..13c44a2a0 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -162,6 +162,7 @@ public: //int m_CurrentGameTick; int m_RunServer; int m_MapReload; + bool m_ReloadedWhenEmpty; int m_RconClientID; int m_RconAuthLevel; int m_PrintCBIndex; diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index df156c9a1..f75a09bb4 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -333,6 +333,7 @@ MACRO_CONFIG_INT(SvSpamMuteDuration, sv_spam_mute_duration, 60, 0, 3600 , CFGFLA MACRO_CONFIG_INT(SvEvents, sv_events, 1, 0, 1, CFGFLAG_SERVER, "Enable triggering of server events, like the happy eyeemotes on some holidays.") MACRO_CONFIG_INT(SvRankCheats, sv_rank_cheats, 0, 0, 1, CFGFLAG_SERVER, "Enable ranks after cheats have been used (file based server only)") MACRO_CONFIG_INT(SvShutdownWhenEmpty, sv_shutdown_when_empty, 0, 0, 1, CFGFLAG_SERVER, "Shutdown server as soon as noone is on it anymore") +MACRO_CONFIG_INT(SvReloadWhenEmpty, sv_reload_when_empty, 0, 0, 2, CFGFLAG_SERVER, "Reload map when server is empty (1 = reload once, 2 = reload everytime server gets empty)") MACRO_CONFIG_INT(SvKillProtection, sv_kill_protection, 20, 0, 9999, CFGFLAG_SERVER, "0 - Disable, 1-9999 minutes") MACRO_CONFIG_INT(SvSoloServer, sv_solo_server, 0, 0, 1, CFGFLAG_SERVER|CFGFLAG_GAME, "Set server to solo mode (no player interactions, has to be set before loading the map)") MACRO_CONFIG_STR(SvClientSuggestion, sv_client_suggestion, 128, "Get DDNet client from DDNet.tw to use all features on DDNet!", CFGFLAG_SERVER, "Broadcast to display to players without DDNet client")