summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-01-15 18:14:29 +0000
committerrubidium <rubidium@openttd.org>2011-01-15 18:14:29 +0000
commitbc9afec3b0f5f0b3f1c7a0f0494e9c3c42e71bec (patch)
tree5222f6dd14d8dda0cdc092f76587605f480d218e
parent53c9846f14be07b887323f3203ed3a0ab52e64db (diff)
downloadopenttd-bc9afec3b0f5f0b3f1c7a0f0494e9c3c42e71bec.tar.xz
(svn r21807) -Codechange: split automatic order removal into a separate function (fonsinchen)
-rw-r--r--src/vehicle.cpp20
-rw-r--r--src/vehicle_base.h2
2 files changed, 15 insertions, 7 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 2dd158329..ae520718b 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1736,6 +1736,18 @@ uint GetVehicleCapacity(const Vehicle *v, uint16 *mail_capacity)
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 @@ void Vehicle::BeginLoading()
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);
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 1e2ae6cf8..5ef98313a 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -243,6 +243,8 @@ public:
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.