From bbddd92ec48256133e1de64d1b76e970fd200a36 Mon Sep 17 00:00:00 2001 From: James Ross Date: Fri, 22 Dec 2023 16:39:35 +0000 Subject: [PATCH] Cleanup: Apply automatic separation to fully timetabled vehicles --- src/vehicle.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index b509435da8..d06914f6a7 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2444,7 +2444,12 @@ void Vehicle::UpdateAutomaticSeparation() TimerGameTick::Ticks separation = std::max(1, vehicles > 0 ? round_trip_time * vehicles_moving_ratio / vehicles / vehicles : 1); /* Finally we can calculate when this vehicle should depart; if that's in the past, it'll depart right now */ - this->first_order_last_departure = std::max(last_departure + separation, TimerGameTick::counter); + TimerGameTick::TickCounter next_departure = last_departure + separation; + this->first_order_last_departure = std::max(next_departure, TimerGameTick::counter); + + /* Update vehicle lateness based on the automatic separation, overriding the timetable */ + this->lateness_counter = TimerGameTick::counter - next_departure; + SetWindowDirty(WC_VEHICLE_TIMETABLE, this->index); /* Debug logging can be quite spammy as it prints a line every time a vehicle departs the first manual order */ if (_debug_misc_level >= 4) {