Fix #12154: Incorrect calendar day lengths with minutes per year setting (#12158)

This commit is contained in:
Jonathan G Rennison 2024-03-02 20:45:30 +00:00 committed by GitHub
parent d7c485d4b9
commit f180262aee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -105,10 +105,13 @@ bool TimerManager<TimerGameCalendar>::Elapsed([[maybe_unused]] TimerGameCalendar
/* If we are using a non-default calendar progression speed, we need to check the sub_date_fract before updating date_fract. */
if (_settings_game.economy.minutes_per_calendar_year != CalendarTime::DEF_MINUTES_PER_YEAR) {
TimerGameCalendar::sub_date_fract++;
TimerGameCalendar::sub_date_fract += Ticks::DAY_TICKS;
/* Check if we are ready to increment date_fract */
if (TimerGameCalendar::sub_date_fract < (Ticks::DAY_TICKS * _settings_game.economy.minutes_per_calendar_year) / CalendarTime::DEF_MINUTES_PER_YEAR) return false;
const uint16_t threshold = (_settings_game.economy.minutes_per_calendar_year * Ticks::DAY_TICKS) / CalendarTime::DEF_MINUTES_PER_YEAR;
if (TimerGameCalendar::sub_date_fract < threshold) return false;
TimerGameCalendar::sub_date_fract = std::min<uint16_t>(TimerGameCalendar::sub_date_fract - threshold, Ticks::DAY_TICKS - 1);
}
TimerGameCalendar::date_fract++;