@@ -2384,24 +2384,30 @@ static CommandCost RemoveAirport(TileInd
tile = st->airport.tile;
CommandCost cost(EXPENSES_CONSTRUCTION);
for (const Aircraft *a : Aircraft::Iterate()) {
if (!a->IsNormalAircraft()) continue;
if (a->targetairport == st->index && a->state != FLYING) {
return_cmd_error(STR_ERROR_AIRCRAFT_IN_THE_WAY);
}
if (flags & DC_EXEC) {
for (uint i = 0; i < st->airport.GetNumHangars(); ++i) {
DeleteWindowById(
WC_VEHICLE_DEPOT, st->airport.GetHangarTile(i)
);
const AirportSpec *as = st->airport.GetSpec();
/* The noise level is the noise from the airport and reduce it to account for the distance to the town center.
* And as for construction, always remove it, even if the setting is not set, in order to avoid the
* need of recalculation */
AirportTileIterator it(st);
uint dist;
Town *nearest = AirportGetNearestTown(as, it, dist);
nearest->noise_reached -= GetAirportNoiseLevelForDistance(as, dist);
TILE_AREA_LOOP(tile_cur, st->airport) {
if (!st->TileBelongsToAirport(tile_cur)) continue;
@@ -2414,30 +2420,24 @@ static CommandCost RemoveAirport(TileInd
if (IsHangarTile(tile_cur)) OrderBackup::Reset(tile_cur, false);
DeleteAnimatedTile(tile_cur);
DoClearSquare(tile_cur);
DeleteNewGRFInspectWindow(GSF_AIRPORTTILES, tile_cur);
/* Clear the persistent storage. */
delete st->airport.psa;
st->rect.AfterRemoveRect(st, st->airport);
st->airport.Clear();
st->facilities &= ~FACIL_AIRPORT;
InvalidateWindowData(WC_STATION_VIEW, st->index, -1);
if (_settings_game.economy.station_noise_level) {
SetWindowDirty(WC_TOWN_VIEW, st->town->index);
Company::Get(st->owner)->infrastructure.airport--;
Status change: