From 847f3f660d665aedff737eece86c5967f5dc4a98 Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Fri, 5 Jan 2024 21:23:01 +0000 Subject: [PATCH] Fix #10511: Delay 'go to nearest depot' orders (#11548) 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. --- src/order_cmd.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 2650843c1f..b64275314f 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -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();