diff options
Diffstat (limited to 'src/train.h')
-rw-r--r-- | src/train.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/train.h b/src/train.h index 5dc3c1cfa..965d45baf 100644 --- a/src/train.h +++ b/src/train.h @@ -274,6 +274,28 @@ struct Train : public SpecializedVehicle<Train, VEH_TRAIN> { } /** + * 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. */ |