diff options
author | yexo <yexo@openttd.org> | 2010-01-08 19:14:33 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-01-08 19:14:33 +0000 |
commit | da3decba522de1149f2fe90fe592957f42bb89e9 (patch) | |
tree | edd58316c00a1eed6dca2b2ee780fae389e83be5 | |
parent | 37e2ea30a8a4c0e103b7d1a18c1e79a609eeb962 (diff) | |
download | openttd-da3decba522de1149f2fe90fe592957f42bb89e9.tar.xz |
(svn r18759) -Fix [NewGRF]: don't segfault when a newgrf contains an action2 and action3 but no action0
-rw-r--r-- | src/newgrf.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index fd2e52e58..04df38e33 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3183,7 +3183,7 @@ static void StationMapSpriteGroup(byte *buf, uint8 idcount) if (ctype == CT_INVALID) continue; for (uint i = 0; i < idcount; i++) { - StationSpec *statspec = _cur_grffile->stations[stations[i]]; + StationSpec *statspec = _cur_grffile->stations == NULL ? NULL : _cur_grffile->stations[stations[i]]; if (statspec == NULL) { grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stations[i]); @@ -3198,7 +3198,7 @@ static void StationMapSpriteGroup(byte *buf, uint8 idcount) if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) return; for (uint i = 0; i < idcount; i++) { - StationSpec *statspec = _cur_grffile->stations[stations[i]]; + StationSpec *statspec = _cur_grffile->stations == NULL ? NULL : _cur_grffile->stations[stations[i]]; if (statspec == NULL) { grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stations[i]); @@ -3227,6 +3227,11 @@ static void TownHouseMapSpriteGroup(byte *buf, uint8 idcount) uint16 groupid = grf_load_word(&buf); if (!IsValidGroupID(groupid, "TownHouseMapSpriteGroup")) return; + if (_cur_grffile->housespec == NULL) { + grfmsg(1, "TownHouseMapSpriteGroup: No houses defined, skipping"); + return; + } + for (uint i = 0; i < idcount; i++) { HouseSpec *hs = _cur_grffile->housespec[houses[i]]; @@ -3253,6 +3258,11 @@ static void IndustryMapSpriteGroup(byte *buf, uint8 idcount) uint16 groupid = grf_load_word(&buf); if (!IsValidGroupID(groupid, "IndustryMapSpriteGroup")) return; + if (_cur_grffile->industryspec == NULL) { + grfmsg(1, "IndustryMapSpriteGroup: No industries defined, skipping"); + return; + } + for (uint i = 0; i < idcount; i++) { IndustrySpec *indsp = _cur_grffile->industryspec[industries[i]]; @@ -3279,6 +3289,11 @@ static void IndustrytileMapSpriteGroup(byte *buf, uint8 idcount) uint16 groupid = grf_load_word(&buf); if (!IsValidGroupID(groupid, "IndustrytileMapSpriteGroup")) return; + if (_cur_grffile->indtspec == NULL) { + grfmsg(1, "IndustrytileMapSpriteGroup: No industry tiles defined, skipping"); + return; + } + for (uint i = 0; i < idcount; i++) { IndustryTileSpec *indtsp = _cur_grffile->indtspec[indtiles[i]]; |