# AIAirport Class Reference

Class that handles all airport related functions. More...

`#include <ai_airport.hpp>`

Inheritance diagram for AIAirport:

## Public Types
enum | AirportType { AT_SMALL = 0, AT_LARGE = 1, AT_METROPOLITAN = 3, AT_INTERNATIONAL = 4, AT_COMMUTER = 5, AT_INTERCON = 7, AT_HELIPORT = 2, AT_HELISTATION = 8, AT_HELIDEPOT = 6, AT_INVALID = 255 }
| The types of airports available in the game. More...
enum | PlaneType { PT_HELICOPTER = 0, PT_SMALL_PLANE = 1, PT_BIG_PLANE = 3, PT_INVALID = -1 }
| All plane types available. More...
## Static Public Member Functions
static const char * | GetClassName ()
| Get the name of this class to identify it towards squirrel.
static bool | IsValidAirportType (AirportType type)
| Checks whether the given AirportType is valid and available.
static bool | IsAirportInformationAvailable (AirportType type)
| Can you get information on this airport type? As opposed to IsValidAirportType this will return also return true when an airport type is no longer buildable.
static Money | GetPrice (AirportType type)
| Get the cost to build this AirportType.
static bool | IsHangarTile (TileIndex tile)
| Checks whether the given tile is actually a tile with a hangar.
static bool | IsAirportTile (TileIndex tile)
| Checks whether the given tile is actually a tile with an airport.
static int32 | GetAirportWidth (AirportType type)
| Get the width of this type of airport.
static int32 | GetAirportHeight (AirportType type)
| Get the height of this type of airport.
static int32 | GetAirportCoverageRadius (AirportType type)
| Get the coverage radius of this type of airport.
static int32 | GetNumHangars (TileIndex tile)
| Get the number of hangars of the airport.
static TileIndex | GetHangarOfAirport (TileIndex tile)
| Get the first hanger tile of the airport.
static bool | BuildAirport (TileIndex tile, AirportType type, StationID station_id)
| Builds a airport with tile at the topleft corner.
static bool | RemoveAirport (TileIndex tile)
| Removes an airport.
static AirportType | GetAirportType (TileIndex tile)
| Get the AirportType of an existing airport.
static int | GetNoiseLevelIncrease (TileIndex tile, AirportType type)
| Get the noise that will be added to the nearest town if an airport was built at this tile.
static TownID | GetNearestTown (TileIndex tile, AirportType type)
| Get the TownID of the town whose local authority will influence an airport at some tile.

## Detailed Description

Class that handles all airport related functions.

Definition at line 20 of file ai_airport.hpp.

## Member Enumeration Documentation

enum AIAirport::AirportType

The types of airports available in the game.

Enumerator:

  AT_SMALL | The small airport.
  AT_LARGE | The large airport.
  AT_METROPOLITAN | The metropolitan airport.
  AT_INTERNATIONAL | The international airport.
  AT_COMMUTER | The commuter airport.
  AT_INTERCON | The intercontinental airport.
  AT_HELIPORT | The heliport.
  AT_HELISTATION | The helistation.
  AT_HELIDEPOT | The helidepot.
  AT_INVALID | Invalid airport.

Definition at line 28 of file ai_airport.hpp.

enum AIAirport::PlaneType

All plane types available.

Enumerator:

  PT_HELICOPTER | A helicopter.
  PT_SMALL_PLANE | A small plane.
  PT_BIG_PLANE | A big plane.
  PT_INVALID | An invalid PlaneType.

Definition at line 48 of file ai_airport.hpp.

## Member Function Documentation

bool AIAirport::BuildAirport | ( | TileIndex | tile,
|  | AirportType | type,
|  | StationID | station_id |
| ) |  |  | `[static]`

Builds a airport with tile at the topleft corner.

Parameters:

  | tile | The topleft corner of the airport.
  | type | The type of airport to build.
  | station_id | The station to join, AIStation::STATION_NEW or AIStation::STATION_JOIN_ADJACENT.

