summaryrefslogtreecommitdiff
path: root/src/vehicle_base.h
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2011-01-29 17:26:23 +0000
committerterkhen <terkhen@openttd.org>2011-01-29 17:26:23 +0000
commit9626e0bf2bb87c7e0957b65069527c26b0da4a34 (patch)
tree262318a1cc7e19176640a0a9533cece310fb66f5 /src/vehicle_base.h
parent23ffef05cec14ae23b6f778f1df4efa85410b3fb (diff)
downloadopenttd-9626e0bf2bb87c7e0957b65069527c26b0da4a34.tar.xz
(svn r21922) -Codechange: Unify articulated vehicle checking functions.
Diffstat (limited to 'src/vehicle_base.h')
-rw-r--r--src/vehicle_base.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index cc5e332d3..d63d97b89 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -644,6 +644,33 @@ public:
bool IsEngineCountable() const;
bool HasDepotOrder() const;
void HandlePathfindingResult(bool path_found);
+
+ /**
+ * Check if the vehicle is a front engine.
+ * @return Returns true if the vehicle is a front engine.
+ */
+ FORCEINLINE bool IsFrontEngine() const
+ {
+ return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_FRONT);
+ }
+
+ /**
+ * Check if the vehicle is an articulated part of an engine.
+ * @return Returns true if the vehicle is an articulated part.
+ */
+ FORCEINLINE bool IsArticulatedPart() const
+ {
+ return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_ARTICULATED_PART);
+ }
+
+ /**
+ * Check if an engine has an articulated part.
+ * @return True if the engine has an articulated part.
+ */
+ FORCEINLINE bool HasArticulatedPart() const
+ {
+ return this->Next() != NULL && this->Next()->IsArticulatedPart();
+ }
};
#define FOR_ALL_VEHICLES_FROM(var, start) FOR_ALL_ITEMS_FROM(Vehicle, vehicle_index, var, start)