diff options
-rw-r--r-- | src/settings.cpp | 22 | ||||
-rw-r--r-- | src/settings_type.h | 1 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 0d379778b..3d142d9ce 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -156,6 +156,7 @@ public: enum IniFileVersion : uint32 { IFV_0, ///< 0 All versions prior to introduction. IFV_PRIVATE_SECRETS, ///< 1 PR#9298 Moving of settings from openttd.cfg to private.cfg / secrets.cfg. + IFV_GAME_TYPE, ///< 2 PR#9515 Convert server_advertise to server_game_type. IFV_MAX_VERSION, ///< Highest possible ini-file version. }; @@ -1218,6 +1219,19 @@ void LoadFromConfig(bool startup) /* Load basic settings only during bootstrap, load other settings not during bootstrap */ if (!startup) { + /* Convert network.server_advertise to network.server_game_type, but only if network.server_game_type is set to default value. */ + if (generic_version < IFV_GAME_TYPE) { + if (_settings_client.network.server_game_type == SERVER_GAME_TYPE_LOCAL) { + IniGroup *network = generic_ini.GetGroup("network", false); + if (network != nullptr) { + IniItem *server_advertise = network->GetItem("server_advertise", false); + if (server_advertise != nullptr && server_advertise->value == "true") { + _settings_client.network.server_game_type = SERVER_GAME_TYPE_PUBLIC; + } + } + } + } + _grfconfig_newgame = GRFLoadConfig(generic_ini, "newgrf", false); _grfconfig_static = GRFLoadConfig(generic_ini, "newgrf-static", true); AILoadConfig(generic_ini, "ai_players"); @@ -1272,6 +1286,14 @@ void SaveToConfig() } } + /* Remove network.server_advertise. */ + if (generic_version < IFV_GAME_TYPE) { + IniGroup *network = generic_ini.GetGroup("network", false); + if (network != nullptr) { + network->RemoveItem("server_advertise"); + } + } + HandleSettingDescs(generic_ini, private_ini, secrets_ini, IniSaveSettings, IniSaveSettingList); GRFSaveConfig(generic_ini, "newgrf", _grfconfig_newgame); GRFSaveConfig(generic_ini, "newgrf-static", _grfconfig_static); diff --git a/src/settings_type.h b/src/settings_type.h index 05833cdb0..dd49d3982 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -280,7 +280,6 @@ struct NetworkSettings { std::string server_password; ///< password for joining this server std::string rcon_password; ///< password for rconsole (server side) std::string admin_password; ///< password for the admin network - bool server_advertise; ///< Advertise the server to the game coordinator. std::string client_name; ///< name of the player (as client) std::string default_company_pass; ///< default password for new companies in encrypted form std::string connect_to_ip; ///< default for the "Add server" query |