(svn r18759) -Fix [NewGRF]: don't segfault when a newgrf contains an action2 and action3 but no action0

This commit is contained in:
yexo 2010-01-08 19:14:33 +00:00
parent 37e2ea30a8
commit da3decba52

View File

@ -3183,7 +3183,7 @@ static void StationMapSpriteGroup(byte *buf, uint8 idcount)
if (ctype == CT_INVALID) continue; if (ctype == CT_INVALID) continue;
for (uint i = 0; i < idcount; i++) { 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) { if (statspec == NULL) {
grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stations[i]); 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; if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) return;
for (uint i = 0; i < idcount; i++) { 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) { if (statspec == NULL) {
grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stations[i]); 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); uint16 groupid = grf_load_word(&buf);
if (!IsValidGroupID(groupid, "TownHouseMapSpriteGroup")) return; 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++) { for (uint i = 0; i < idcount; i++) {
HouseSpec *hs = _cur_grffile->housespec[houses[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); uint16 groupid = grf_load_word(&buf);
if (!IsValidGroupID(groupid, "IndustryMapSpriteGroup")) return; 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++) { for (uint i = 0; i < idcount; i++) {
IndustrySpec *indsp = _cur_grffile->industryspec[industries[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); uint16 groupid = grf_load_word(&buf);
if (!IsValidGroupID(groupid, "IndustrytileMapSpriteGroup")) return; 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++) { for (uint i = 0; i < idcount; i++) {
IndustryTileSpec *indtsp = _cur_grffile->indtspec[indtiles[i]]; IndustryTileSpec *indtsp = _cur_grffile->indtspec[indtiles[i]];