diff options
author | rubidium <rubidium@openttd.org> | 2010-12-11 13:48:30 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-12-11 13:48:30 +0000 |
commit | 23369337c1af635f479c1d1541601742f6285dd2 (patch) | |
tree | db1efa572b852449fcc8001061278338d0b199fc | |
parent | fc7082590551a36ca7606f61f0ffced27b3194ac (diff) | |
download | openttd-23369337c1af635f479c1d1541601742f6285dd2.tar.xz |
(svn r21466) -Codechange: make VehicleHasDepotOrders a function of Vehicle.
-rw-r--r-- | src/order_cmd.cpp | 11 | ||||
-rw-r--r-- | src/order_func.h | 1 | ||||
-rw-r--r-- | src/vehicle.cpp | 4 | ||||
-rw-r--r-- | src/vehicle_base.h | 1 |
4 files changed, 7 insertions, 10 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index d02522cc6..13bdf2d8c 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1445,17 +1445,14 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination) } /** - * - * Checks if a vehicle has a GOTO_DEPOT in his order list - * - * @return True if this is true (lol ;)) - * + * Checks if a vehicle has a depot in its order list. + * @return True iff at least one order is a depot order. */ -bool VehicleHasDepotOrders(const Vehicle *v) +bool Vehicle::HasDepotOrder() const { const Order *order; - FOR_VEHICLE_ORDERS(v, order) { + FOR_VEHICLE_ORDERS(this, order) { if (order->IsType(OT_GOTO_DEPOT)) return true; } diff --git a/src/order_func.h b/src/order_func.h index 5736cb0ca..638c940af 100644 --- a/src/order_func.h +++ b/src/order_func.h @@ -19,7 +19,6 @@ /* Functions */ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination); void InvalidateVehicleOrder(const Vehicle *v, int data); -bool VehicleHasDepotOrders(const Vehicle *v); void CheckOrders(const Vehicle*); void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist = false); bool ProcessOrders(Vehicle *v); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ff6039c9a..b7bae6cb0 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -158,8 +158,8 @@ bool Vehicle::NeedsServicing() const bool Vehicle::NeedsAutomaticServicing() const { - if (_settings_game.order.gotodepot && VehicleHasDepotOrders(this)) return false; - if (this->current_order.IsType(OT_LOADING)) return false; + if (_settings_game.order.gotodepot && this->HasDepotOrder()) return false; + if (this->current_order.IsType(OT_LOADING)) return false; if (this->current_order.IsType(OT_GOTO_DEPOT) && this->current_order.GetDepotOrderType() != ODTFB_SERVICE) return false; return NeedsServicing(); } diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 20cd9ee21..4dfa4e6f1 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -658,6 +658,7 @@ public: } bool IsEngineCountable() const; + bool HasDepotOrder() const; }; #define FOR_ALL_VEHICLES_FROM(var, start) FOR_ALL_ITEMS_FROM(Vehicle, vehicle_index, var, start) |