summaryrefslogtreecommitdiff
path: root/src/train.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-08-16 14:02:20 +0000
committerfrosch <frosch@openttd.org>2008-08-16 14:02:20 +0000
commitf7826f8a372d3120cc9d56e4d1c11df3e2fd577c (patch)
tree4c275596da6f577f47cea17f49ee3870846e07cb /src/train.h
parent56459cab81f6a56d1fde29130670d001389ff7ce (diff)
downloadopenttd-f7826f8a372d3120cc9d56e4d1c11df3e2fd577c.tar.xz
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
Diffstat (limited to 'src/train.h')
-rw-r--r--src/train.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/train.h b/src/train.h
index 0e92a962c..22ed95b04 100644
--- a/src/train.h
+++ b/src/train.h
@@ -247,6 +247,20 @@ static inline Vehicle *GetNextVehicle(const Vehicle *v)
return v->Next();
}
+/** Get the previous real (non-articulated part) vehicle in the consist.
+ * @param w Vehicle.
+ * @return Previous vehicle in the consist.
+ */
+static inline Vehicle *GetPrevVehicle(const Vehicle *w)
+{
+ assert(w->type == VEH_TRAIN);
+
+ Vehicle *v = w->Previous();
+ while (v != NULL && IsArticulatedPart(v)) v = v->Previous();
+
+ return v;
+}
+
/** Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist.
* @param v Vehicle.
* @return Next vehicle in the consist.
@@ -260,6 +274,19 @@ static inline Vehicle *GetNextUnit(Vehicle *v)
return v;
}
+/** Get the previous real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist.
+ * @param v Vehicle.
+ * @return Previous vehicle in the consist.
+ */
+static inline Vehicle *GetPrevUnit(Vehicle *v)
+{
+ assert(v->type == VEH_TRAIN);
+ v = GetPrevVehicle(v);
+ if (v != NULL && IsRearDualheaded(v)) v = GetPrevVehicle(v);
+
+ return v;
+}
+
void ConvertOldMultiheadToNew();
void ConnectMultiheadedTrains();