Timetable: Only reset timetable start/lateness when turning on automate when also auto-separating

This commit is contained in:
Jonathan G Rennison 2024-09-04 19:58:36 +01:00
parent dc44a83cdb
commit fa361ef9e9

View File

@ -624,14 +624,15 @@ CommandCost CmdAutomateTimetable(TileIndex index, DoCommandFlag flags, uint32_t
if (flags & DC_EXEC) {
for (Vehicle *v2 = v->FirstShared(); v2 != nullptr; v2 = v2->NextShared()) {
if (HasBit(p2, 0)) {
/* Automated timetable. Set flags and clear current times. */
/* Automated timetable. Set flags and clear current times if also auto-separating. */
SetBit(v2->vehicle_flags, VF_AUTOMATE_TIMETABLE);
ClrBit(v2->vehicle_flags, VF_AUTOFILL_TIMETABLE);
ClrBit(v2->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME);
ClrBit(v2->vehicle_flags, VF_TIMETABLE_STARTED);
v2->timetable_start = 0;
v2->lateness_counter = 0;
v2->current_loading_time = 0;
if (HasBit(v2->vehicle_flags, VF_TIMETABLE_SEPARATION)) {
ClrBit(v2->vehicle_flags, VF_TIMETABLE_STARTED);
v2->timetable_start = 0;
v2->lateness_counter = 0;
}
v2->ClearSeparation();
} else {
/* De-automate timetable. Clear flags. */