summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-10-09 15:28:40 +0000
committerrubidium <rubidium@openttd.org>2007-10-09 15:28:40 +0000
commit6b9bff753188dde4678f78f0e12eeb618435b9c8 (patch)
tree25c86e8cfd08af1b2dce9753e381cc923d81d7d3 /src
parent5684e42adaea4ca4c534ebd039192164b0a4313e (diff)
downloadopenttd-6b9bff753188dde4678f78f0e12eeb618435b9c8.tar.xz
(svn r11233) -Fix [FS#1303]: handle some wrong written station NewGRFs a little more gracefully than segfaulting.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 2d9ed343f..c993e1e01 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -2864,6 +2864,12 @@ static void StationMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount)
for (uint i = 0; i < idcount; i++) {
uint8 stid = buf[3 + i];
StationSpec *statspec = _cur_grffile->stations[stid];
+
+ if (statspec == NULL) {
+ grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stid);
+ return;
+ }
+
byte *bp = &buf[4 + idcount];
for (uint c = 0; c < cidcount; c++) {
@@ -2896,6 +2902,10 @@ static void StationMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount)
for (uint i = 0; i < idcount; i++) {
uint8 stid = buf[3 + i];
StationSpec *statspec = _cur_grffile->stations[stid];
+ if (statspec == NULL) {
+ grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stid);
+ continue;
+ }
statspec->spritegroup[CT_DEFAULT] = _cur_grffile->spritegroups[groupid];
statspec->grffile = _cur_grffile;