From d2b236802cb202c07aa7586b197935b96dddee7b Mon Sep 17 00:00:00 2001 From: frosch Date: Mon, 4 Jul 2011 20:25:17 +0000 Subject: (svn r22633) -Fix: Implement variables 25 and 7F for railtypes. --- src/newgrf.cpp | 1 + src/newgrf_railtype.cpp | 10 +++++++--- src/rail.h | 5 +++++ src/table/railtypes.h | 4 ++++ 4 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 78d91cd4a..ffd8e37fd 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -4599,6 +4599,7 @@ static void RailTypeMapSpriteGroup(ByteReader *buf, uint8 idcount) if (railtypes[i] != INVALID_RAILTYPE) { RailtypeInfo *rti = &_railtypes[railtypes[i]]; + rti->grffile[ctype] = _cur_grffile; rti->group[ctype] = _cur_grffile->spritegroups[groupid]; } } diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp index c38124464..b01b3b084 100644 --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -67,7 +67,7 @@ static const SpriteGroup *RailTypeResolveReal(const ResolverObject *object, cons return NULL; } -static inline void NewRailTypeResolver(ResolverObject *res, TileIndex tile, TileContext context) +static inline void NewRailTypeResolver(ResolverObject *res, TileIndex tile, TileContext context, const GRFFile *grffile) { res->GetRandomBits = &RailTypeGetRandomBits; res->GetTriggers = &RailTypeGetTriggers; @@ -85,6 +85,8 @@ static inline void NewRailTypeResolver(ResolverObject *res, TileIndex tile, Tile res->trigger = 0; res->reseed = 0; res->count = 0; + + res->grffile = grffile; } /** @@ -104,7 +106,7 @@ SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSp const SpriteGroup *group; ResolverObject object; - NewRailTypeResolver(&object, tile, context); + NewRailTypeResolver(&object, tile, context, rti->grffile[rtsg]); group = SpriteGroup::Resolve(rti->group[rtsg], &object); if (group == NULL || group->GetNumResults() == 0) return 0; @@ -140,5 +142,7 @@ uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile) */ void GetRailTypeResolver(ResolverObject *ro, uint index) { - NewRailTypeResolver(ro, index, TCX_NORMAL); + /* There is no unique GRFFile for the tile. Multiple GRFs can define different parts of the railtype. + * However, currently the NewGRF Debug GUI does not display variables depending on the GRF (like 0x7F) anyway. */ + NewRailTypeResolver(ro, index, TCX_NORMAL, NULL); } diff --git a/src/rail.h b/src/rail.h index 067db7957..63dfa2e10 100644 --- a/src/rail.h +++ b/src/rail.h @@ -232,6 +232,11 @@ struct RailtypeInfo { */ byte sorting_order; + /** + * NewGRF providing the Action3 for the railtype. NULL if not available. + */ + const GRFFile *grffile[RTSG_END]; + /** * Sprite groups for resolving sprites */ diff --git a/src/table/railtypes.h b/src/table/railtypes.h index 191714028..3fceb4ffe 100644 --- a/src/table/railtypes.h +++ b/src/table/railtypes.h @@ -105,6 +105,7 @@ static const RailtypeInfo _original_railtypes[] = { 0 << 4 | 7, { NULL }, + { NULL }, }, /** Electrified railway */ @@ -197,6 +198,7 @@ static const RailtypeInfo _original_railtypes[] = { 1 << 4 | 7, { NULL }, + { NULL }, }, /** Monorail */ @@ -285,6 +287,7 @@ static const RailtypeInfo _original_railtypes[] = { 2 << 4 | 7, { NULL }, + { NULL }, }, /** Maglev */ @@ -373,6 +376,7 @@ static const RailtypeInfo _original_railtypes[] = { 3 << 4 | 7, { NULL }, + { NULL }, }, }; -- cgit v1.2.3-70-g09d2