1
0
Fork 0

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

pull/7632/head
Charles Pigott 2019-04-27 09:59:45 +01:00
parent 69c0332813
commit 5eb7d49024
1 changed files with 8 additions and 0 deletions

View File

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