From 92ab114e13c08324a5522f4bf0e2b5403a6daa6a Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Sun, 22 Oct 2023 10:51:06 -0400 Subject: [PATCH] Fix f49ffaa: Use DateAtStartOfYear() to calculate max timetable start date (#11388) --- src/timetable_cmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index ec87aa21e3..8fe617ed70 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -305,7 +305,7 @@ CommandCost CmdSetTimetableStart(DoCommandFlag flags, VehicleID veh_id, bool tim /* Don't let a timetable start more than 15 years into the future or 1 year in the past. */ if (start_date < 0 || start_date > CalendarTime::MAX_DATE) return CMD_ERROR; - if (start_date - TimerGameCalendar::date > static_cast(MAX_TIMETABLE_START_YEARS) * CalendarTime::DAYS_IN_LEAP_YEAR) return CMD_ERROR; + if (start_date - TimerGameCalendar::date > TimerGameCalendar::DateAtStartOfYear(MAX_TIMETABLE_START_YEARS)) return CMD_ERROR; if (TimerGameCalendar::date - start_date > CalendarTime::DAYS_IN_LEAP_YEAR) return CMD_ERROR; if (timetable_all && !v->orders->IsCompleteTimetable()) return CommandCost(STR_ERROR_TIMETABLE_INCOMPLETE); if (timetable_all && start_date + total_duration / Ticks::DAY_TICKS > CalendarTime::MAX_DATE) return CMD_ERROR;