diff options
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ce1f2abba..219ac872d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1747,9 +1747,10 @@ void Vehicle::BeginLoading() current_order.MakeLoading(true); UpdateVehicleTimetable(this, true); - for (Order *order = this->GetOrder(this->cur_order_index); - order != NULL && order->IsType(OT_AUTOMATIC); - order = order->next) { + const Order *order = this->GetOrder(this->cur_order_index); + while (order != NULL && order->IsType(OT_AUTOMATIC)) { + /* Delete order effectively deletes order, so get the next before deleting it. */ + order = order->next; DeleteOrder(this, this->cur_order_index); } |