summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSamuXarick <43006711+SamuXarick@users.noreply.github.com>2020-05-04 18:41:16 +0100
committerYexo <t.marinussen@gmail.com>2020-05-04 21:21:06 +0200
commitc01803cd42b06c9e0716b86079d825dbb06036ad (patch)
treeddb3d76b680e548666174b99e0d49cdbee532f8e /src
parentaa91c0666e1cc199d55a9b2454f32f625ad1fb13 (diff)
downloadopenttd-c01803cd42b06c9e0716b86079d825dbb06036ad.tar.xz
Fix #8108: possible crash on loading TTD savegames with phantom oil rigs
Diffstat (limited to 'src')
-rw-r--r--src/saveload/afterload.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 63e4b37e6..432e35dd2 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -929,19 +929,19 @@ bool AfterLoadGame()
break;
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.
* an oil rig which got shut down, but not completely removed from
* the map
*/
TileIndex t1 = TILE_ADDXY(t, 0, 1);
- if (IsTileType(t1, MP_INDUSTRY) &&
- 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 {
+ if (!IsTileType(t1, MP_INDUSTRY) || GetIndustryGfx(t1) != GFX_OILRIG_1) {
DeleteOilRig(t);
}
break;