Skip to content

Commit

Permalink
Fix #10511: Delay 'go to nearest depot' orders
Browse files Browse the repository at this point in the history
Delay the nearest depot order search for a day if the vehicle can't find its destination, which happens when it has already attempted to do so and failed to find a valid destination.
  • Loading branch information
SamuXarick committed Jan 2, 2024
1 parent 502a52e commit a1efb1f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/order_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,10 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool
}

if (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
/* If the vehicle can't find its destination, delay its next search.
* In case many vehicles are in this state, use the vehicle index to spread out pathfinder calls. */
if (v->dest_tile == 0 && TimerGameCalendar::date_fract != (v->index % Ticks::DAY_TICKS)) break;

/* We need to search for the nearest depot (hangar). */
ClosestDepot closestDepot = v->FindClosestDepot();

Expand Down

0 comments on commit a1efb1f

Please sign in to comment.