Changeset - r25000:a4806b58d770
[Not reviewed]
master
0 1 0
Jonathan G Rennison - 3 years ago 2021-03-07 00:14:50
j.g.rennison@gmail.com
Fix #8809: Crash when removing airport when hangar window open
1 file changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -2390,12 +2390,18 @@ static CommandCost RemoveAirport(TileInd
 
		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;
 
@@ -2420,18 +2426,12 @@ static CommandCost RemoveAirport(TileInd
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		/* 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();
 
		st->facilities &= ~FACIL_AIRPORT;
 

	
 
		InvalidateWindowData(WC_STATION_VIEW, st->index, -1);
0 comments (0 inline, 0 general)