Fix #6507: Don't try to load invalid depots from older savegames

This commit is contained in:
Charles Pigott 2019-04-27 09:59:45 +01:00 committed by PeterN
parent 3299d6540b
commit d9f9a64389
1 changed files with 8 additions and 0 deletions

View File

@ -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;
}