summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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;
}