changeset 17070:38c723434782 draft

(svn r21807) -Codechange: split automatic order removal into a separate function (fonsinchen)
author rubidium <rubidium@openttd.org>
date Sat, 15 Jan 2011 18:14:29 +0000
parents 9fd1737eb624
children cef968e48b30
files src/vehicle.cpp src/vehicle_base.h
diffstat 2 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1736,6 +1736,18 @@
 	return capacity;
 }
 
+/**
+ * Delete all automatic orders which were not reached.
+ */
+void Vehicle::DeleteUnreachedAutoOrders()
+{
+	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);
+	}
+}
 
 void Vehicle::BeginLoading()
 {
@@ -1743,13 +1755,7 @@
 
 	if (this->current_order.IsType(OT_GOTO_STATION) &&
 			this->current_order.GetDestination() == this->last_station_visited) {
-		/* Delete all automatic orders which were not reached */
-		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);
-		}
+		this->DeleteUnreachedAutoOrders();
 
 		/* Now cur_order_index points to the destination station, and we can start loading */
 		this->current_order.MakeLoading(true);
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -243,6 +243,8 @@
 	GroundVehicleCache *GetGroundVehicleCache();
 	const GroundVehicleCache *GetGroundVehicleCache() const;
 
+	void DeleteUnreachedAutoOrders();
+
 	/**
 	 * Handle the loading of the vehicle; when not it skips through dummy
 	 * orders and does nothing in all other cases.