1
0
Fork 0

Remove: setting_newgame console command

Remove now unused force_newgame parameters

Fixes: #12059
pull/12077/head
Jonathan G Rennison 2024-02-12 19:22:06 +00:00
parent 79374bc003
commit 6dbddb0b5c
4 changed files with 12 additions and 41 deletions

View File

@ -2163,25 +2163,6 @@ DEF_CONSOLE_CMD(ConSetting)
return true; return true;
} }
DEF_CONSOLE_CMD(ConSettingNewgame)
{
if (argc == 0) {
IConsolePrint(CC_HELP, "Change setting for the next game. Usage: 'setting_newgame <name> [<value>]'.");
IConsolePrint(CC_HELP, "Omitting <value> 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) DEF_CONSOLE_CMD(ConListSettings)
{ {
if (argc == 0) { if (argc == 0) {
@ -2643,7 +2624,6 @@ void IConsoleStdLibRegister()
IConsole::CmdRegister("clear", ConClearBuffer); IConsole::CmdRegister("clear", ConClearBuffer);
IConsole::CmdRegister("font", ConFont); IConsole::CmdRegister("font", ConFont);
IConsole::CmdRegister("setting", ConSetting); IConsole::CmdRegister("setting", ConSetting);
IConsole::CmdRegister("setting_newgame", ConSettingNewgame);
IConsole::CmdRegister("list_settings", ConListSettings); IConsole::CmdRegister("list_settings", ConListSettings);
IConsole::CmdRegister("gamelog", ConGamelogPrint); IConsole::CmdRegister("gamelog", ConGamelogPrint);
IConsole::CmdRegister("rescan_newgrf", ConRescanNewGRF); IConsole::CmdRegister("rescan_newgrf", ConRescanNewGRF);
@ -2654,7 +2634,6 @@ void IConsoleStdLibRegister()
IConsole::AliasRegister("newmap", "newgame"); IConsole::AliasRegister("newmap", "newgame");
IConsole::AliasRegister("patch", "setting %+"); IConsole::AliasRegister("patch", "setting %+");
IConsole::AliasRegister("set", "setting %+"); IConsole::AliasRegister("set", "setting %+");
IConsole::AliasRegister("set_newgame", "setting_newgame %+");
IConsole::AliasRegister("list_patches", "list_settings %+"); IConsole::AliasRegister("list_patches", "list_settings %+");
IConsole::AliasRegister("developer", "setting developer %+"); IConsole::AliasRegister("developer", "setting developer %+");

View File

@ -1732,9 +1732,8 @@ CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name
* @param index offset in the SettingDesc array of the Settings struct which * @param index offset in the SettingDesc array of the Settings struct which
* identifies the setting member we want to change * identifies the setting member we want to change
* @param value new value of the setting * @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(); const IntSettingDesc *setting = sd->AsIntSetting();
if ((setting->flags & SF_PER_COMPANY) != 0) { if ((setting->flags & SF_PER_COMPANY) != 0) {
@ -1758,11 +1757,6 @@ bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame
return true; return true;
} }
if (force_newgame) {
setting->ChangeValue(&_settings_newgame, value);
return true;
}
/* send non-company-based settings over the network */ /* send non-company-based settings over the network */
if (!_networking || (_networking && _network_server)) { if (!_networking || (_networking && _network_server)) {
return Command<CMD_CHANGE_SETTING>::Post(setting->GetName(), value); return Command<CMD_CHANGE_SETTING>::Post(setting->GetName(), value);
@ -1801,10 +1795,9 @@ void SyncCompanySettings()
* Set a setting value with a string. * Set a setting value with a string.
* @param sd the setting to change. * @param sd the setting to change.
* @param value the value to write * @param value the value to write
* @param force_newgame force the newgame settings
* @note Strings WILL NOT be synced over the network * @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); assert(sd->flags & SF_NO_NETWORK_SYNC);
@ -1812,7 +1805,7 @@ bool SetSettingValue(const StringSettingDesc *sd, std::string value, bool force_
value.clear(); 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); sd->AsStringSetting()->ChangeValue(object, value);
return true; 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 /* 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 */ * 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); const SettingDesc *sd = GetSettingFromName(name);
if (sd == nullptr) { if (sd == nullptr) {
@ -1846,7 +1839,7 @@ void IConsoleSetSetting(const char *name, const char *value, bool force_newgame)
bool success = true; bool success = true;
if (sd->IsStringSetting()) { if (sd->IsStringSetting()) {
success = SetSettingValue(sd->AsStringSetting(), value, force_newgame); success = SetSettingValue(sd->AsStringSetting(), value);
} else if (sd->IsIntSetting()) { } else if (sd->IsIntSetting()) {
const IntSettingDesc *isd = sd->AsIntSetting(); const IntSettingDesc *isd = sd->AsIntSetting();
size_t val = isd->ParseValue(value); 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(); _settings_error_list.clear();
return; return;
} }
success = SetSettingValue(isd, (int32_t)val, force_newgame); success = SetSettingValue(isd, (int32_t)val);
} }
if (!success) { if (!success) {
@ -1877,9 +1870,8 @@ void IConsoleSetSetting(const char *name, int value)
/** /**
* Output value of a specific setting to the console * Output value of a specific setting to the console
* @param name Name of the setting to output its value * @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); const SettingDesc *sd = GetSettingFromName(name);
if (sd == nullptr) { if (sd == nullptr) {
@ -1887,7 +1879,7 @@ void IConsoleGetSetting(const char *name, bool force_newgame)
return; 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()) { if (sd->IsStringSetting()) {
IConsolePrint(CC_INFO, "Current value for '{}' is '{}'.", sd->GetName(), sd->AsStringSetting()->Read(object)); IConsolePrint(CC_INFO, "Current value for '{}' is '{}'.", sd->GetName(), sd->AsStringSetting()->Read(object));

View File

@ -15,9 +15,9 @@
struct IniFile; 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 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 IConsoleListSettings(const char *prefilter);
void LoadFromConfig(bool minimal = false); void LoadFromConfig(bool minimal = false);

View File

@ -379,7 +379,7 @@ typedef std::span<const SettingVariant> SettingTable;
const SettingDesc *GetSettingFromName(const std::string_view name); const SettingDesc *GetSettingFromName(const std::string_view name);
void GetSaveLoadFromSettingTable(SettingTable settings, std::vector<SaveLoad> &saveloads); void GetSaveLoadFromSettingTable(SettingTable settings, std::vector<SaveLoad> &saveloads);
bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame = false); bool SetSettingValue(const IntSettingDesc *sd, int32_t value);
bool SetSettingValue(const StringSettingDesc *sd, const std::string value, bool force_newgame = false); bool SetSettingValue(const StringSettingDesc *sd, const std::string value);
#endif /* SETTINGS_INTERNAL_H */ #endif /* SETTINGS_INTERNAL_H */