Fix ProcessOrders not always being called after leaving a waiting order
Fixes conditional order loop on leaving a depot
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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)) {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user