diff options
author | peter1138 <peter1138@openttd.org> | 2007-05-06 18:14:33 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2007-05-06 18:14:33 +0000 |
commit | 37a873e03ce5301e9d583072700a938ea889e368 (patch) | |
tree | 50b4edf6cde355dbf64d36175e883e73d2e37b4a /src/newgrf.cpp | |
parent | b0e3c0d40aa66880deef9aa56a8f5d5dea92ae67 (diff) | |
download | openttd-37a873e03ce5301e9d583072700a938ea889e368.tar.xz |
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r-- | src/newgrf.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 97411ca03..45075b65f 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -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 @@ static void NewSpriteGroup(byte *buf, int len) 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 VehicleMapSpriteGroup(byte *buf, byte feature, uint8 idcount, uint8 } +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 @@ static void FeatureMapSpriteGroup(byte *buf, int len) 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 @@ static void ResetNewGRFData() ResetStationClasses(); ResetCustomStations(); + /* Reset canal sprite groups */ + memset(_canal_sg, 0, sizeof(_canal_sg)); + /* Reset the snowline table. */ ClearSnowLine(); |