summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2019-04-27 09:59:45 +0100
committerPeterN <peter@fuzzle.org>2019-04-29 17:46:28 +0100
commitd9f9a64389ebe66b2dfa7b16cd66ed463ab2cec7 (patch)
tree8872c62932cfbb022c72cd9a53513ee4784b4eee /src
parent3299d6540be33449d3a4eebc7de69c1f57993d98 (diff)
downloadopenttd-d9f9a64389ebe66b2dfa7b16cd66ed463ab2cec7.tar.xz
Fix #6507: Don't try to load invalid depots from older savegames
Diffstat (limited to 'src')
-rw-r--r--src/saveload/afterload.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index eea896dd7..06cbbd17d 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -2312,6 +2312,14 @@ bool AfterLoadGame()
if (IsSavegameVersionBefore(SLV_128)) {
const Depot *d;
FOR_ALL_DEPOTS(d) {
+ /* At some point, invalid depots were saved into the game (possibly those removed in the past?)
+ * Remove them here, so they don't cause issues further down the line */
+ if (!IsDepotTile(d->xy)) {
+ DEBUG(sl, 0, "Removing invalid depot %d at %d, %d", d->index, TileX(d->xy), TileY(d->xy));
+ delete d;
+ d = nullptr;
+ continue;
+ }
_m[d->xy].m2 = d->index;
if (IsTileType(d->xy, MP_WATER)) _m[GetOtherShipDepotTile(d->xy)].m2 = d->index;
}