From e7581fd42d9740ca68adfc2ec55edb49d51af237 Mon Sep 17 00:00:00 2001 From: rubidium42 Date: Wed, 5 May 2021 19:21:12 +0200 Subject: Change: [Network] Update server's NetworkServerGameInfo only when needed Split the updating in a "static" version that only needs to be called when a new map is loaded or some settings are changed, and a "dynamic" version that updates everything that changes regularly such as the current game date or the number of spectators. --- src/network/core/game_info.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/network/core/game_info.cpp') diff --git a/src/network/core/game_info.cpp b/src/network/core/game_info.cpp index e5e85105e..9f4d23b3b 100644 --- a/src/network/core/game_info.cpp +++ b/src/network/core/game_info.cpp @@ -122,10 +122,10 @@ void CheckGameCompatibility(NetworkGameInfo &ngi) } /** - * Get the NetworkServerGameInfo structure with the latest information of the server. - * @return The current NetworkServerGameInfo. + * Fill a NetworkServerGameInfo structure with the static content, or things + * that are so static they can be updated on request from a settings change. */ -const NetworkServerGameInfo *GetCurrentNetworkServerGameInfo() +void FillStaticNetworkServerGameInfo() { _network_game_info.use_password = !StrEmpty(_settings_client.network.server_password); _network_game_info.start_date = ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1); @@ -140,7 +140,14 @@ const NetworkServerGameInfo *GetCurrentNetworkServerGameInfo() strecpy(_network_game_info.server_name, _settings_client.network.server_name, lastof(_network_game_info.server_name)); strecpy(_network_game_info.server_revision, GetNetworkRevisionString(), lastof(_network_game_info.server_revision)); +} +/** + * Get the NetworkServerGameInfo structure with the latest information of the server. + * @return The current NetworkServerGameInfo. + */ +const NetworkServerGameInfo *GetCurrentNetworkServerGameInfo() +{ /* Client_on is used as global variable to keep track on the number of clients. */ _network_game_info.companies_on = (byte)Company::GetNumItems(); _network_game_info.spectators_on = NetworkSpectatorCount(); -- cgit v1.2.3-70-g09d2