summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-11-01 22:27:34 +0000
committerrubidium <rubidium@openttd.org>2010-11-01 22:27:34 +0000
commit7148a8e21f82b92e67f7f854dca2db468d6c2d45 (patch)
treeec4f8017052290361db8433ebe8ff3e205189b7d /src
parentadde677c0a9bb06e416baf098f9072681ddf2e53 (diff)
downloadopenttd-7148a8e21f82b92e67f7f854dca2db468d6c2d45.tar.xz
(svn r21074) -Fix [FS#4194]: Crash when loading a corrupted 0.7.x (or before) savegame where the waypoint refered to an already removed town
Diffstat (limited to 'src')
-rw-r--r--src/saveload/waypoint_sl.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp
index 501aa86c5..5dac5d8e4 100644
--- a/src/saveload/waypoint_sl.cpp
+++ b/src/saveload/waypoint_sl.cpp
@@ -190,6 +190,15 @@ static void Ptrs_WAYP()
wp->town = ClosestTownFromTile(wp->xy, UINT_MAX);
} else if (CheckSavegameVersion(122)) {
/* Only for versions 12 .. 122 */
+ if (!Town::IsValidID(wp->town_index)) {
+ /* Upon a corrupted waypoint we'll likely get here. The next step will be to
+ * loop over all Ptrs procs to NULL the pointers. However, we don't know
+ * whether we're in the NULL or "normal" Ptrs proc. So just clear the list
+ * of old waypoints we constructed and then this waypoint (and the other
+ * possibly corrupt ones) will not be queried in the NULL Ptrs proc run. */
+ _old_waypoints.Clear();
+ SlErrorCorrupt("Referencing invalid Town");
+ }
wp->town = Town::Get(wp->town_index);
}
if (CheckSavegameVersion(84)) {