summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-02-09 21:39:22 +0000
committerfrosch <frosch@openttd.org>2011-02-09 21:39:22 +0000
commit3a787f5a0b83c1bac9680a80b657601ce2d3bf5b (patch)
tree82480e5d02f1f80a33b45f095fbcc930ffb6ec5f /src
parentdda7b60a57344183e7db77ba050c97173a4605fc (diff)
downloadopenttd-3a787f5a0b83c1bac9680a80b657601ce2d3bf5b.tar.xz
(svn r22045) -Codechange: Move cancelling the current loading order on deleting the current order to a separate function.
Diffstat (limited to 'src')
-rw-r--r--src/order_cmd.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 4f97c782b..aa0f0eacc 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -907,6 +907,21 @@ CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
/**
+ * Cancel the current loading order of the vehicle as the order was deleted.
+ * @param v the vehicle
+ */
+static void CancelLoadingDueToDeletedOrder(Vehicle *v)
+{
+ assert(v->current_order.IsType(OT_LOADING));
+ /* NON-stop flag is misused to see if a train is in a station that is
+ * on his order list or not */
+ v->current_order.SetNonStopType(ONSF_STOP_EVERYWHERE);
+ /* When full loading, "cancel" that order so the vehicle doesn't
+ * stay indefinitely at this station anymore. */
+ if (v->current_order.GetLoadType() & OLFB_FULL_LOAD) v->current_order.SetLoadType(OLF_LOAD_IF_POSSIBLE);
+}
+
+/**
* 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.
@@ -920,13 +935,8 @@ void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
for (; u != NULL; u = u->NextShared()) {
assert(v->orders.list == u->orders.list);
- /* NON-stop flag is misused to see if a train is in a station that is
- * on his order list or not */
if (sel_ord == u->cur_real_order_index && u->current_order.IsType(OT_LOADING)) {
- u->current_order.SetNonStopType(ONSF_STOP_EVERYWHERE);
- /* When full loading, "cancel" that order so the vehicle doesn't
- * stay indefinitely at this station anymore. */
- if (u->current_order.GetLoadType() & OLFB_FULL_LOAD) u->current_order.SetLoadType(OLF_LOAD_IF_POSSIBLE);
+ CancelLoadingDueToDeletedOrder(u);
}
if (sel_ord < u->cur_real_order_index) {