Precondition:
  AIMap::IsValidTile(tile).
  AirportAvailable(type).
  station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id).

Exceptions:

  | AIError::ERR_AREA_NOT_CLEAR |
  | AIError::ERR_FLAT_LAND_REQUIRED |
  | AIError::ERR_LOCAL_AUTHORITY_REFUSES |
  | AIStation::ERR_STATION_TOO_LARGE |
  | AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION |

Returns:
  Whether the airport has been/can be build or not.

Definition at line 72 of file ai_airport.cpp.

References CMD_BUILD_AIRPORT, AIObject::DoCommand(), EnforcePrecondition, IsValidAirportType(), AIStation::IsValidStation(), IsValidTile(), AIBaseStation::STATION_JOIN_ADJACENT, and AIBaseStation::STATION_NEW.

int32 AIAirport::GetAirportCoverageRadius | ( | AirportType | type | ) | `[static]`

Get the coverage radius of this type of airport.

Parameters:

  | type | The type of airport.

Precondition:
  IsAirportInformationAvailable(type).

Returns:
  The radius in tiles.

Definition at line 65 of file ai_airport.cpp.

References _settings_game, CA_UNMODIFIED, AirportSpec::Get(), IsAirportInformationAvailable(), StationSettings::modified_catchment, and GameSettings::station.

int32 AIAirport::GetAirportHeight | ( | AirportType | type | ) | `[static]`

Get the height of this type of airport.

Parameters:

  | type | The type of airport.

Precondition:
  IsAirportInformationAvailable(type).

Returns:
  The height in tiles.

Definition at line 58 of file ai_airport.cpp.

References IsAirportInformationAvailable().

AIAirport::AirportType AIAirport::GetAirportType | ( | TileIndex | tile | ) | `[static]`

Get the AirportType of an existing airport.

Parameters:

  | tile | Any tile of the airport.

Precondition:
  AITile::IsStationTile(tile).
  AIStation::HasStationType(AIStation.GetStationID(tile), AIStation::STATION_AIRPORT).

Returns:
  The AirportType of the airport.

Definition at line 116 of file ai_airport.cpp.

References AT_INVALID, SpecializedStation< Station, false >::Get(), GetStationIndex(), AIStation::HasStationType(), AITile::IsStationTile(), and AIStation::STATION_AIRPORT.

int32 AIAirport::GetAirportWidth | ( | AirportType | type | ) | `[static]`

Get the width of this type of airport.

Parameters:

  | type | The type of airport.

Precondition:
  IsAirportInformationAvailable(type).

Returns:
  The width in tiles.

Definition at line 51 of file ai_airport.cpp.

References IsAirportInformationAvailable().

static const char* AIAirport::GetClassName | ( |  | ) | `[inline, static]`

Get the name of this class to identify it towards squirrel.

Definition at line 23 of file ai_airport.hpp.

TileIndex AIAirport::GetHangarOfAirport | ( | TileIndex | tile | ) | `[static]`

Get the first hanger tile of the airport.

Parameters:

  | tile | Any tile of the airport.

Precondition:
  AIMap::IsValidTile(tile).
  GetNumHangars(tile) > 0.

Returns:
  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.

Definition at line 103 of file ai_airport.cpp.

References _current_company, Station::airport, FACIL_AIRPORT, BaseStation::facilities, SpecializedStation< Station, false >::GetByTile(), Airport::GetHangarTile(), GetNumHangars(), INVALID_TILE, IsTileType(), IsValidTile(), MP_STATION, and BaseStation::owner.

TownID AIAirport::GetNearestTown | ( | TileIndex | tile,
|  | AirportType | type |
| ) |  |  | `[static]`

Get the TownID of the town whose local authority will influence an airport at some tile.

Parameters:

  | tile | The tile to check.
  | type | The AirportType to check.

Precondition:
  IsAirportInformationAvailable(type).

Returns:
  The TownID of the town closest to the tile.

Definition at line 145 of file ai_airport.cpp.

References AirportGetNearestTown(), AirportSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IsAirportInformationAvailable(), and IsValidTile().

