summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-08-17 21:46:25 +0000
committeryexo <yexo@openttd.org>2010-08-17 21:46:25 +0000
commitafb60ec59ca6b22614e40b4def00b2372f2789be (patch)
tree389e39a5ee7e4b84372cf44473abf3149f2030f6 /src
parentcc45b99866ef1ee142ae680acff9639c407a27a6 (diff)
downloadopenttd-afb60ec59ca6b22614e40b4def00b2372f2789be.tar.xz
(svn r20528) -Fix: in old savegames aircraft can have an invalid state
Diffstat (limited to 'src')
-rw-r--r--src/saveload/afterload.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 1a2d07cca..f9e229485 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -2226,6 +2226,26 @@ bool AfterLoadGame()
FOR_ALL_DEPOTS(d) d->build_date = _date;
}
+ /* In old versions it was possible to remove an airport while a plane was
+ * taking off or landing. This gives all kind of problems when building
+ * another airport in the same station so we don't allow that anymore.
+ * For old savegames with such aircraft we just throw them in the air and
+ * treat the aircraft like they were flying already. */
+ if (CheckSavegameVersion(146)) {
+ Aircraft *v;
+ FOR_ALL_AIRCRAFT(v) {
+ if (!v->IsNormalAircraft()) continue;
+ Station *st = GetTargetAirportIfValid(v);
+ if (st == NULL && v->state != FLYING) {
+ v->state = FLYING;
+ UpdateAircraftCache(v);
+ AircraftNextAirportPos_and_Order(v);
+ /* get aircraft back on running altitude */
+ if ((v->vehstatus & VS_CRASHED) == 0) SetAircraftPosition(v, v->x_pos, v->y_pos, GetAircraftFlyingAltitude(v));
+ }
+ }
+ }
+
/* Road stops is 'only' updating some caches */
AfterLoadRoadStops();
AfterLoadLabelMaps();