summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-12-14 21:27:30 +0000
committerterkhen <terkhen@openttd.org>2010-12-14 21:27:30 +0000
commitd6959dcc6be6a6c6cdc94c9c249a636a2781c8e5 (patch)
tree6c44d607b91a012870e842dbd219d7cfbfab4ba1
parent79e2b3153d4d89a653a72e07727e58300b435ac4 (diff)
downloadopenttd-d6959dcc6be6a6c6cdc94c9c249a636a2781c8e5.tar.xz
(svn r21517) -Codechange: Add IsGroundVehicle function to the Engine class.
-rw-r--r--src/articulated_vehicles.cpp6
-rw-r--r--src/engine_base.h9
2 files changed, 12 insertions, 3 deletions
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index c1bb1f838..7556d5497 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -108,7 +108,7 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine)
uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
if (cargo_type < NUM_CARGO) capacity[cargo_type] = cargo_capacity;
- if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return capacity;
+ if (!e->IsGroundVehicle()) return capacity;
if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return capacity;
@@ -133,7 +133,7 @@ bool IsArticulatedVehicleRefittable(EngineID engine)
if (IsEngineRefittable(engine)) return true;
const Engine *e = Engine::Get(engine);
- if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return false;
+ if (!e->IsGroundVehicle()) return false;
if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return false;
@@ -161,7 +161,7 @@ void GetArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type,
*union_mask = veh_cargos;
*intersection_mask = (veh_cargos != 0) ? veh_cargos : UINT32_MAX;
- if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return;
+ if (!e->IsGroundVehicle()) return;
if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return;
for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
diff --git a/src/engine_base.h b/src/engine_base.h
index ac6fa1d22..251b42729 100644
--- a/src/engine_base.h
+++ b/src/engine_base.h
@@ -87,6 +87,15 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
uint GetDisplayWeight() const;
uint GetDisplayMaxTractiveEffort() const;
Date GetLifeLengthInDays() const;
+
+ /**
+ * Check if the engine is a ground vehicle.
+ * @return True iff the engine is a train or a road vehicle.
+ */
+ FORCEINLINE bool IsGroundVehicle() const
+ {
+ return this->type == VEH_TRAIN || this->type == VEH_ROAD;
+ }
};
struct EngineIDMapping {