diff options
author | rubidium <rubidium@openttd.org> | 2008-06-19 11:45:52 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-06-19 11:45:52 +0000 |
commit | 525c964f53c51192cde1fca88a2446b59ee68520 (patch) | |
tree | 4300716b93b72905bb5fef6fc8d37f9a24b8478e | |
parent | ad8578419e37e31b44a5cfc7e1ec4fcf1e0fca7f (diff) | |
download | openttd-525c964f53c51192cde1fca88a2446b59ee68520.tar.xz |
(svn r13579) -Fix [FS#2088]: process the order coming after a conditional order, otherwise the vehicle would already leaving the station before it knows where the next destination is, making it leave in the wrong way. However, after processing as many conditional orders as there are in the order list it will stop processing them in order to not create an infinite loop.
-rw-r--r-- | src/order_cmd.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 01e0fec94..627fdcb76 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1644,7 +1644,7 @@ static VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle * @param order the order the vehicle currently has * @param v the vehicle to update */ -static bool UpdateOrderDest(Vehicle *v, const Order *order) +static bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth = 0) { switch (order->GetType()) { case OT_GOTO_STATION: @@ -1691,7 +1691,13 @@ static bool UpdateOrderDest(Vehicle *v, const Order *order) } else { v->cur_order_index++; } - return false; + + if (conditional_depth > v->num_orders) return false; + + /* Get the current order */ + if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0; + + return UpdateOrderDest(v, GetVehicleOrder(v, v->cur_order_index), conditional_depth + 1); } default: |