diff -r 76282d3b748d -r ca3fd1fbe311 src/train.h --- a/src/train.h Thu Sep 06 19:42:48 2007 +0000 +++ b/src/train.h Sat Oct 06 21:16:00 2007 +0000 @@ -225,6 +225,16 @@ return v; } +/** Tell if we are dealing with the rear end of a multiheaded engine. + * @param v Vehicle. + * @return True if the engine is the rear part of a dualheaded engine. + */ +static inline bool IsRearDualheaded(const Vehicle *v) +{ + assert(v->type == VEH_TRAIN); + return (IsMultiheaded(v) && !IsTrainEngine(v)); +} + /** Get the next real (non-articulated part) vehicle in the consist. * @param v Vehicle. * @return Next vehicle in the consist. @@ -238,6 +248,19 @@ 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); @@ -273,9 +296,8 @@ WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; } void PlayLeaveStationSound() const; bool IsPrimaryVehicle() const { return IsFrontEngine(this); } - bool HasFront() const { return true; } int GetImage(Direction direction) const; - int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; } + int GetDisplaySpeed() const { return this->u.rail.last_speed * 10 / 16; } int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; } Money GetRunningCost() const; bool IsInDepot() const { return CheckTrainInDepot(this, false) != -1; }