Add support for deleted functions
[openttd/fttd.git] / src / airport.h
blobd17c4afdf1234083dad1d46c462c121994c93179
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file airport.h Various declarations for airports */
12 #ifndef AIRPORT_H
13 #define AIRPORT_H
15 #include "map/coord.h"
16 #include "direction_type.h"
18 /** Some airport-related constants */
19 static const uint MAX_TERMINALS = 8; ///< maximum number of terminals per airport
20 static const uint MAX_HELIPADS = 3; ///< maximum number of helipads per airport
21 static const uint MAX_ELEMENTS = 255; ///< maximum number of aircraft positions at airport
23 static const uint NUM_AIRPORTTILES_PER_GRF = 255; ///< Number of airport tiles per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on.
25 static const uint NUM_AIRPORTTILES = 256; ///< Total number of airport tiles.
26 static const uint NEW_AIRPORTTILE_OFFSET = 74; ///< offset of first newgrf airport tile
27 static const uint INVALID_AIRPORTTILE = NUM_AIRPORTTILES; ///< id for an invalid airport tile
29 /** Airport types */
30 enum AirportTypes {
31 AT_SMALL = 0, ///< Small airport.
32 AT_LARGE = 1, ///< Large airport.
33 AT_HELIPORT = 2, ///< Heli port.
34 AT_METROPOLITAN = 3, ///< Metropolitan airport.
35 AT_INTERNATIONAL = 4, ///< International airport.
36 AT_COMMUTER = 5, ///< Commuter airport.
37 AT_HELIDEPOT = 6, ///< Heli depot.
38 AT_INTERCON = 7, ///< Intercontinental airport.
39 AT_HELISTATION = 8, ///< Heli station airport.
40 AT_OILRIG = 9, ///< Oilrig airport.
41 NEW_AIRPORT_OFFSET = 10, ///< Number of the first newgrf airport.
42 NUM_AIRPORTS_PER_GRF = 128, ///< Maximal number of airports per NewGRF.
43 NUM_AIRPORTS = 128, ///< Maximal number of airports in total.
44 AT_INVALID = 254, ///< Invalid airport.
45 AT_DUMMY = 255, ///< Dummy airport.
48 /** Flags for airport movement data. */
49 enum AirportMovingDataFlags {
50 AMED_NOSPDCLAMP = 1 << 0, ///< No speed restrictions.
51 AMED_TAKEOFF = 1 << 1, ///< Takeoff movement.
52 AMED_SLOWTURN = 1 << 2, ///< Turn slowly (mostly used in the air).
53 AMED_LAND = 1 << 3, ///< Landing onto landing strip.
54 AMED_EXACTPOS = 1 << 4, ///< Go exactly to the destination coordinates.
55 AMED_BRAKE = 1 << 5, ///< Taxiing at the airport.
56 AMED_HELI_RAISE = 1 << 6, ///< Helicopter take-off.
57 AMED_HELI_LOWER = 1 << 7, ///< Helicopter landing.
58 AMED_HOLD = 1 << 8, ///< Holding pattern movement (above the airport).
61 /** Movement States on Airports (headings target) */
62 enum AirportMovementStates {
63 TO_ALL = 0, ///< Go in this direction for every target.
64 HANGAR = 1, ///< Heading for hangar.
65 TERM1 = 2, ///< Heading for terminal 1.
66 TERM2 = 3, ///< Heading for terminal 2.
67 TERM3 = 4, ///< Heading for terminal 3.
68 TERM4 = 5, ///< Heading for terminal 4.
69 TERM5 = 6, ///< Heading for terminal 5.
70 TERM6 = 7, ///< Heading for terminal 6.
71 HELIPAD1 = 8, ///< Heading for helipad 1.
72 HELIPAD2 = 9, ///< Heading for helipad 2.
73 TAKEOFF = 10, ///< Airplane wants to leave the airport.
74 STARTTAKEOFF = 11, ///< Airplane has arrived at a runway for take-off.
75 ENDTAKEOFF = 12, ///< Airplane has reached end-point of the take-off runway.
76 HELITAKEOFF = 13, ///< Helicopter wants to leave the airport.
77 FLYING = 14, ///< %Vehicle is flying in the air.
78 LANDING = 15, ///< Airplane wants to land.
79 ENDLANDING = 16, ///< Airplane wants to finish landing.
80 HELILANDING = 17, ///< Helicopter wants to land.
81 HELIENDLANDING = 18, ///< Helicopter wants to finish landing.
82 TERM7 = 19, ///< Heading for terminal 7.
83 TERM8 = 20, ///< Heading for terminal 8.
84 HELIPAD3 = 21, ///< Heading for helipad 3.
85 MAX_HEADINGS = 21, ///< Last valid target to head for.
88 /** Movement Blocks on Airports blocks (eg_airport_flags). */
89 static const uint64
90 TERM1_block = 1ULL << 0, ///< Block belonging to terminal 1.
91 TERM2_block = 1ULL << 1, ///< Block belonging to terminal 2.
92 TERM3_block = 1ULL << 2, ///< Block belonging to terminal 3.
93 TERM4_block = 1ULL << 3, ///< Block belonging to terminal 4.
94 TERM5_block = 1ULL << 4, ///< Block belonging to terminal 5.
95 TERM6_block = 1ULL << 5, ///< Block belonging to terminal 6.
96 HELIPAD1_block = 1ULL << 6, ///< Block belonging to helipad 1.
97 HELIPAD2_block = 1ULL << 7, ///< Block belonging to helipad 2.
98 RUNWAY_IN_OUT_block = 1ULL << 8,
99 RUNWAY_IN_block = 1ULL << 8,
100 AIRPORT_BUSY_block = 1ULL << 8,
101 RUNWAY_OUT_block = 1ULL << 9,
102 TAXIWAY_BUSY_block = 1ULL << 10,
103 OUT_WAY_block = 1ULL << 11,
104 IN_WAY_block = 1ULL << 12,
105 AIRPORT_ENTRANCE_block = 1ULL << 13,
106 TERM_GROUP1_block = 1ULL << 14,
107 TERM_GROUP2_block = 1ULL << 15,
108 HANGAR2_AREA_block = 1ULL << 16,
109 TERM_GROUP2_ENTER1_block = 1ULL << 17,
110 TERM_GROUP2_ENTER2_block = 1ULL << 18,
111 TERM_GROUP2_EXIT1_block = 1ULL << 19,
112 TERM_GROUP2_EXIT2_block = 1ULL << 20,
113 PRE_HELIPAD_block = 1ULL << 21,
115 /* blocks for new airports */
116 TERM7_block = 1ULL << 22, ///< Block belonging to terminal 7.
117 TERM8_block = 1ULL << 23, ///< Block belonging to terminal 8.
118 HELIPAD3_block = 1ULL << 24, ///< Block belonging to helipad 3.
119 HANGAR1_AREA_block = 1ULL << 26,
120 OUT_WAY2_block = 1ULL << 27,
121 IN_WAY2_block = 1ULL << 28,
122 RUNWAY_IN2_block = 1ULL << 29,
123 RUNWAY_OUT2_block = 1ULL << 10, ///< @note re-uses #TAXIWAY_BUSY_block
124 HELIPAD_GROUP_block = 1ULL << 13, ///< @note re-uses #AIRPORT_ENTRANCE_block
125 OUT_WAY_block2 = 1ULL << 31,
126 /* end of new blocks */
128 NOTHING_block = 1ULL << 30,
129 AIRPORT_CLOSED_block = 1ULL << 63; ///< Dummy block for indicating a closed airport.
131 /** A single location on an airport where aircraft can move to. */
132 struct AirportMovingData {
133 int16 x; ///< x-coordinate of the destination.
134 int16 y; ///< y-coordinate of the destination.
135 uint16 flag; ///< special flags when moving towards the destination.
136 DirectionByte direction; ///< Direction to turn the aircraft after reaching the destination.
139 AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Direction rotation, uint num_tiles_x, uint num_tiles_y);
141 struct AirportFTAbuildup;
143 /** Finite sTate mAchine (FTA) of an airport. */
144 struct AirportFTAClass {
145 public:
146 /** Bitmask of airport flags. */
147 enum Flags {
148 AIRPLANES = 0x1, ///< Can planes land on this airport type?
149 HELICOPTERS = 0x2, ///< Can helicopters land on this airport type?
150 ALL = AIRPLANES | HELICOPTERS, ///< Mask to check for both planes and helicopters.
151 SHORT_STRIP = 0x4, ///< This airport has a short landing strip, dangerous for fast aircraft.
154 AirportFTAClass(
155 const AirportMovingData *moving_data,
156 const byte *terminals,
157 const byte num_helipads,
158 const byte *entry_points,
159 Flags flags,
160 const AirportFTAbuildup *apFA,
161 byte delta_z
164 ~AirportFTAClass();
167 * Get movement data at a position.
168 * @param position Element number to get movement data about.
169 * @return Pointer to the movement data.
171 const AirportMovingData *MovingData(byte position) const
173 assert(position < nofelements);
174 return &moving_data[position];
177 const AirportMovingData *moving_data; ///< Movement data.
178 struct AirportFTA *layout; ///< state machine for airport
179 const byte *terminals; ///< %Array with the number of terminal groups, followed by the number of terminals in each group.
180 const byte num_helipads; ///< Number of helipads on this airport. When 0 helicopters will go to normal terminals.
181 Flags flags; ///< Flags for this airport type.
182 byte nofelements; ///< number of positions the airport consists of
183 const byte *entry_points; ///< when an airplane arrives at this airport, enter it at position entry_point, index depends on direction
184 byte delta_z; ///< Z adjustment for helicopter pads
187 DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
190 /** Internal structure used in openttd - Finite sTate mAchine --> FTA */
191 struct AirportFTA {
192 AirportFTA *next; ///< possible extra movement choices from this position
193 uint64 block; ///< 64 bit blocks (st->airport.flags), should be enough for the most complex airports
194 byte position; ///< the position that an airplane is at
195 byte next_position; ///< next position from this position
196 byte heading; ///< heading (current orders), guiding an airplane to its target on an airport
199 const AirportFTAClass *GetAirport(const byte airport_type);
200 byte GetVehiclePosOnBuild(TileIndex hangar_tile);
202 #endif /* AIRPORT_H */