diff -u b/src/order_cmd.cpp b/src/order_cmd.cpp --- b/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -947,6 +947,17 @@ } /** + * Invalidate the next unload station of all cargo packets of a vehicle chain. + * @param v The vehicle. + */ +static void InvalidateNextStation(Vehicle *v) +{ + for (; v != NULL; v = v->Next()) { + v->cargo.InvalidateNextStation(); + } +} + +/** * Delete an order but skip the parameter validation. * @param v The vehicle to delete the order from. * @param sel_ord The id of the order to be deleted. @@ -988,7 +999,7 @@ InvalidateVehicleOrder(u, sel_ord | (INVALID_VEH_ORDER_ID << 8)); /* Clear the next unload station of all cargo packets, it might not be in the orders anymore. */ - u->cargo.InvalidateNextStation(); + InvalidateNextStation(u); } /* As we delete an order, the order to skip to will be 'wrong'. */ @@ -1378,7 +1389,7 @@ InvalidateVehicleOrder(u, -2); /* Invalidate the next unload station of all packets as we might not unload there anymore. */ - u->cargo.InvalidateNextStation(); + InvalidateNextStation(u); } } @@ -1741,7 +1752,7 @@ } /* Invalidate the next unload station of all cargo. */ - v->cargo.InvalidateNextStation(); + InvalidateNextStation(v); if (reset_order_indices) { v->cur_auto_order_index = v->cur_real_order_index = 0;