diff options
author | peter1138 <peter1138@openttd.org> | 2010-02-07 22:22:54 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2010-02-07 22:22:54 +0000 |
commit | 898e879bd90e34505cd7083acecf341fd798d02c (patch) | |
tree | f9c016c9dcb7d2e78726296e15aceb6adf4a0e2c /src/newgrf.cpp | |
parent | 01474412fc95b69ea6595a94eeb8baa0db575e16 (diff) | |
download | openttd-898e879bd90e34505cd7083acecf341fd798d02c.tar.xz |
(svn r19056) -Add: [NewGRF] Action 3/2/1 (i.e. new graphics) support for rail types. (To be documented...)
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r-- | src/newgrf.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index f8d988489..d6db4c6f3 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3037,6 +3037,7 @@ static void NewSpriteGroup(ByteReader *buf) case GSF_STATION: case GSF_CANAL: case GSF_CARGOS: + case GSF_RAILTYPES: { byte sprites = _cur_grffile->spriteset_numents; byte num_loaded = type; @@ -3519,6 +3520,35 @@ static void CargoMapSpriteGroup(ByteReader *buf, uint8 idcount) } } +static void RailTypeMapSpriteGroup(ByteReader *buf, uint8 idcount) +{ + uint8 *railtypes = AllocaM(uint8, idcount); + for (uint i = 0; i < idcount; i++) { + railtypes[i] = _cur_grffile->railtype_map[buf->ReadByte()]; + } + + uint8 cidcount = buf->ReadByte(); + for (uint c = 0; c < cidcount; c++) { + uint8 ctype = buf->ReadByte(); + uint16 groupid = buf->ReadWord(); + if (!IsValidGroupID(groupid, "RailTypeMapSpriteGroup")) continue; + + if (ctype >= RTSG_END) continue; + + extern RailtypeInfo _railtypes[RAILTYPE_END]; + for (uint i = 0; i < idcount; i++) { + if (railtypes[i] != INVALID_RAILTYPE) { + RailtypeInfo *rti = &_railtypes[railtypes[i]]; + + rti->group[ctype] = _cur_grffile->spritegroups[groupid]; + } + } + } + + /* Railtypes do not use the default group. */ + buf->ReadWord(); +} + /* Action 0x03 */ static void FeatureMapSpriteGroup(ByteReader *buf) @@ -3594,6 +3624,10 @@ static void FeatureMapSpriteGroup(ByteReader *buf) CargoMapSpriteGroup(buf, idcount); return; + case GSF_RAILTYPES: + RailTypeMapSpriteGroup(buf, idcount); + break; + default: grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %d, skipping", feature); return; @@ -6446,6 +6480,9 @@ static void AfterLoadGRFs() /* Load old shore sprites in new position, if they were replaced by ActionA */ ActivateOldShore(); + /* Set up custom rail types */ + InitRailTypes(); + Engine *e; FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) { if (_gted[e->index].rv_max_speed != 0) { |