OpenTTD Game API
Public Types | Static Public Member Functions
GSAirport Class Reference

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

Inheritance diagram for GSAirport:

Public Types

enum  AirportType {
  AT_SMALL,
  AT_LARGE,
  AT_METROPOLITAN,
  AT_INTERNATIONAL,
  AT_COMMUTER,
  AT_INTERCON,
  AT_HELIPORT,
  AT_HELISTATION,
  AT_HELIDEPOT,
  AT_INVALID
}
 The types of airports available in the game. More...
 
enum  PlaneType {
  PT_HELICOPTER,
  PT_SMALL_PLANE,
  PT_BIG_PLANE,
  PT_INVALID
}
 All plane types available. More...
 

Static Public Member Functions

static bool IsValidAirportType (AirportType type)
 Checks whether the given AirportType is valid and available. More...
 
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. More...
 
static Money GetPrice (AirportType type)
 Get the cost to build this AirportType. More...
 
static bool IsHangarTile (TileIndex tile)
 Checks whether the given tile is actually a tile with a hangar. More...
 
static bool IsAirportTile (TileIndex tile)
 Checks whether the given tile is actually a tile with an airport. More...
 
static int32 GetAirportWidth (AirportType type)
 Get the width of this type of airport. More...
 
static int32 GetAirportHeight (AirportType type)
 Get the height of this type of airport. More...
 
static int32 GetAirportCoverageRadius (AirportType type)
 Get the coverage radius of this type of airport. More...
 
static int32 GetNumHangars (TileIndex tile)
 Get the number of hangars of the airport. More...
 
static TileIndex GetHangarOfAirport (TileIndex tile)
 Get the first hangar tile of the airport. More...
 
static bool BuildAirport (TileIndex tile, AirportType type, StationID station_id)
 Builds a airport with tile at the topleft corner. More...
 
static bool RemoveAirport (TileIndex tile)
 Removes an airport. More...
 
static AirportType GetAirportType (TileIndex tile)
 Get the AirportType of an existing airport. More...
 
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. More...
 
static TownID GetNearestTown (TileIndex tile, AirportType type)
 Get the TownID of the town whose local authority will influence an airport at some tile. More...
 
static uint16 GetMaintenanceCostFactor (AirportType type)
 Get the maintenance cost factor of an airport type. More...
 
static Money GetMonthlyMaintenanceCost (AirportType type)
 Get the monthly maintenance cost of an airport type. More...
 

Detailed Description

Class that handles all airport related functions.

Member Enumeration Documentation

◆ 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.

◆ 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.

Member Function Documentation

◆ BuildAirport()

static bool GSAirport::BuildAirport ( TileIndex  tile,
AirportType  type,
StationID  station_id 
)
static

Builds a airport with tile at the topleft corner.

Parameters
tileThe topleft corner of the airport.
typeThe type of airport to build.
station_idThe station to join, GSStation::STATION_NEW or GSStation::STATION_JOIN_ADJACENT.
Precondition
GSMap::IsValidTile(tile).
AirportAvailable(type).
station_id == GSStation::STATION_NEW || station_id == GSStation::STATION_JOIN_ADJACENT || GSStation::IsValidStation(station_id).
Valid GSCompanyMode active in scope.
Exceptions
GSError::ERR_AREA_NOT_CLEAR
GSError::ERR_FLAT_LAND_REQUIRED
GSError::ERR_LOCAL_AUTHORITY_REFUSES
GSStation::ERR_STATION_TOO_LARGE
GSStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
Returns
Whether the airport has been/can be build or not.

◆ GetAirportCoverageRadius()

static int32 GSAirport::GetAirportCoverageRadius ( AirportType  type)
static

Get the coverage radius of this type of airport.

Parameters
typeThe type of airport.
Precondition
IsAirportInformationAvailable(type).
Returns
The radius in tiles.

◆ GetAirportHeight()

static int32 GSAirport::GetAirportHeight ( AirportType  type)
static

Get the height of this type of airport.

Parameters
typeThe type of airport.
Precondition
IsAirportInformationAvailable(type).
Returns
The height in tiles.

◆ GetAirportType()

static AirportType GSAirport::GetAirportType ( TileIndex  tile)
static

