Improve handling of conditional order waiting loops

Do not leave station/depot/waypoint at all if conditional order
loop would result in re-starting waiting/loading

Only actually leave and update timetable at end of loop

Rate-limit loop checks regardless of timetabled wait time
This commit is contained in:
Jonathan G Rennison
2022-01-19 00:09:55 +00:00
parent 904ff6757d
commit beb6d01fe8
5 changed files with 146 additions and 11 deletions

View File

@@ -698,7 +698,7 @@ void AdvanceOrderIndex(const Vehicle *v, VehicleOrderID &index)
case OT_GOTO_WAYPOINT:
return;
case OT_CONDITIONAL: {
VehicleOrderID next = ProcessConditionalOrder(order, v, true);
VehicleOrderID next = ProcessConditionalOrder(order, v, PCO_DRY_RUN);
if (next != INVALID_VEH_ORDER_ID) {
depth++;
index = next;
@@ -3880,7 +3880,7 @@ public:
this->v->current_order = *order;
return UpdateOrderDest(this->v, order, 0, true);
case OT_CONDITIONAL: {
VehicleOrderID next = ProcessConditionalOrder(order, this->v, true);
VehicleOrderID next = ProcessConditionalOrder(order, this->v, PCO_DRY_RUN);
if (next != INVALID_VEH_ORDER_ID) {
depth++;
this->v->cur_real_order_index = next;
@@ -6368,6 +6368,7 @@ static bool TrainLocoHandler(Train *v, bool mode)
if (CheckTrainStayInDepot(v)) return true;
if (v->current_order.IsType(OT_WAITING) && v->reverse_distance == 0) {
if (mode) return true;
v->HandleWaiting(false, true);
if (v->current_order.IsType(OT_WAITING)) return true;
if (IsRailWaypointTile(v->tile)) {