summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-04-16 16:41:02 +0000
committerfrosch <frosch@openttd.org>2011-04-16 16:41:02 +0000
commitaedd38255b2bc961d95a53cf784c3110711e05e3 (patch)
tree659ddbe6d2a2b3a6678e324890ff7380c3bb9e9d
parent30b4bad60cc914902fe29df52e89d64871d6a297 (diff)
downloadopenttd-aedd38255b2bc961d95a53cf784c3110711e05e3.tar.xz
(svn r22327) -Add: Vehicle::GetGroundVehicleFlags() for accessing GroundVehicle<>::gv_flags through a Vehicle struct.
-rw-r--r--src/vehicle.cpp30
-rw-r--r--src/vehicle_base.h3
2 files changed, 33 insertions, 0 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index f4f38bd9c..38437c1b9 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2392,6 +2392,36 @@ const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const
}
/**
+ * Access the ground vehicle flags of the vehicle.
+ * @pre The vehicle is a #GroundVehicle.
+ * @return #GroundVehicleFlags of the vehicle.
+ */
+uint16 &Vehicle::GetGroundVehicleFlags()
+{
+ assert(this->IsGroundVehicle());
+ if (this->type == VEH_TRAIN) {
+ return Train::From(this)->gv_flags;
+ } else {
+ return RoadVehicle::From(this)->gv_flags;
+ }
+}
+
+/**
+ * Access the ground vehicle flags of the vehicle.
+ * @pre The vehicle is a #GroundVehicle.
+ * @return #GroundVehicleFlags of the vehicle.
+ */
+const uint16 &Vehicle::GetGroundVehicleFlags() const
+{
+ assert(this->IsGroundVehicle());
+ if (this->type == VEH_TRAIN) {
+ return Train::From(this)->gv_flags;
+ } else {
+ return RoadVehicle::From(this)->gv_flags;
+ }
+}
+
+/**
* Calculates the set of vehicles that will be affected by a given selection.
* @param set [inout] Set of affected vehicles.
* @param v First vehicle of the selection.
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index baf99d398..a673bcfd1 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -249,6 +249,9 @@ public:
GroundVehicleCache *GetGroundVehicleCache();
const GroundVehicleCache *GetGroundVehicleCache() const;
+ uint16 &GetGroundVehicleFlags();
+ const uint16 &GetGroundVehicleFlags() const;
+
void DeleteUnreachedAutoOrders();
void HandleLoading(bool mode = false);