From 6dbddb0b5cb3fd59a61f6c861aaebf7201e94963 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 12 Feb 2024 19:22:06 +0000 Subject: [PATCH] Remove: setting_newgame console command Remove now unused force_newgame parameters Fixes: #12059 --- src/console_cmds.cpp | 21 --------------------- src/settings.cpp | 24 ++++++++---------------- src/settings_func.h | 4 ++-- src/settings_internal.h | 4 ++-- 4 files changed, 12 insertions(+), 41 deletions(-) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 98a521861e..a3f47168ca 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -2163,25 +2163,6 @@ DEF_CONSOLE_CMD(ConSetting) return true; } -DEF_CONSOLE_CMD(ConSettingNewgame) -{ - if (argc == 0) { - IConsolePrint(CC_HELP, "Change setting for the next game. Usage: 'setting_newgame []'."); - IConsolePrint(CC_HELP, "Omitting will print out the current value of the setting."); - return true; - } - - if (argc == 1 || argc > 3) return false; - - if (argc == 2) { - IConsoleGetSetting(argv[1], true); - } else { - IConsoleSetSetting(argv[1], argv[2], true); - } - - return true; -} - DEF_CONSOLE_CMD(ConListSettings) { if (argc == 0) { @@ -2643,7 +2624,6 @@ void IConsoleStdLibRegister() IConsole::CmdRegister("clear", ConClearBuffer); IConsole::CmdRegister("font", ConFont); IConsole::CmdRegister("setting", ConSetting); - IConsole::CmdRegister("setting_newgame", ConSettingNewgame); IConsole::CmdRegister("list_settings", ConListSettings); IConsole::CmdRegister("gamelog", ConGamelogPrint); IConsole::CmdRegister("rescan_newgrf", ConRescanNewGRF); @@ -2654,7 +2634,6 @@ void IConsoleStdLibRegister() IConsole::AliasRegister("newmap", "newgame"); IConsole::AliasRegister("patch", "setting %+"); IConsole::AliasRegister("set", "setting %+"); - IConsole::AliasRegister("set_newgame", "setting_newgame %+"); IConsole::AliasRegister("list_patches", "list_settings %+"); IConsole::AliasRegister("developer", "setting developer %+"); diff --git a/src/settings.cpp b/src/settings.cpp index 5200b2394c..4addf01d25 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1732,9 +1732,8 @@ CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name * @param index offset in the SettingDesc array of the Settings struct which * identifies the setting member we want to change * @param value new value of the setting - * @param force_newgame force the newgame settings */ -bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame) +bool SetSettingValue(const IntSettingDesc *sd, int32_t value) { const IntSettingDesc *setting = sd->AsIntSetting(); if ((setting->flags & SF_PER_COMPANY) != 0) { @@ -1758,11 +1757,6 @@ bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame return true; } - if (force_newgame) { - setting->ChangeValue(&_settings_newgame, value); - return true; - } - /* send non-company-based settings over the network */ if (!_networking || (_networking && _network_server)) { return Command::Post(setting->GetName(), value); @@ -1801,10 +1795,9 @@ void SyncCompanySettings() * Set a setting value with a string. * @param sd the setting to change. * @param value the value to write - * @param force_newgame force the newgame settings * @note Strings WILL NOT be synced over the network */ -bool SetSettingValue(const StringSettingDesc *sd, std::string value, bool force_newgame) +bool SetSettingValue(const StringSettingDesc *sd, std::string value) { assert(sd->flags & SF_NO_NETWORK_SYNC); @@ -1812,7 +1805,7 @@ bool SetSettingValue(const StringSettingDesc *sd, std::string value, bool force_ value.clear(); } - const void *object = (_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game; + const void *object = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game; sd->AsStringSetting()->ChangeValue(object, value); return true; } @@ -1836,7 +1829,7 @@ void StringSettingDesc::ChangeValue(const void *object, std::string &newval) con /* Those 2 functions need to be here, else we have to make some stuff non-static * and besides, it is also better to keep stuff like this at the same place */ -void IConsoleSetSetting(const char *name, const char *value, bool force_newgame) +void IConsoleSetSetting(const char *name, const char *value) { const SettingDesc *sd = GetSettingFromName(name); if (sd == nullptr) { @@ -1846,7 +1839,7 @@ void IConsoleSetSetting(const char *name, const char *value, bool force_newgame) bool success = true; if (sd->IsStringSetting()) { - success = SetSettingValue(sd->AsStringSetting(), value, force_newgame); + success = SetSettingValue(sd->AsStringSetting(), value); } else if (sd->IsIntSetting()) { const IntSettingDesc *isd = sd->AsIntSetting(); size_t val = isd->ParseValue(value); @@ -1855,7 +1848,7 @@ void IConsoleSetSetting(const char *name, const char *value, bool force_newgame) _settings_error_list.clear(); return; } - success = SetSettingValue(isd, (int32_t)val, force_newgame); + success = SetSettingValue(isd, (int32_t)val); } if (!success) { @@ -1877,9 +1870,8 @@ void IConsoleSetSetting(const char *name, int value) /** * Output value of a specific setting to the console * @param name Name of the setting to output its value - * @param force_newgame force the newgame settings */ -void IConsoleGetSetting(const char *name, bool force_newgame) +void IConsoleGetSetting(const char *name) { const SettingDesc *sd = GetSettingFromName(name); if (sd == nullptr) { @@ -1887,7 +1879,7 @@ void IConsoleGetSetting(const char *name, bool force_newgame) return; } - const void *object = (_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game; + const void *object = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game; if (sd->IsStringSetting()) { IConsolePrint(CC_INFO, "Current value for '{}' is '{}'.", sd->GetName(), sd->AsStringSetting()->Read(object)); diff --git a/src/settings_func.h b/src/settings_func.h index 490ce9605f..6be0bcef13 100644 --- a/src/settings_func.h +++ b/src/settings_func.h @@ -15,9 +15,9 @@ struct IniFile; -void IConsoleSetSetting(const char *name, const char *value, bool force_newgame = false); +void IConsoleSetSetting(const char *name, const char *value); void IConsoleSetSetting(const char *name, int32_t value); -void IConsoleGetSetting(const char *name, bool force_newgame = false); +void IConsoleGetSetting(const char *name); void IConsoleListSettings(const char *prefilter); void LoadFromConfig(bool minimal = false); diff --git a/src/settings_internal.h b/src/settings_internal.h index f74127a8ae..46e2196010 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -379,7 +379,7 @@ typedef std::span SettingTable; const SettingDesc *GetSettingFromName(const std::string_view name); void GetSaveLoadFromSettingTable(SettingTable settings, std::vector &saveloads); -bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame = false); -bool SetSettingValue(const StringSettingDesc *sd, const std::string value, bool force_newgame = false); +bool SetSettingValue(const IntSettingDesc *sd, int32_t value); +bool SetSettingValue(const StringSettingDesc *sd, const std::string value); #endif /* SETTINGS_INTERNAL_H */