(svn r16884) -Codechange: Add Train::GetFirstEnginePart() and use it.
This commit is contained in:
22
src/train.h
22
src/train.h
@@ -273,6 +273,28 @@ struct Train : public SpecializedVehicle<Train, VEH_TRAIN> {
|
||||
return this->Next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first part of a multi-part engine.
|
||||
* @return First part of the engine.
|
||||
*/
|
||||
FORCEINLINE Train *GetFirstEnginePart()
|
||||
{
|
||||
Train *v = this;
|
||||
while (v->IsArticulatedPart()) v = v->Previous();
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first part of a multi-part engine.
|
||||
* @return First part of the engine.
|
||||
*/
|
||||
FORCEINLINE const Train *GetFirstEnginePart() const
|
||||
{
|
||||
const Train *v = this;
|
||||
while (v->IsArticulatedPart()) v = v->Previous();
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last part of a multi-part engine.
|
||||
* @return Last part of the engine.
|
||||
|
Reference in New Issue
Block a user