diff options
author | truebrain <truebrain@openttd.org> | 2009-01-12 17:11:45 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2009-01-12 17:11:45 +0000 |
commit | c2406cd42d481a697602b430111a9e59af61660f (patch) | |
tree | ced1a262eb143ad6e64ec02f4a4c89835c0c32fd /src/ai/api/ai_airport.hpp | |
parent | ec97e1fd0d6ca942805fa25d94007437bc0ed952 (diff) | |
download | openttd-c2406cd42d481a697602b430111a9e59af61660f.tar.xz |
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
NoAI is an API (a framework) to build your own AIs in. See:
http://wiki.openttd.org/wiki/index.php/AI:Main_Page
With many thanks to:
- glx and Rubidium for their syncing, feedback and hard work
- Yexo for his feedback, patches, and AIs which tested the system very deep
- Morloth for his feedback and patches
- TJIP for hosting a challenge which kept NoAI on track
- All AI authors for testing our AI API, and all other people who helped in one way or another
-Remove: all old AIs and their cheats/hacks
Diffstat (limited to 'src/ai/api/ai_airport.hpp')
-rw-r--r-- | src/ai/api/ai_airport.hpp | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/src/ai/api/ai_airport.hpp b/src/ai/api/ai_airport.hpp new file mode 100644 index 000000000..d1d18714b --- /dev/null +++ b/src/ai/api/ai_airport.hpp @@ -0,0 +1,164 @@ +/* $Id$ */ + +/** @file ai_airport.hpp Everything to query and build airports. */ + +#ifndef AI_AIRPORT_HPP +#define AI_AIRPORT_HPP + +#include "ai_object.hpp" + +/** + * Class that handles all airport related functions. + */ +class AIAirport : public AIObject { +public: + static const char *GetClassName() { return "AIAirport"; } + + /** + * The types of airports available in the game. + */ + enum AirportType { + /* Note: the values _are_ important as they represent an in-game value */ + AT_SMALL = 0, //!< The small airport. + AT_LARGE = 1, //!< The large airport. + AT_METROPOLITAN = 3, //!< The metropolitan airport. + AT_INTERNATIONAL = 4, //!< The international airport. + AT_COMMUTER = 5, //!< The commuter airport. + AT_INTERCON = 7, //!< The intercontinental airport. + + /* Next are the airports which only have helicopter platforms */ + AT_HELIPORT = 2, //!< The heliport. + AT_HELISTATION = 8, //!< The helistation. + AT_HELIDEPOT = 6, //!< The helidepot. + + AT_INVALID = 255, //!< Invalid airport. + }; + + /** + * All plane types available. + */ + enum PlaneType { + /* Note: the values _are_ important as they represent an in-game value */ + PT_HELICOPTER = 0, //!< A helicopter. + PT_SMALL_PLANE = 1, //!< A small plane. + PT_BIG_PLANE = 3, //!< A big plane. + + PT_INVALID = -1, //!< An invalid PlaneType + }; + + /** + * Checks whether the given AirportType is valid. + * @param type The AirportType to check. + * @return True if and only if the AirportTypeis valid. + */ + static bool IsValidAirportType(AirportType type); + + /** + * Checks whether the given tile is actually a tile with a hangar. + * @param tile The tile to check. + * @pre AIMap::IsValidTile(tile). + * @return True if and only if the tile has a hangar. + */ + static bool IsHangarTile(TileIndex tile); + + /** + * Checks whether the given tile is actually a tile with a airport. + * @param tile The tile to check. + * @pre AIMap::IsValidTile(tile). + * @return True if and only if the tile has a airport. + */ + static bool IsAirportTile(TileIndex tile); + + /** + * Check if a certain airport type is already available. + * @param type The type of airport to check. + */ + static bool AirportAvailable(AirportType type); + + /** + * Get the width of this type of airport. + * @param type The type of airport. + * @return The width in tiles. + */ + static int32 GetAirportWidth(AirportType type); + + /** + * Get the height of this type of airport. + * @param type The type of airport. + * @return The height in tiles. + */ + static int32 GetAirportHeight(AirportType type); + + /** + * Get the coverage radius of this type of airport. + * @param type The type of airport. + * @return The radius in tiles. + */ + static int32 GetAirportCoverageRadius(AirportType type); + + /** + * Get the number of hangars of the airport. + * @param tile Any tile of the airport. + * @pre AIMap::IsValidTile(tile). + * @return The number of hangars of the airport. + */ + static int32 GetNumHangars(TileIndex tile); + + /** + * Get the first hanger tile of the airport. + * @param tile Any tile of the airport. + * @pre AIMap::IsValidTile(tile). + * @pre GetNumHangars(tile) > 0. + * @return The first hanger tile of the airport. + * @note Possible there are more hangars, but you won't be able to find them + * without walking over all the tiles of the airport and using + * IsHangarTile() on them. + */ + static TileIndex GetHangarOfAirport(TileIndex tile); + + /** + * Builds a airport with tile at the topleft corner. + * @param tile The topleft corner of the airport. + * @param type The type of airport to build. + * @param join_adjacent When building next to an other station, don't create a new station when this flag is true. + * @pre AIMap::IsValidTile(tile). + * @pre AirportAvailable(type). + * @exception AIError::ERR_AREA_NOT_CLEAR + * @exception AIError::ERR_FLAT_LAND_REQUIRED + * @exception AIError::ERR_LOCAL_AUTHORITY_REFUSES + * @exception AIStation::ERR_STATION_TOO_LARGE + * @exception AIStation::ERR_STATION_TOO_CLOSE_TO_OTHER_STATION + * @return Whether the airport has been/can be build or not. + */ + static bool BuildAirport(TileIndex tile, AirportType type, bool join_adjacent); + + /** + * Removes a airport. + * @param tile Any tile of the airport. + * @pre AIMap::IsValidTile(tile). + * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY + * @return Whether the airport has been/can be removed or not. + */ + static bool RemoveAirport(TileIndex tile); + + /** + * Get the AirportType of an existing airport. + * @param tile Any tile of the airport. + * @pre AITile::IsStationTile(tile). + * @pre AIStation::HasStationType(AIStation.GetStationID(tile), AIStation::STATION_AIRPORT). + * @return The AirportType of the airport. + */ + static AirportType GetAirportType(TileIndex tile); + + /** + * Get the noise that will be added to the nearest town if an airport was + * built at this tile. + * @param tile The tile to check. + * @param type The AirportType to check. + * @return The TownID of the town closest to the tile. + * @note The noise will be added to the town with TownID AITile.GetClosestTown(tile). + */ + static int GetNoiseLevelIncrease(TileIndex tile, AirportType type); +}; + +#endif /* AI_AIRPORT_HPP */ |