diff options
author | peter1138 <peter1138@openttd.org> | 2006-05-06 20:20:02 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-05-06 20:20:02 +0000 |
commit | 416f8ec5fb6e581d0452022604a6864c4ead1258 (patch) | |
tree | 683837fde5c9eed28275fe082627c5864dce00a0 | |
parent | 79935130eb5ba75e129cd0e4ee501c7ac9ea67ca (diff) | |
download | openttd-416f8ec5fb6e581d0452022604a6864c4ead1258.tar.xz |
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
-rw-r--r-- | newgrf.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -1753,7 +1753,7 @@ static void VehicleNewName(byte *buf, int len) num = grf_load_byte(&buf); id = (lang & 0x80) ? grf_load_word(&buf) : grf_load_byte(&buf); - if (feature < GSF_AIRCRAFT+1) { + if (feature <= GSF_AIRCRAFT && id < _vehcounts[feature]) { id += _vehshifts[feature]; } endid = id + num; @@ -1779,22 +1779,23 @@ static void VehicleNewName(byte *buf, int len) break; } - case GSF_STATION: { - byte station = GB(id, 0, 8); - if (station >= _cur_grffile->num_stations) { - grfmsg(GMS_WARN, "VehicleNewName: Attempt to name undefined station 0x%X, ignoring.", station); - break; - } - + default: switch (GB(id, 8, 8)) { - case 0xC4: { /* Station class name */ - StationClassID sclass = _cur_grffile->stations[station].sclass; - SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name)); + case 0xC4: /* Station class name */ + if (GB(id, 0, 8) >= _cur_grffile->num_stations) { + grfmsg(GMS_WARN, "VehicleNewName: Attempt to name undefined station 0x%X, ignoring.", station); + } else { + StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)].sclass; + SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name)); + } break; - } - case 0xC5: /* Station name */ - _cur_grffile->stations[station].name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name); + case 0xC5: /* Station name */ + if (GB(id, 0, 8) >= _cur_grffile->num_stations) { + grfmsg(GMS_WARN, "VehicleNewName: Attempt to name undefined station 0x%X, ignoring.", station); + } else { + _cur_grffile->stations[station].name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name); + } break; default: @@ -1802,7 +1803,6 @@ static void VehicleNewName(byte *buf, int len) break; } break; - } #if 0 case GSF_CANAL : |