diff -r 7ff39cd822b0 -r 71d62b85d3ad src/newgrf.cpp --- a/src/newgrf.cpp Sun May 06 17:06:10 2007 +0000 +++ b/src/newgrf.cpp Sun May 06 18:14:33 2007 +0000 @@ -39,6 +39,7 @@ #include "table/town_land.h" #include "cargotype.h" #include "industry.h" +#include "newgrf_canal.h" /* TTDPatch extended GRF format codec * (c) Petr Baudis 2004 (GPL'd) @@ -2244,6 +2245,7 @@ case GSF_SHIP: case GSF_AIRCRAFT: case GSF_STATION: + case GSF_CANAL: case GSF_CARGOS: { byte sprites = _cur_grffile->spriteset_numents; @@ -2513,6 +2515,30 @@ } +static void CanalMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount) +{ + byte *bp = &buf[4 + idcount + cidcount * 3]; + uint16 groupid = grf_load_word(&bp); + + if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { + grfmsg(1, "CanalMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", + groupid, _cur_grffile->spritegroups_count); + return; + } + + for (uint i = 0; i < idcount; i++) { + CanalFeature cf = (CanalFeature)buf[3 + i]; + + if (cf >= CF_END) { + grfmsg(1, "CanalMapSpriteGroup: Canal subset %d out of range, skipping", cf); + continue; + } + + _canal_sg[cf] = _cur_grffile->spritegroups[groupid]; + } +} + + static void StationMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount) { for (uint i = 0; i < idcount; i++) { @@ -2661,6 +2687,10 @@ VehicleMapSpriteGroup(buf, feature, idcount, cidcount, wagover); return; + case GSF_CANAL: + CanalMapSpriteGroup(buf, idcount, cidcount); + return; + case GSF_STATION: StationMapSpriteGroup(buf, idcount, cidcount); return; @@ -4315,6 +4345,9 @@ ResetStationClasses(); ResetCustomStations(); + /* Reset canal sprite groups */ + memset(_canal_sg, 0, sizeof(_canal_sg)); + /* Reset the snowline table. */ ClearSnowLine();