Skip to content

Commit

Permalink
Fix #6507: Don't try to load invalid depots from older savegames
Browse files Browse the repository at this point in the history
  • Loading branch information
LordAro committed May 28, 2019
1 parent 69c0332 commit 5eb7d49
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/saveload/afterload.cpp
Expand Up @@ -2305,6 +2305,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;
}
Expand Down

0 comments on commit 5eb7d49

Please sign in to comment.