int AIAirport::GetNoiseLevelIncrease | ( | TileIndex | tile,
|  | AirportType | type |
| ) |  |  | `[static]`

Get the noise that will be added to the nearest town if an airport was built at this tile.

Parameters:

  | tile | The tile to check.
  | type | The AirportType to check.

Returns:
  The amount of noise added to the nearest town.

Note:
  The noise will be added to the town with TownID GetNearestTown(tile, type).

Definition at line 128 of file ai_airport.cpp.

References _settings_game, AirportGetNearestTown(), GameSettings::economy, AirportSpec::Get(), GetAirportNoiseLevelForTown(), IsValidAirportType(), IsValidTile(), and EconomySettings::station_noise_level.

int32 AIAirport::GetNumHangars | ( | TileIndex | tile | ) | `[static]`

Get the number of hangars of the airport.

Parameters:

  | tile | Any tile of the airport.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  The number of hangars of the airport.

Definition at line 91 of file ai_airport.cpp.

References _current_company, Station::airport, FACIL_AIRPORT, BaseStation::facilities, SpecializedStation< Station, false >::GetByTile(), Airport::GetNumHangars(), IsTileType(), IsValidTile(), MP_STATION, and BaseStation::owner.

Referenced by GetHangarOfAirport().

Money AIAirport::GetPrice | ( | AirportType | type | ) | `[static]`

Get the cost to build this AirportType.

Parameters:

  | type | The AirportType to check.

Precondition:
  AirportAvailable(type).

Returns:
  The cost of building this AirportType.

Definition at line 29 of file ai_airport.cpp.

References AirportSpec::Get(), IsValidAirportType(), AirportSpec::size_x, and AirportSpec::size_y.

bool AIAirport::IsAirportInformationAvailable | ( | AirportType | type | ) | `[static]`

Can you get information on this airport type? As opposed to IsValidAirportType this will return also return true when an airport type is no longer buildable.

Parameters:

  | type | The AirportType to check.

Returns:
  True if and only if the AirportType is valid.

Postcondition:
  return value == false -> IsValidAirportType returns false.

Definition at line 24 of file ai_airport.cpp.

References AirportSpec::enabled, AirportSpec::Get(), and NUM_AIRPORTS.

Referenced by GetAirportCoverageRadius(), GetAirportHeight(), GetAirportWidth(), GetNearestTown(), and IsValidAirportType().

bool AIAirport::IsAirportTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with an airport.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has an airport.

Definition at line 44 of file ai_airport.cpp.

References IsAirport(), IsTileType(), IsValidTile(), and MP_STATION.

Referenced by RemoveAirport().

bool AIAirport::IsHangarTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with a hangar.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has a hangar.

Definition at line 37 of file ai_airport.cpp.

References IsHangar(), IsTileType(), IsValidTile(), and MP_STATION.

Referenced by RemoveAirport().

bool AIAirport::IsValidAirportType | ( | AirportType | type | ) | `[static]`

Checks whether the given AirportType is valid and available.

Parameters:

  | type | The AirportType to check.

Returns:
  True if and only if the AirportType is valid and available.

Postcondition:
  return value == true -> IsAirportInformationAvailable returns true.

Definition at line 19 of file ai_airport.cpp.

References AirportSpec::Get(), and IsAirportInformationAvailable().

Referenced by BuildAirport(), GetNoiseLevelIncrease(), and GetPrice().

bool AIAirport::RemoveAirport | ( | TileIndex | tile | ) | `[static]`

Removes an airport.

Parameters:

  | tile | Any tile of the airport.

Precondition:
  AIMap::IsValidTile(tile).

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |

Returns:
  Whether the airport has been/can be removed or not.

Definition at line 83 of file ai_airport.cpp.

References CMD_LANDSCAPE_CLEAR, AIObject::DoCommand(), EnforcePrecondition, IsAirportTile(), IsHangarTile(), and IsValidTile().

The documentation for this class was generated from the following files:

- src/ai/api/ai_airport.hpp
- src/ai/api/ai_airport.cpp