diff options
author | frosch <frosch@openttd.org> | 2015-07-26 12:25:37 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2015-07-26 12:25:37 +0000 |
commit | 574b981e33e6e64e694bb1904a9dd70a2c392ad8 (patch) | |
tree | 057bfdcc4d8bb01ac55a58572735c1d321800a8f | |
parent | a81968d0f35a58c04a445a35a02f1ce06837d5dd (diff) | |
download | openttd-574b981e33e6e64e694bb1904a9dd70a2c392ad8.tar.xz |
(svn r27342) -Add: Optionally return the number of sprites in the spriteset from GetCustomRailSprite.
-rw-r--r-- | src/newgrf_railtype.cpp | 5 | ||||
-rw-r--r-- | src/newgrf_railtype.h | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp index 872a3a7f6..8a074db97 100644 --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -100,9 +100,10 @@ RailTypeResolverObject::RailTypeResolverObject(const RailtypeInfo *rti, TileInde * @param tile The tile to get the sprite for. * @param rtsg The type of sprite to draw. * @param content Where are we drawing the tile? + * @param [out] num_results If not NULL, return the number of sprites in the spriteset. * @return The sprite to draw. */ -SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context) +SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results) { assert(rtsg < RTSG_END); @@ -112,6 +113,8 @@ SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSp const SpriteGroup *group = object.Resolve(); if (group == NULL || group->GetNumResults() == 0) return 0; + if (num_results) *num_results = group->GetNumResults(); + return group->GetResult(); } diff --git a/src/newgrf_railtype.h b/src/newgrf_railtype.h index 9b00bf5bf..4c68e7d1d 100644 --- a/src/newgrf_railtype.h +++ b/src/newgrf_railtype.h @@ -44,7 +44,7 @@ struct RailTypeResolverObject : public ResolverObject { /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const; }; -SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context = TCX_NORMAL); +SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context = TCX_NORMAL, uint *num_results = NULL); SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui = false); uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile); |