FS#640 - Airport Removal crashes trunk/

Attached to Project: OpenTTD
Opened by izhirahider (izhirahider) - Tuesday, 20 February 2007, 16:44 GMT
Last edited by Celestar (Celestar) - Friday, 09 March 2007, 08:17 GMT
Type Bug
Category Core
Status Closed
Assigned To Celestar (Celestar)
Operating System All
Severity Critical
Priority Urgent
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


trunk/, revision 8824.

Removing an airport causes OpenTTD to crash, reporting the following message:

(...)/src/station.h:118: const AirportFTAClass* Station::Airport() const: Assertion `airport_tile != 0' failed.

A way to reproduce it is shown in the following video:
This task depends upon

Closed by  Celestar (Celestar)
Thursday, 29 March 2007, 13:52 GMT
Reason for closing:  Fixed
Additional comments about closing:  r9524
Comment by Remko Bijker (Rubidium) - Tuesday, 20 February 2007, 18:10 GMT
It's caused by r8755, but I'm not sure what the best way to solve this problem is.
Comment by Leviath.NL (Leviath.NL) - Friday, 23 February 2007, 22:03 GMT
I did manage to just delete that line to fix the problem but this seems no real solution to me....
Comment by Tonio2000 (Tonio2000) - Sunday, 25 February 2007, 11:55 GMT
Help me!!!

What can I do?

Comment by Weztie (Weztie) - Sunday, 25 February 2007, 16:32 GMT
I have found a work around. Perhaps it will help developers locate the problem too.

If you remove the airport you want to delete from the goto list for all airplanes you can delete the airport.
However, you do need to ensure that any airplanes that have just left the airport have made their turns away from the airport. That is they are not in the holding or takeoff patterns.
Comment by Arathorn (Arathorn) - Wednesday, 14 March 2007, 18:23 GMT
I've found out that simply making sure no airplane is currently going to the airport you want to remove or no airplanes are taking off you can safely remove the airport.
Comment by Weztie (Weztie) - Thursday, 15 March 2007, 23:28 GMT
I believe that this became the case when patch r8921 was made. There are comments against that patch that indicated it fixed some airplane issues. I did a little more testing and found that the crash appears to occur whenever a plane is on-route to the airport you are deleting, or has taken off from, but not yet made the first turn.
Comment by Skaven55 (Skaven55) - Wednesday, 28 March 2007, 02:56 GMT
I have created this patch to solve this problem. r8755 added an incorrect assert to airport_tile != 0 where GetAirport already handles this issue (as it did prior to r8755). A deletion of an airport causes airport_tile to reset to 0 and the next call of Airport() results in a debug error.
Comment by Celestar (Celestar) - Thursday, 29 March 2007, 10:31 GMT
Attempt to solve this problem by adding a "dummy" State Machine. However, as the previous poster displayed, GetAirport already makes sure that the game asserts when a wrong State Machine is selected, so a simple removal of the assert would fix the problem as well.