summaryrefslogtreecommitdiff
path: root/vehicle.h
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2005-11-05 16:07:26 +0000
committerpeter1138 <peter1138@openttd.org>2005-11-05 16:07:26 +0000
commit267314b4d0a28ac8a9d5b0d44a7c6dcd7ef88ac1 (patch)
treead0c24edec46ec7170c414961c2eda4185970ae0 /vehicle.h
parentd86829d0e09fd981cc65c85d65f75129f9299b8f (diff)
downloadopenttd-267314b4d0a28ac8a9d5b0d44a7c6dcd7ef88ac1.tar.xz
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
Diffstat (limited to 'vehicle.h')
-rw-r--r--vehicle.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/vehicle.h b/vehicle.h
index be2b120d4..91921d4ba 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -30,6 +30,7 @@ enum VehStatus {
// 1 and 3 do not appear to be used
typedef enum TrainSubtypes {
TS_Front_Engine = 0, // Leading engine of a train
+ TS_Artic_Part = 1, // Articulated part of an engine
TS_Not_First = 2, // Wagon or additional engine
TS_Free_Car = 4, // First in a wagon chain (in depot)
} TrainSubtype;
@@ -414,6 +415,41 @@ static inline bool IsVehicleIndex(uint index)
return index < GetVehiclePoolSize();
}
+/**
+ * Get the next real (non-articulated part) vehicle in the consist.
+ * @param v Vehicle.
+ * @return Next vehicle in the consist.
+ */
+static inline Vehicle *GetNextVehicle(const Vehicle *v)
+{
+ Vehicle *u = v->next;
+ while (u != NULL && u->subtype == TS_Artic_Part) {
+ u = u->next;
+ }
+ return u;
+}
+
+/**
+ * Check if an engine has an articulated part.
+ * @param v Vehicle.
+ * @return True if the engine has an articulated part.
+ */
+static inline bool EngineHasArticPart(const Vehicle *v)
+{
+ return (v->next != NULL && v->next->subtype == TS_Artic_Part);
+}
+
+/**
+ * Get the last part of a multi-part engine.
+ * @param v Vehicle.
+ * @return Last part of the engine.
+ */
+static inline Vehicle *GetLastEnginePart(Vehicle *v)
+{
+ while (EngineHasArticPart(v)) v = v->next;
+ return v;
+}
+
/* Returns order 'index' of a vehicle or NULL when it doesn't exists */
static inline Order *GetVehicleOrder(const Vehicle *v, int index)
{