Get the AirportType of an existing airport.

Parameters
tileAny tile of the airport.
Precondition
GSTile::IsStationTile(tile).
GSStation::HasStationType(GSStation.GetStationID(tile), GSStation::STATION_AIRPORT).
Returns
The AirportType of the airport.

◆ GetAirportWidth()

static int32 GSAirport::GetAirportWidth ( AirportType  type)
static

Get the width of this type of airport.

Parameters
typeThe type of airport.
Precondition
IsAirportInformationAvailable(type).
Returns
The width in tiles.

◆ GetHangarOfAirport()

static TileIndex GSAirport::GetHangarOfAirport ( TileIndex  tile)
static

Get the first hangar tile of the airport.

Parameters
tileAny tile of the airport.
Precondition
GSMap::IsValidTile(tile).
GetNumHangars(tile) > 0.
Returns
The first hangar 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.

◆ GetMaintenanceCostFactor()

static uint16 GSAirport::GetMaintenanceCostFactor ( AirportType  type)
static

Get the maintenance cost factor of an airport type.

Parameters
typeThe airport type to get the maintenance factor of.
Precondition
IsAirportInformationAvailable(type)
Returns
Maintenance cost factor of the airport type.

◆ GetMonthlyMaintenanceCost()

static Money GSAirport::GetMonthlyMaintenanceCost ( AirportType  type)
static

Get the monthly maintenance cost of an airport type.

Parameters
typeThe airport type to get the monthly maintenance cost of.
Precondition
IsAirportInformationAvailable(type)
Returns
Monthly maintenance cost of the airport type.

◆ GetNearestTown()

static TownID GSAirport::GetNearestTown ( TileIndex  tile,
AirportType  type 
)
static

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

Parameters
tileThe tile to check.
typeThe AirportType to check.
Precondition
IsAirportInformationAvailable(type).
Returns
The TownID of the town closest to the tile.

◆ GetNoiseLevelIncrease()

static int GSAirport::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
tileThe tile to check.
typeThe AirportType to check.
Precondition
IsAirportInformationAvailable(type).
Returns
The amount of noise added to the nearest town.
Note
The noise will be added to the town with TownID GetNearestTown(tile, type).

◆ GetNumHangars()

static int32 GSAirport::GetNumHangars ( TileIndex  tile)
static

Get the number of hangars of the airport.

Parameters
tileAny tile of the airport.
Precondition
GSMap::IsValidTile(tile).
Returns
The number of hangars of the airport.

◆ GetPrice()

static Money GSAirport::GetPrice ( AirportType  type)
static

Get the cost to build this AirportType.

Parameters
typeThe AirportType to check.
Precondition
AirportAvailable(type).
Returns
The cost of building this AirportType.

◆ IsAirportInformationAvailable()

static bool GSAirport::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
typeThe AirportType to check.
Returns
True if and only if the AirportType is valid.
Postcondition
return value == false -> IsValidAirportType returns false.

◆ IsAirportTile()

static bool GSAirport::IsAirportTile ( TileIndex  tile)
static

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

Parameters
tileThe tile to check.
Precondition
GSMap::IsValidTile(tile).
Returns
True if and only if the tile has an airport.

◆ IsHangarTile()

static bool GSAirport::IsHangarTile ( TileIndex  tile)
static

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

Parameters
tileThe tile to check.
Precondition
GSMap::IsValidTile(tile).
Returns
True if and only if the tile has a hangar.

◆ IsValidAirportType()

static bool GSAirport::IsValidAirportType ( AirportType  type)
static

Checks whether the given AirportType is valid and available.

Parameters
typeThe AirportType to check.
Returns
True if and only if the AirportType is valid and available.
Postcondition
return value == true -> IsAirportInformationAvailable returns true.

◆ RemoveAirport()

static bool GSAirport::RemoveAirport ( TileIndex  tile)
static

Removes an airport.

Parameters
tileAny tile of the airport.
Precondition
GSMap::IsValidTile(tile).
Valid GSCompanyMode active in scope.
Exceptions
GSError::ERR_OWNED_BY_ANOTHER_COMPANY
Returns
Whether the airport has been/can be removed or not.