diff options
author | frosch <frosch@openttd.org> | 2009-07-19 19:17:41 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-07-19 19:17:41 +0000 |
commit | 7b92d9efe4efbc69b4a2b4563f2fc7645bc8938d (patch) | |
tree | 8494dfb1d08cb55203440c4c2f02f077394b6041 /src/train.h | |
parent | 3999dbe7f786931607c0f185ed1fc166b0bdd012 (diff) | |
download | openttd-7b92d9efe4efbc69b4a2b4563f2fc7645bc8938d.tar.xz |
(svn r16884) -Codechange: Add Train::GetFirstEnginePart() and use it.
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. */ |