From 128e71cde957545fc4229097432f2bbc0a3115fa Mon Sep 17 00:00:00 2001 From: bjarni Date: Wed, 5 Sep 2007 10:33:42 +0000 Subject: (svn r11046) -Codechange: added function to get the next movable (non-articulated, non-read end of dualheaded engine) vehicle in a train --- src/train.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/train.h') diff --git a/src/train.h b/src/train.h index d2cfa1268..db9e53c6a 100644 --- a/src/train.h +++ b/src/train.h @@ -248,6 +248,19 @@ static inline Vehicle *GetNextVehicle(const Vehicle *v) return v->Next(); } +/** 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. + */ +static inline Vehicle *GetNextUnit(Vehicle *v) +{ + assert(v->type == VEH_TRAIN); + v = GetNextVehicle(v); + if (v != NULL && IsRearDualheaded(v)) v = v->Next(); + + return v; +} + void ConvertOldMultiheadToNew(); void ConnectMultiheadedTrains(); uint CountArticulatedParts(EngineID engine_type); -- cgit v1.2.3-54-g00ecf