From f45509848a94f2d918f22a5e7e10d0425301a1d9 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Fri, 21 Apr 2023 18:36:06 -0400 Subject: [PATCH] Fix #10289: Don't silently fail when setting timetable start dates (#10690) --- src/lang/english.txt | 1 + src/timetable_cmd.cpp | 2 +- src/timetable_gui.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index 27183c0f5a..b12b339f9a 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -5110,6 +5110,7 @@ STR_ERROR_NO_BUOY :{WHITE}There is STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Can't timetable vehicle... STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Vehicles can only wait at stations STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}This vehicle is not stopping at this station +STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... timetable is incomplete # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... too many signs diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index 874d7fd9c7..436948922f 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -306,7 +306,7 @@ CommandCost CmdSetTimetableStart(DoCommandFlag flags, VehicleID veh_id, bool tim if (start_date < 0 || start_date > MAX_DAY) return CMD_ERROR; if (start_date - _date > MAX_TIMETABLE_START_YEARS * DAYS_IN_LEAP_YEAR) return CMD_ERROR; if (_date - start_date > DAYS_IN_LEAP_YEAR) return CMD_ERROR; - if (timetable_all && !v->orders->IsCompleteTimetable()) return CMD_ERROR; + if (timetable_all && !v->orders->IsCompleteTimetable()) return CommandCost(STR_ERROR_TIMETABLE_INCOMPLETE); if (timetable_all && start_date + total_duration / DAY_TICKS > MAX_DAY) return CMD_ERROR; if (flags & DC_EXEC) { diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 4401c63fff..228fabd4cd 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -572,7 +572,7 @@ struct TimetableWindow : Window { } case WID_VT_START_DATE: // Change the date that the timetable starts. - ShowSetDateWindow(this, v->index, _date, _cur_year, _cur_year + MAX_TIMETABLE_START_YEARS, ChangeTimetableStartCallback, reinterpret_cast(static_cast(v->orders->IsCompleteTimetable() && _ctrl_pressed))); + ShowSetDateWindow(this, v->index, _date, _cur_year, _cur_year + MAX_TIMETABLE_START_YEARS, ChangeTimetableStartCallback, reinterpret_cast(static_cast(_ctrl_pressed))); break; case WID_VT_CHANGE_TIME: { // "Wait For" button.