diff --git a/src/script/api/script_gamesettings.cpp b/src/script/api/script_gamesettings.cpp index 425531cce7..00e88e8351 100644 --- a/src/script/api/script_gamesettings.cpp +++ b/src/script/api/script_gamesettings.cpp @@ -22,7 +22,7 @@ return sd != nullptr && sd->IsIntSetting(); } -/* static */ int32 ScriptGameSettings::GetValue(const char *setting) +/* static */ SQInteger ScriptGameSettings::GetValue(const char *setting) { if (!IsValid(setting)) return -1; @@ -31,7 +31,7 @@ return sd->AsIntSetting()->Read(&_settings_game); } -/* static */ bool ScriptGameSettings::SetValue(const char *setting, int value) +/* static */ bool ScriptGameSettings::SetValue(const char *setting, SQInteger value) { if (!IsValid(setting)) return false; @@ -40,6 +40,8 @@ if ((sd->flags & SF_NO_NETWORK_SYNC) != 0) return false; + value = Clamp(value, INT32_MIN, INT32_MAX); + return ScriptObject::Command::Do(sd->GetName(), value); } diff --git a/src/script/api/script_gamesettings.hpp b/src/script/api/script_gamesettings.hpp index 14b30e5c4d..a2d238c82a 100644 --- a/src/script/api/script_gamesettings.hpp +++ b/src/script/api/script_gamesettings.hpp @@ -57,18 +57,19 @@ public: * @note Results achieved in the past offer no guarantee for the future. * @return The value for the setting. */ - static int32 GetValue(const char *setting); + static SQInteger GetValue(const char *setting); /** * Sets the value of the game setting. * @param setting The setting to set the value of. * @param value The value to set the setting to. + * The value will be clamped to MIN(int32) .. MAX(int32). * @pre IsValid(setting). * @return True if the action succeeded. * @note Results achieved in the past offer no guarantee for the future. * @api -ai */ - static bool SetValue(const char *setting, int value); + static bool SetValue(const char *setting, SQInteger value); /** * Checks whether the given vehicle-type is disabled for companies.