summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp34
-rw-r--r--src/station_cmd.cpp12
2 files changed, 6 insertions, 40 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index b403e137e..1c8b7e360 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -1958,37 +1958,13 @@ void UpdateAirplanesOnNewStation(const Station *st)
{
/* only 1 station is updated per function call, so it is enough to get entry_point once */
const AirportFTAClass *ap = st->airport.GetFTA();
+ Direction rotation = st->airport.tile == INVALID_TILE ? DIR_N : st->airport.rotation;
Aircraft *v;
FOR_ALL_AIRCRAFT(v) {
- if (v->IsNormalAircraft()) {
- if (v->targetairport == st->index) { // if heading to this airport
- /* update position of airplane. If plane is not flying, landing, or taking off
- * you cannot delete airport, so it doesn't matter */
- if (v->state >= FLYING) { // circle around
- Direction rotation = st->airport.tile == INVALID_TILE ? DIR_N : st->airport.rotation;
- v->pos = v->previous_pos = AircraftGetEntryPoint(v, ap, rotation);
- v->state = FLYING;
- UpdateAircraftCache(v);
- /* landing plane needs to be reset to flying height (only if in pause mode upgrade,
- * in normal mode, plane is reset in AircraftController. It doesn't hurt for FLYING */
- GetNewVehiclePosResult gp = GetNewVehiclePos(v);
- /* set new position x,y,z */
- SetAircraftPosition(v, gp.x, gp.y, GetAircraftFlyingAltitude(v));
- } else {
- assert(v->state == ENDTAKEOFF || v->state == HELITAKEOFF);
- byte takeofftype = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : ENDTAKEOFF;
- /* search in airportdata for that heading
- * easiest to do, since this doesn't happen a lot */
- for (uint cnt = 0; cnt < ap->nofelements; cnt++) {
- if (ap->layout[cnt].heading == takeofftype) {
- v->pos = ap->layout[cnt].position;
- UpdateAircraftCache(v);
- break;
- }
- }
- }
- }
- }
+ if (!v->IsNormalAircraft() || v->targetairport != st->index) continue;
+ assert(v->state == FLYING);
+ v->pos = v->previous_pos = AircraftGetEntryPoint(v, ap, rotation);
+ UpdateAircraftCache(v);
}
}
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 902b1ed45..77d8619d2 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2106,7 +2106,6 @@ void UpdateAirportsNoise()
*/
CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
- bool airport_upgrade = true;
StationID station_to_join = GB(p2, 16, 16);
bool reuse = (station_to_join != NEW_STATION);
if (!reuse) station_to_join = INVALID_STATION;
@@ -2188,8 +2187,6 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT);
}
} else {
- airport_upgrade = false;
-
/* allocate and initialize new station */
if (!Station::CanAllocateItem()) return_cmd_error(STR_ERROR_TOO_MANY_STATIONS_LOADING);
@@ -2239,14 +2236,7 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
AirportTileAnimationTrigger(st, cur_tile, AAT_BUILT);
} while ((++it)->ti.x != -0x80);
- /* if airport was demolished while planes were en-route to it, the
- * positions can no longer be the same (v->u.air.pos), since different
- * airports have different indexes. So update all planes en-route to this
- * airport. Only update if
- * 1. airport is upgraded
- * 2. airport is added to existing station (unfortunately unavoideable)
- */
- if (airport_upgrade) UpdateAirplanesOnNewStation(st);
+ UpdateAirplanesOnNewStation(st);
st->UpdateVirtCoord();
UpdateStationAcceptance(st, false);