1
0
Fork 0

Fix #14375: When loading config, validate timekeeping mode and minutes per year (#14405)

pull/13303/merge
Tyler Trahan 2025-07-09 16:04:38 -04:00 committed by GitHub
parent 753905ae2d
commit 259830777c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -667,6 +667,15 @@ static void ChangeMinutesPerYear(int32_t new_value)
} }
} }
/* Get the valid range of the "minutes per calendar year" setting. */
static std::tuple<int32_t, uint32_t> GetMinutesPerYearRange(const IntSettingDesc &)
{
/* Allow a non-default value only if using Wallclock timekeeping units. */
if (_settings_newgame.economy.timekeeping_units == TKU_WALLCLOCK) return { CalendarTime::FROZEN_MINUTES_PER_YEAR, CalendarTime::MAX_MINUTES_PER_YEAR };
return { CalendarTime::DEF_MINUTES_PER_YEAR, CalendarTime::DEF_MINUTES_PER_YEAR };
}
/** /**
* Pre-callback check when trying to change the timetable mode. This is locked to Seconds when using wallclock units. * Pre-callback check when trying to change the timetable mode. This is locked to Seconds when using wallclock units.
* @param Unused. * @param Unused.

View File

@ -11,6 +11,7 @@
static void TownFoundingChanged(int32_t new_value); static void TownFoundingChanged(int32_t new_value);
static void ChangeTimekeepingUnits(int32_t new_value); static void ChangeTimekeepingUnits(int32_t new_value);
static void ChangeMinutesPerYear(int32_t new_value); static void ChangeMinutesPerYear(int32_t new_value);
static std::tuple<int32_t, uint32_t> GetMinutesPerYearRange(const IntSettingDesc &sd);
static constexpr std::initializer_list<std::string_view> _place_houses{"forbidden"sv, "allowed"sv, "fully constructed"sv}; static constexpr std::initializer_list<std::string_view> _place_houses{"forbidden"sv, "allowed"sv, "fully constructed"sv};
@ -332,6 +333,7 @@ strhelp = STR_CONFIG_SETTING_MINUTES_PER_YEAR_HELPTEXT
strval = STR_CONFIG_SETTING_MINUTES_PER_YEAR_VALUE strval = STR_CONFIG_SETTING_MINUTES_PER_YEAR_VALUE
pre_cb = [](auto) { return _game_mode == GM_MENU || _settings_game.economy.timekeeping_units == 1; } pre_cb = [](auto) { return _game_mode == GM_MENU || _settings_game.economy.timekeeping_units == 1; }
post_cb = ChangeMinutesPerYear post_cb = ChangeMinutesPerYear
range_cb = GetMinutesPerYearRange
cat = SC_BASIC cat = SC_BASIC
[SDT_VAR] [SDT_VAR]