Skip to content

Commit

Permalink
Fix OpenTTD#10059: [Script] Let custom values on a config item be up …
Browse files Browse the repository at this point in the history
…to 10 digits + 1 for sign
  • Loading branch information
SamuXarick authored and rubidium42 committed Mar 28, 2023
1 parent 4148992 commit 7db64b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ai/ai_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion src/game/game_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@
#include "../misc_cmd.h"

#include "game_gui.hpp"
<<<<<<< HEAD
#include "../ai/ai_config.hpp"
#include "../ai/ai_gui.hpp"
#include "../widgets/game_widget.h"
=======
#include "game_config.hpp"
#include "game_info.hpp"
#include "../script/script_gui.h"
#include "../script_config.hpp"
>>>>>>> fde7028a9 (Fix #10059: [Script] Let custom values on a config item be up to 10 digits + 1 for sign)
#include "../table/strings.h"
#include "../game/game.hpp"
#include "../game/game_config.hpp"
Expand Down Expand Up @@ -365,7 +372,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;
Expand Down
3 changes: 3 additions & 0 deletions src/script/script_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7db64b6

Please sign in to comment.