Files
@ r28572:dd3e6f760743
Branch filter:
Location: cpp/openttd-patchpack/source/src/script/api/script_airport.hpp
r28572:dd3e6f760743
7.8 KiB
text/x-c++hdr
Update: nlohmann/json to 3.11.3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | /*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/** @file script_airport.hpp Everything to query and build airports. */
#ifndef SCRIPT_AIRPORT_HPP
#define SCRIPT_AIRPORT_HPP
#include "script_object.hpp"
#include "../../airport.h"
/**
* Class that handles all airport related functions.
* @api ai game
*/
class ScriptAirport : public ScriptObject {
public:
/**
* The types of airports available in the game.
*/
enum AirportType {
/* Note: these values represent part of the in-game AirportTypes enum */
AT_SMALL = ::AT_SMALL, ///< The small airport.
AT_LARGE = ::AT_LARGE, ///< The large airport.
AT_METROPOLITAN = ::AT_METROPOLITAN, ///< The metropolitan airport.
AT_INTERNATIONAL = ::AT_INTERNATIONAL, ///< The international airport.
AT_COMMUTER = ::AT_COMMUTER, ///< The commuter airport.
AT_INTERCON = ::AT_INTERCON, ///< The intercontinental airport.
AT_HELIPORT = ::AT_HELIPORT, ///< The heliport.
AT_HELISTATION = ::AT_HELISTATION, ///< The helistation.
AT_HELIDEPOT = ::AT_HELIDEPOT, ///< The helidepot.
AT_INVALID = ::AT_INVALID, ///< Invalid airport.
};
/**
* All plane types available.
*/
enum PlaneType {
/* Note: these values represent part of the in-game values, which are not defined in an enum */
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 and available.
* @param type The AirportType to check.
* @return True if and only if the AirportType is valid and available.
* @post return value == true -> IsAirportInformationAvailable returns true.
*/
static bool IsValidAirportType(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.
* @param type The AirportType to check.
* @return True if and only if the AirportType is valid.
* @post return value == false -> IsValidAirportType returns false.
*/
static bool IsAirportInformationAvailable(AirportType type);
/**
* Get the cost to build this AirportType.
* @param type The AirportType to check.
* @pre AirportAvailable(type).
* @return The cost of building this AirportType.
*/
static Money GetPrice(AirportType type);
/**
* Checks whether the given tile is actually a tile with a hangar.
* @param tile The tile to check.
* @pre ScriptMap::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 an airport.
* @param tile The tile to check.
* @pre ScriptMap::IsValidTile(tile).
* @return True if and only if the tile has an airport.
*/
static bool IsAirportTile(TileIndex tile);
/**
* Get the width of this type of airport.
* @param type The type of airport.
* @pre IsAirportInformationAvailable(type).
* @return The width in tiles.
*/
static SQInteger GetAirportWidth(AirportType type);
/**
* Get the height of this type of airport.
* @param type The type of airport.
* @pre IsAirportInformationAvailable(type).
* @return The height in tiles.
*/
static SQInteger GetAirportHeight(AirportType type);
/**
* Get the coverage radius of this type of airport.
* @param type The type of airport.
* @pre IsAirportInformationAvailable(type).
* @return The radius in tiles.
*/
static SQInteger GetAirportCoverageRadius(AirportType type);
/**
* Get the number of hangars of the airport.
* @param tile Any tile of the airport.
* @pre ScriptMap::IsValidTile(tile).
* @return The number of hangars of the airport.
*/
static SQInteger GetNumHangars(TileIndex tile);
/**
* Get the first hangar tile of the airport.
* @param tile Any tile of the airport.
* @pre ScriptMap::IsValidTile(tile).
* @pre GetNumHangars(tile) > 0.
* @return 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.
*/
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 station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT.
* @pre ScriptMap::IsValidTile(tile).
* @pre AirportAvailable(type).
* @pre station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id).
* @game @pre ScriptCompanyMode::IsValid().
* @exception ScriptError::ERR_AREA_NOT_CLEAR
* @exception ScriptError::ERR_FLAT_LAND_REQUIRED
* @exception ScriptError::ERR_LOCAL_AUTHORITY_REFUSES
* @exception ScriptStation::ERR_STATION_TOO_LARGE
* @exception ScriptStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
* @return Whether the airport has been/can be build or not.
*/
static bool BuildAirport(TileIndex tile, AirportType type, StationID station_id);
/**
* Removes an airport.
* @param tile Any tile of the airport.
* @pre ScriptMap::IsValidTile(tile).
* @game @pre ScriptCompanyMode::IsValid().
* @exception ScriptError::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 ScriptTile::IsStationTile(tile).
* @pre ScriptStation::HasStationType(ScriptStation.GetStationID(tile), ScriptStation::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.
* @pre IsAirportInformationAvailable(type).
* @return The amount of noise added to the nearest town.
* @note The noise will be added to the town with TownID GetNearestTown(tile, type).
*/
static SQInteger GetNoiseLevelIncrease(TileIndex tile, AirportType type);
/**
* Get the TownID of the town whose local authority will influence
* an airport at some tile.
* @param tile The tile to check.
* @param type The AirportType to check.
* @pre IsAirportInformationAvailable(type).
* @return The TownID of the town closest to the tile.
*/
static TownID GetNearestTown(TileIndex tile, AirportType type);
/**
* Get the maintenance cost factor of an airport type.
* @param type The airport type to get the maintenance factor of.
* @pre IsAirportInformationAvailable(type)
* @return Maintenance cost factor of the airport type.
*/
static SQInteger GetMaintenanceCostFactor(AirportType type);
/**
* Get the monthly maintenance cost of an airport type.
* @param type The airport type to get the monthly maintenance cost of.
* @pre IsAirportInformationAvailable(type)
* @return Monthly maintenance cost of the airport type.
*/
static Money GetMonthlyMaintenanceCost(AirportType type);
};
#endif /* SCRIPT_AIRPORT_HPP */
|