(svn r16884) -Codechange: Add Train::GetFirstEnginePart() and use it.

This commit is contained in:
frosch
2009-07-19 19:17:41 +00:00
parent ba11651346
commit f1f4edfbd1
3 changed files with 26 additions and 7 deletions

View File

@@ -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.