diff options
-rw-r--r-- | src/aircraft.h | 2 | ||||
-rw-r--r-- | src/aircraft_cmd.cpp | 13 | ||||
-rw-r--r-- | src/saveload/vehicle_sl.cpp | 2 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/aircraft.h b/src/aircraft.h index 491a1a09f..a35159b70 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -31,7 +31,7 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height); void UpdateAirplanesOnNewStation(const Station *st); void UpdateAircraftCache(Aircraft *v); -void AircraftLeaveHangar(Aircraft *v); +void AircraftLeaveHangar(Aircraft *v, Direction exit_dir); void AircraftNextAirportPos_and_Order(Aircraft *v); void SetAircraftPosition(Aircraft *v, int x, int y, int z); byte GetAircraftFlyingAltitude(const Aircraft *v); 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); } diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index ff738c7e2..14827eb7b 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -178,7 +178,7 @@ void UpdateOldAircraft() continue; } - AircraftLeaveHangar(a); // make airplane visible if it was in a depot for example + AircraftLeaveHangar(a, a->direction); // make airplane visible if it was in a depot for example a->vehstatus &= ~VS_STOPPED; // make airplane moving UpdateAircraftCache(a); a->cur_speed = a->vcache.cached_max_speed; // so aircraft don't have zero speed while in air |