# HG changeset patch # User rubidium # Date 1191943720 0 # Node ID 2676eea146e6ba41791f9358bdeaef707bc01c91 # Parent 34a2e15f66700825366f8bd65a8ae62c2d9576ad (svn r11233) -Fix [FS#1303]: handle some wrong written station NewGRFs a little more gracefully than segfaulting. diff -r 34a2e15f6670 -r 2676eea146e6 src/newgrf.cpp --- a/src/newgrf.cpp Tue Oct 09 02:57:29 2007 +0000 +++ b/src/newgrf.cpp Tue Oct 09 15:28:40 2007 +0000 @@ -2864,6 +2864,12 @@ 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 @@ 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;