For some time OpenTTD have supported for NewGRFs that define new airports. As of now, they can't define new state machines (movement patterns). What they can do is to create more views/rotations of airports. In the OpenGFX+ Airports set there exist a 180 degree rotation of the small airport.
In order to support the NewGRF movements in airports, some work need to be done on the NoAI API. I start this thread in order to open up for thoughts about how this API expansion should be done to keep backward compatibility as good as possible while still providing a good API for the future.
My initial proposal:
- We need APIs to interact with views/rotations
- Acquire information about airports that previously could be hard coded in the AIs
Code: Select all
AIAirportTypeList() // List of airport types
AIAirportViewList(airport_type) // List of available views for a given airport type
AIAirport.IsValidAirportView(airport_view)
Code: Select all
AIAirport.GetAirportWidth
AIAirport.GetAirportHeight
AIAirport.BuildAirport
AIAirport.GetNoiseLevelIncrease
AIAirport.GetNearestTown
To clean up a bit I would propose a rename as follows. I personally think that AIAirport.IsAirportInformationAvailable better fit under the name "IsValid" and the IsValid.. function could go under the name "IsBuildable". However such a rename could potentially cause unnecessary confusion.
Code: Select all
AIAirport.IsValidAirport => AIAirport.IsValidAirportType
AIAirport.IsAirportInformationAvailable => AIAirport.IsAirportTypeInformationAvailable
As for getting more information about airports via the API, now that you soon can't trust hard coded values anymore, I here just give an idea of what I have in my wish-list: (that I also think could be possible to implement) Some of these might not be possible with the current NewGRF Spec. In that case we AI authors will have to work with the NewGRF people to find a solution.
Code: Select all
AIAirport.GetHoldingQueueLength(airport_tile) // Get the number of aircrafts that are waiting to land on the airport
AIAirport.GetNumberOfRunways(airport_type) // Gets the number of runways that a given airport type have
AIAirport.GetNumberOfHelicopterLandingPlaces(airport_type) // Gets the number of places where helicopters can start and land
AIAirport.GetNumberOfLoadingBays(airport_type) // Gets the number of loading bays for aircrafts of a given airport type.
As for actually implementing this it is something that will take some time and I will probably see what I can do, but before getting started with actual code, it is useful to get reflections on this proposal which is just based on my initial thoughts.