diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index bae56889d4..f0167ae0d2 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1583,7 +1583,7 @@ static void AircraftEventHandler_InHangar(Aircraft *v, const AirportFTAClass *ap } if (v->current_order.IsWaitTimetabled()) { - v->HandleWaiting(false); + v->HandleWaiting(false, true); } if (v->current_order.IsType(OT_WAITING)) { return; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 49886c580c..eb198269de 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -2070,7 +2070,7 @@ static bool RoadVehController(RoadVehicle *v) if (v->current_order.IsType(OT_LOADING)) return true; - v->HandleWaiting(false); + v->HandleWaiting(false, true); if (v->current_order.IsType(OT_WAITING)) return true; if (v->IsInDepot() && RoadVehLeaveDepot(v, true)) return true; diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index d7f3ae20b6..5e27654a7c 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -352,7 +352,7 @@ static bool CheckShipLeaveDepot(Ship *v) if (!v->IsChainInDepot()) return false; if (v->current_order.IsWaitTimetabled()) { - v->HandleWaiting(false); + v->HandleWaiting(false, true); } if (v->current_order.IsType(OT_WAITING)) { return true; diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 9b41d1c216..e2e9e120a8 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3208,7 +3208,7 @@ static bool CheckTrainStayInDepot(Train *v) } if (v->current_order.IsWaitTimetabled()) { - v->HandleWaiting(false); + v->HandleWaiting(false, true); } if (v->current_order.IsType(OT_WAITING)) { return true; @@ -6198,9 +6198,8 @@ static bool TrainLocoHandler(Train *v, bool mode) if (CheckTrainStayInDepot(v)) return true; if (v->current_order.IsType(OT_WAITING) && v->reverse_distance == 0) { - v->HandleWaiting(false); + v->HandleWaiting(false, true); if (v->current_order.IsType(OT_WAITING)) return true; - ProcessOrders(v); if (IsRailWaypointTile(v->tile)) { StationID station_id = GetStationIndex(v->tile); if (v->current_order.ShouldStopAtStation(v, station_id, true)) { diff --git a/src/vehicle.cpp b/src/vehicle.cpp index e751695775..db44f004bd 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -3474,8 +3474,9 @@ void Vehicle::HandleLoading(bool mode) * Handle the waiting time everywhere else as in stations (basically in depot but, eventually, also elsewhere ?) * Function is called when order's wait_time is defined. * @param stop_waiting should we stop waiting (or definitely avoid) even if there is still time left to wait ? + * @param process_orders whether to call ProcessOrders when exiting a waiting order */ -void Vehicle::HandleWaiting(bool stop_waiting) +void Vehicle::HandleWaiting(bool stop_waiting, bool process_orders) { switch (this->current_order.GetType()) { case OT_WAITING: { @@ -3490,7 +3491,7 @@ void Vehicle::HandleWaiting(bool stop_waiting) this->IncrementImplicitOrderIndex(); this->current_order.MakeDummy(); if (this->type == VEH_TRAIN) Train::From(this)->force_proceed = TFP_NONE; - + if (process_orders) ProcessOrders(this); break; } diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 26e7b80a02..68012e51ac 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -396,7 +396,7 @@ public: void HandleLoading(bool mode = false); - void HandleWaiting(bool stop_waiting = false); + void HandleWaiting(bool stop_waiting, bool process_orders = false); /** * Marks the vehicles to be redrawn and updates cached variables