1
0
Fork 0

Fix #8108: possible crash on loading TTD savegames with phantom oil rigs

pull/8110/head
SamuXarick 2020-05-04 18:41:16 +01:00 committed by Yexo
parent aa91c0666e
commit c01803cd42
1 changed files with 8 additions and 8 deletions

View File

@ -929,19 +929,19 @@ bool AfterLoadGame()
break; break;
case STATION_OILRIG: { case STATION_OILRIG: {
/* The internal encoding of oil rigs was changed twice.
* It was 3 (till 2.2) and later 5 (till 5.1).
* DeleteOilRig asserts on the correct type, and
* setting it unconditionally does not hurt.
*/
Station::GetByTile(t)->airport.type = AT_OILRIG;
/* Very old savegames sometimes have phantom oil rigs, i.e. /* Very old savegames sometimes have phantom oil rigs, i.e.
* an oil rig which got shut down, but not completely removed from * an oil rig which got shut down, but not completely removed from
* the map * the map
*/ */
TileIndex t1 = TILE_ADDXY(t, 0, 1); TileIndex t1 = TILE_ADDXY(t, 0, 1);
if (IsTileType(t1, MP_INDUSTRY) && if (!IsTileType(t1, MP_INDUSTRY) || GetIndustryGfx(t1) != GFX_OILRIG_1) {
GetIndustryGfx(t1) == GFX_OILRIG_1) {
/* The internal encoding of oil rigs was changed twice.
* It was 3 (till 2.2) and later 5 (till 5.1).
* Setting it unconditionally does not hurt.
*/
Station::GetByTile(t)->airport.type = AT_OILRIG;
} else {
DeleteOilRig(t); DeleteOilRig(t);
} }
break; break;