diff options
author | smatz <smatz@openttd.org> | 2011-02-02 14:50:57 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2011-02-02 14:50:57 +0000 |
commit | b15719bbd216966661ed66d8a54c17b27d77f391 (patch) | |
tree | 7d7d3232a5df0d61c0e896d259137f718a36a545 /src/saveload | |
parent | 0ebc548a89a9966bc6ccae2731bf4d187efbe0b5 (diff) | |
download | openttd-b15719bbd216966661ed66d8a54c17b27d77f391.tar.xz |
(svn r21939) -Fix (r16357): the check for valid depot wasn't strict enough
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/oldloader_sl.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index d177e7207..db2ea4dca 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -108,7 +108,7 @@ static void FixTTDDepots() { const Depot *d; FOR_ALL_DEPOTS_FROM(d, 252) { - if (!IsRoadDepotTile(d->xy) && !IsRailDepotTile(d->xy) && !IsShipDepotTile(d->xy) && !IsHangarTile(d->xy)) { + if (!IsDepotTile(d->xy) || GetDepotIndex(d->xy) != d->index) { /** Workaround for SVXConverter bug, depots 252-255 could be invalid */ delete d; } @@ -670,7 +670,10 @@ static bool LoadOldDepot(LoadgameState *ls, int num) if (!LoadChunk(ls, d, depot_chunk)) return false; if (d->xy != 0) { - d->town = Town::Get(RemapTownIndex(_old_town_index)); + /* In some cases, there could be depots referencing invalid town. */ + Town *t = Town::GetIfValid(RemapTownIndex(_old_town_index)); + if (t == NULL) t = Town::GetRandom(); + d->town = t; } else { delete d; } |