diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 24daa84e96..9ca49be6ad 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2445,8 +2445,8 @@ bool Vehicle::HasUnbunchingOrder() const static bool PreviousOrderIsUnbunching(const Vehicle *v) { /* If we are headed for the first order, we must wrap around back to the last order. */ - bool is_first_order = (v->GetOrder(v->cur_real_order_index) == v->GetFirstOrder()); - Order *previous_order = (is_first_order) ? v->GetLastOrder() : v->GetOrder(v->cur_real_order_index - 1); + bool is_first_order = (v->GetOrder(v->cur_implicit_order_index) == v->GetFirstOrder()); + Order *previous_order = (is_first_order) ? v->GetLastOrder() : v->GetOrder(v->cur_implicit_order_index - 1); if (previous_order == nullptr || !previous_order->IsType(OT_GOTO_DEPOT)) return false; return (previous_order->GetDepotActionType() & ODATFB_UNBUNCH) != 0;