summaryrefslogtreecommitdiff
path: root/src/aircraft_cmd.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-09-09 21:27:57 +0000
committeryexo <yexo@openttd.org>2011-09-09 21:27:57 +0000
commitbc3b725812bc5910b89426d60df66b371026f2b3 (patch)
treeb3f26fd4a2870060b35a42b0f065e93fb32649cf /src/aircraft_cmd.cpp
parenta8889fd0e03d7b87a8bf61a259a926178e00e5e2 (diff)
downloadopenttd-bc3b725812bc5910b89426d60df66b371026f2b3.tar.xz
(svn r22915) -Fix (r22743): TTO savegames with any aircraft not in an hangar caused crashes during load
Diffstat (limited to 'src/aircraft_cmd.cpp')
-rw-r--r--src/aircraft_cmd.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 10820436e..7475e412f 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -1251,15 +1251,17 @@ void AircraftNextAirportPos_and_Order(Aircraft *v)
/**
* Aircraft is about to leave the hangar.
* @param v Aircraft leaving.
+ * @param exit_dir The direction the vehicle leaves the hangar.
+ * @note This function is called in AfterLoadGame for old savegames, so don't rely
+ * on any data to be valid, especially don't rely on the fact that the vehicle
+ * is actually on the ground inside a depot.
*/
-void AircraftLeaveHangar(Aircraft *v)
+void AircraftLeaveHangar(Aircraft *v, Direction exit_dir)
{
- const Station *st = Station::GetByTile(v->tile);
-
v->cur_speed = 0;
v->subspeed = 0;
v->progress = 0;
- v->direction = st->airport.GetHangarExitDirection(v->tile);
+ v->direction = exit_dir;
v->vehstatus &= ~VS_HIDDEN;
{
Vehicle *u = v->Next();
@@ -1344,7 +1346,8 @@ static void AircraftEventHandler_InHangar(Aircraft *v, const AirportFTAClass *ap
/* airplane goto state takeoff, helicopter to helitakeoff */
v->state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF;
}
- AircraftLeaveHangar(v);
+ const Station *st = Station::GetByTile(v->tile);
+ AircraftLeaveHangar(v, st->airport.GetHangarExitDirection(v->tile));
AirportMove(v, apc);
}