Update: Translations from eints
[openttd-github.git] / src / script / api / script_airport.hpp
blobcb3fc3c227892341bf981d44f176dd2be65bae1a
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file script_airport.hpp Everything to query and build airports. */
10 #ifndef SCRIPT_AIRPORT_HPP
11 #define SCRIPT_AIRPORT_HPP
13 #include "script_object.hpp"
14 #include "../../airport.h"
16 /**
17 * Class that handles all airport related functions.
18 * @api ai game
20 class ScriptAirport : public ScriptObject {
21 public:
22 /**
23 * The types of airports available in the game.
25 enum AirportType {
26 /* Note: these values represent part of the in-game AirportTypes enum */
27 AT_SMALL = ::AT_SMALL, ///< The small airport.
28 AT_LARGE = ::AT_LARGE, ///< The large airport.
29 AT_METROPOLITAN = ::AT_METROPOLITAN, ///< The metropolitan airport.
30 AT_INTERNATIONAL = ::AT_INTERNATIONAL, ///< The international airport.
31 AT_COMMUTER = ::AT_COMMUTER, ///< The commuter airport.
32 AT_INTERCON = ::AT_INTERCON, ///< The intercontinental airport.
33 AT_HELIPORT = ::AT_HELIPORT, ///< The heliport.
34 AT_HELISTATION = ::AT_HELISTATION, ///< The helistation.
35 AT_HELIDEPOT = ::AT_HELIDEPOT, ///< The helidepot.
36 AT_INVALID = ::AT_INVALID, ///< Invalid airport.
39 /**
40 * All plane types available.
42 enum PlaneType {
43 /* Note: these values represent part of the in-game values, which are not defined in an enum */
44 PT_HELICOPTER = 0, ///< A helicopter.
45 PT_SMALL_PLANE = 1, ///< A small plane.
46 PT_BIG_PLANE = 3, ///< A big plane.
48 PT_INVALID = -1, ///< An invalid PlaneType
51 /**
52 * Checks whether the given AirportType is valid and available.
53 * @param type The AirportType to check.
54 * @return True if and only if the AirportType is valid and available.
55 * @post return value == true -> IsAirportInformationAvailable returns true.
57 static bool IsValidAirportType(AirportType type);
59 /**
60 * Can you get information on this airport type? As opposed to
61 * IsValidAirportType this will return also return true when
62 * an airport type is no longer buildable.
63 * @param type The AirportType to check.
64 * @return True if and only if the AirportType is valid.
65 * @post return value == false -> IsValidAirportType returns false.
67 static bool IsAirportInformationAvailable(AirportType type);
69 /**
70 * Get the cost to build this AirportType.
71 * @param type The AirportType to check.
72 * @pre AirportAvailable(type).
73 * @return The cost of building this AirportType.
75 static Money GetPrice(AirportType type);
77 /**
78 * Checks whether the given tile is actually a tile with a hangar.
79 * @param tile The tile to check.
80 * @pre ScriptMap::IsValidTile(tile).
81 * @return True if and only if the tile has a hangar.
83 static bool IsHangarTile(TileIndex tile);
85 /**
86 * Checks whether the given tile is actually a tile with an airport.
87 * @param tile The tile to check.
88 * @pre ScriptMap::IsValidTile(tile).
89 * @return True if and only if the tile has an airport.
91 static bool IsAirportTile(TileIndex tile);
93 /**
94 * Get the width of this type of airport.
95 * @param type The type of airport.
96 * @pre IsAirportInformationAvailable(type).
97 * @return The width in tiles.
99 static SQInteger GetAirportWidth(AirportType type);
102 * Get the height of this type of airport.
103 * @param type The type of airport.
104 * @pre IsAirportInformationAvailable(type).
105 * @return The height in tiles.
107 static SQInteger GetAirportHeight(AirportType type);
110 * Get the coverage radius of this type of airport.
111 * @param type The type of airport.
112 * @pre IsAirportInformationAvailable(type).
113 * @return The radius in tiles.
115 static SQInteger GetAirportCoverageRadius(AirportType type);
118 * Get the number of hangars of the airport.
119 * @param tile Any tile of the airport.
120 * @pre ScriptMap::IsValidTile(tile).
121 * @return The number of hangars of the airport.
123 static SQInteger GetNumHangars(TileIndex tile);
126 * Get the first hangar tile of the airport.
127 * @param tile Any tile of the airport.
128 * @pre ScriptMap::IsValidTile(tile).
129 * @pre GetNumHangars(tile) > 0.
130 * @return The first hangar tile of the airport.
131 * @note Possible there are more hangars, but you won't be able to find them
132 * without walking over all the tiles of the airport and using
133 * IsHangarTile() on them.
135 static TileIndex GetHangarOfAirport(TileIndex tile);
138 * Builds a airport with tile at the topleft corner.
139 * @param tile The topleft corner of the airport.
140 * @param type The type of airport to build.
141 * @param station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT.
142 * @pre ScriptMap::IsValidTile(tile).
143 * @pre AirportAvailable(type).
144 * @pre station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id).
145 * @game @pre ScriptCompanyMode::IsValid().
146 * @exception ScriptError::ERR_AREA_NOT_CLEAR
147 * @exception ScriptError::ERR_FLAT_LAND_REQUIRED
148 * @exception ScriptError::ERR_LOCAL_AUTHORITY_REFUSES
149 * @exception ScriptStation::ERR_STATION_TOO_LARGE
150 * @exception ScriptStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
151 * @return Whether the airport has been/can be build or not.
153 static bool BuildAirport(TileIndex tile, AirportType type, StationID station_id);
156 * Removes an airport.
157 * @param tile Any tile of the airport.
158 * @pre ScriptMap::IsValidTile(tile).
159 * @game @pre ScriptCompanyMode::IsValid().
160 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
161 * @return Whether the airport has been/can be removed or not.
163 static bool RemoveAirport(TileIndex tile);
166 * Get the AirportType of an existing airport.
167 * @param tile Any tile of the airport.
168 * @pre ScriptTile::IsStationTile(tile).
169 * @pre ScriptStation::HasStationType(ScriptStation.GetStationID(tile), ScriptStation::STATION_AIRPORT).
170 * @return The AirportType of the airport.
172 static AirportType GetAirportType(TileIndex tile);
175 * Get the noise that will be added to the nearest town if an airport was
176 * built at this tile.
177 * @param tile The tile to check.
178 * @param type The AirportType to check.
179 * @pre IsAirportInformationAvailable(type).
180 * @return The amount of noise added to the nearest town.
181 * @note The noise will be added to the town with TownID GetNearestTown(tile, type).
183 static SQInteger GetNoiseLevelIncrease(TileIndex tile, AirportType type);
186 * Get the TownID of the town whose local authority will influence
187 * an airport at some tile.
188 * @param tile The tile to check.
189 * @param type The AirportType to check.
190 * @pre IsAirportInformationAvailable(type).
191 * @return The TownID of the town closest to the tile.
193 static TownID GetNearestTown(TileIndex tile, AirportType type);
196 * Get the maintenance cost factor of an airport type.
197 * @param type The airport type to get the maintenance factor of.
198 * @pre IsAirportInformationAvailable(type)
199 * @return Maintenance cost factor of the airport type.
201 static SQInteger GetMaintenanceCostFactor(AirportType type);
204 * Get the monthly maintenance cost of an airport type.
205 * @param type The airport type to get the monthly maintenance cost of.
206 * @pre IsAirportInformationAvailable(type)
207 * @return Maintenance cost of the airport type per economy-month.
208 * @see \ref ScriptEconomyTime
210 static Money GetMonthlyMaintenanceCost(AirportType type);
213 * Get the number of helipads of this airport type.
214 * @param type The airport type.
215 * @pre IsAirportInformationAvailable(type)
216 * @return Number of helipads of this type of airport. When 0 helicopters will go to normal terminals.
218 static SQInteger GetAirportNumHelipads(AirportType type);
221 #endif /* SCRIPT_AIRPORT_HPP */