summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan G Rennison <j.g.rennison@gmail.com>2021-03-07 00:14:50 +0000
committerCharles Pigott <charlespigott@googlemail.com>2021-03-07 17:59:38 +0000
commit25909b06d2b5efaa874e5ebbd4bf7f57ebbff688 (patch)
treed91d29aa0a3e6fbbaa7a2b6d16b522f2a3bd40ba /src
parent2860de7bf448b5d1170256ab4aa833eb72b45ed8 (diff)
downloadopenttd-25909b06d2b5efaa874e5ebbd4bf7f57ebbff688.tar.xz
Fix #8809: Crash when removing airport when hangar window open
Diffstat (limited to 'src')
-rw-r--r--src/station_cmd.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 4077a7b8c..7266ad618 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2393,6 +2393,12 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
}
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
@@ -2423,12 +2429,6 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
/* Clear the persistent storage. */
delete st->airport.psa;
- for (uint i = 0; i < st->airport.GetNumHangars(); ++i) {
- DeleteWindowById(
- WC_VEHICLE_DEPOT, st->airport.GetHangarTile(i)
- );
- }
-
st->rect.AfterRemoveRect(st, st->airport);
st->airport.Clear();