From 8ffb4122df903393bceca49a25ac81cc42cca3ff Mon Sep 17 00:00:00 2001 From: rubidium42 Date: Tue, 18 May 2021 20:57:44 +0200 Subject: Codechange: just pass the SettingDesc to SetSettingValue and remove distinction between (non)company --- src/script/api/script_gamesettings.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/script/api') diff --git a/src/script/api/script_gamesettings.cpp b/src/script/api/script_gamesettings.cpp index 2717d4ddd..12435d253 100644 --- a/src/script/api/script_gamesettings.cpp +++ b/src/script/api/script_gamesettings.cpp @@ -17,8 +17,7 @@ /* static */ bool ScriptGameSettings::IsValid(const char *setting) { - uint i; - const SettingDesc *sd = GetSettingFromName(setting, &i); + const SettingDesc *sd = GetSettingFromName(setting); return sd != nullptr && sd->desc.cmd != SDT_STDSTRING; } @@ -26,8 +25,7 @@ { if (!IsValid(setting)) return -1; - uint index; - const SettingDesc *sd = GetSettingFromName(setting, &index); + const SettingDesc *sd = GetSettingFromName(setting); void *ptr = GetVariableAddress(&_settings_game, &sd->save); if (sd->desc.cmd == SDT_BOOLX) return *(bool*)ptr; @@ -39,13 +37,12 @@ { if (!IsValid(setting)) return false; - uint index; - const SettingDesc *sd = GetSettingFromName(setting, &index); + const SettingDesc *sd = GetSettingFromName(setting); if ((sd->save.conv & SLF_NO_NETWORK_SYNC) != 0) return false; if (sd->desc.cmd != SDT_BOOLX && sd->desc.cmd != SDT_NUMX) return false; - return ScriptObject::DoCommand(0, index, value, CMD_CHANGE_SETTING); + return ScriptObject::DoCommand(0, GetSettingIndex(sd), value, CMD_CHANGE_SETTING); } /* static */ bool ScriptGameSettings::IsDisabledVehicleType(ScriptVehicle::VehicleType vehicle_type) -- cgit v1.2.3-70-g09d2