diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1982,23 +1982,21 @@ bool UpdateOrderDest(Vehicle *v, const O if (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) { /* We need to search for the nearest depot (hangar). */ - TileIndex location; - DestinationID destination; - bool reverse; + ClosestDepot closestDepot = v->FindClosestDepot(); - if (v->FindClosestDepot(&location, &destination, &reverse)) { + if (closestDepot.found) { /* PBS reservations cannot reverse */ - if (pbs_look_ahead && reverse) return false; + if (pbs_look_ahead && closestDepot.reverse) return false; - v->SetDestTile(location); - v->current_order.SetDestination(destination); + v->SetDestTile(closestDepot.location); + v->current_order.SetDestination(closestDepot.destination); /* If there is no depot in front, reverse automatically (trains only) */ - if (v->type == VEH_TRAIN && reverse) Command::Do(DC_EXEC, v->index, false); + if (v->type == VEH_TRAIN && closestDepot.reverse) Command::Do(DC_EXEC, v->index, false); if (v->type == VEH_AIRCRAFT) { Aircraft *a = Aircraft::From(v); - if (a->state == FLYING && a->targetairport != destination) { + if (a->state == FLYING && a->targetairport != closestDepot.destination) { /* The aircraft is now heading for a different hangar than the next in the orders */ extern void AircraftNextAirportPos_and_Order(Aircraft *a); AircraftNextAirportPos_and_Order(a);