From 381f1ac7771324cda99807409cbd07b984c596a2 Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Fri, 3 Feb 2023 20:39:06 +0000 Subject: [PATCH] Fix #10059: [Script] Let custom values on a config item be up to 10 digits + 1 for sign --- src/ai/ai_gui.cpp | 2 +- src/game/game_gui.cpp | 2 +- src/script/script_config.hpp | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index d885de813b..a15d675ed0 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -501,7 +501,7 @@ struct AISettingsWindow : public Window { } else if (!bool_item && !config_item.complete_labels) { /* Display a query box so users can enter a custom value. */ SetDParam(0, old_val); - ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_NONE); + ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, INT32_DIGITS_WITH_SIGN_AND_TERMINATION, this, CS_NUMERAL_SIGNED, QSF_NONE); } this->SetDirty(); break; diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index d111ff192c..dad7a71e41 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -365,7 +365,7 @@ struct GSConfigWindow : public Window { } else if (!bool_item && !config_item.complete_labels) { /* Display a query box so users can enter a custom value. */ SetDParam(0, old_val); - ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_NONE); + ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, INT32_DIGITS_WITH_SIGN_AND_TERMINATION, this, CS_NUMERAL_SIGNED, QSF_NONE); } this->SetDirty(); break; diff --git a/src/script/script_config.hpp b/src/script/script_config.hpp index f8b2a43dc9..b243f3061f 100644 --- a/src/script/script_config.hpp +++ b/src/script/script_config.hpp @@ -18,6 +18,9 @@ #include "../textfile_gui.h" #include "script_instance.hpp" +/** Maximum of 10 digits for MIN / MAX_INT32, 1 for the sign and 1 for '\0'. */ +static const int INT32_DIGITS_WITH_SIGN_AND_TERMINATION = 10 + 1 + 1; + /** Bitmask of flags for Script settings. */ enum ScriptConfigFlags { SCRIPTCONFIG_NONE = 0x0, ///< No flags set.