summaryrefslogtreecommitdiff
path: root/src/settings_gui.cpp
diff options
context:
space:
mode:
authorPavel Stupnikov <dp@dpointer.org>2020-12-16 23:56:32 +0300
committerGitHub <noreply@github.com>2020-12-16 21:56:32 +0100
commitb2895dfcd056798bb82957a55394a941c61376f5 (patch)
tree2fc6ba5bc8f39720c1434f0197729ad6307625b7 /src/settings_gui.cpp
parentd989fb516bf271bc59c97d7580b1b66d849a1c1b (diff)
downloadopenttd-b2895dfcd056798bb82957a55394a941c61376f5.tar.xz
Change: extend the allowed range for max loan setting (#8386)
Diffstat (limited to 'src/settings_gui.cpp')
-rw-r--r--src/settings_gui.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index cfb6bc5b8..c7dd0cb14 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -2187,12 +2187,14 @@ struct GameSettingsWindow : Window {
} else {
/* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
if (this->last_clicked == pe && sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
+ int64 value64 = value;
/* Show the correct currency-translated value */
- if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate;
+ if (sd->desc.flags & SGF_CURRENCY) value64 *= _currency->rate;
this->valuewindow_entry = pe;
- SetDParam(0, value);
- ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
+ SetDParam(0, value64);
+ /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
+ ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
}
this->SetDisplayedHelpText(pe);
}
@@ -2217,10 +2219,12 @@ struct GameSettingsWindow : Window {
int32 value;
if (!StrEmpty(str)) {
- value = atoi(str);
+ long long llvalue = atoll(str);
/* Save the correct currency-translated value */
- if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
+ if (sd->desc.flags & SGF_CURRENCY) llvalue /= _currency->rate;
+
+ value = (int32)ClampToI32(llvalue);
} else {
value = (int32)(size_t)sd->desc.def;
}