(svn r27953) -Cleanup: Adjust other languages for r27952
[openttd.git] / src / newgrf_airport.h
blob867362e9ad755317ab90337dd9cd166a62308346
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 newgrf_airport.h NewGRF handling of airports. */
12 #ifndef NEWGRF_AIRPORT_H
13 #define NEWGRF_AIRPORT_H
15 #include "airport.h"
16 #include "date_type.h"
17 #include "newgrf_class.h"
18 #include "newgrf_commons.h"
19 #include "tilearea_type.h"
21 /** Copy from station_map.h */
22 typedef byte StationGfx;
24 /** Tile-offset / AirportTileID pair. */
25 struct AirportTileTable {
26 TileIndexDiffC ti; ///< Tile offset from the top-most airport tile.
27 StationGfx gfx; ///< AirportTile to use for this tile.
30 /** Iterator to iterate over all tiles belonging to an airport spec. */
31 class AirportTileTableIterator : public TileIterator {
32 private:
33 const AirportTileTable *att; ///< The offsets.
34 TileIndex base_tile; ///< The tile we base the offsets off.
36 public:
37 /**
38 * Construct the iterator.
39 * @param att The TileTable we want to iterate over.
40 * @param base_tile The basetile for all offsets.
42 AirportTileTableIterator(const AirportTileTable *att, TileIndex base_tile) : TileIterator(base_tile + ToTileIndexDiff(att->ti)), att(att), base_tile(base_tile)
46 inline TileIterator& operator ++()
48 this->att++;
49 if (this->att->ti.x == -0x80) {
50 this->tile = INVALID_TILE;
51 } else {
52 this->tile = this->base_tile + ToTileIndexDiff(this->att->ti);
54 return *this;
57 /** Get the StationGfx for the current tile. */
58 StationGfx GetStationGfx() const
60 return this->att->gfx;
63 virtual AirportTileTableIterator *Clone() const
65 return new AirportTileTableIterator(*this);
69 /** List of default airport classes. */
70 enum AirportClassID {
71 APC_BEGIN = 0, ///< Lowest valid airport class id
72 APC_SMALL = 0, ///< id for small airports class
73 APC_LARGE, ///< id for large airports class
74 APC_HUB, ///< id for hub airports class
75 APC_HELIPORT, ///< id for heliports
76 APC_MAX = 16, ///< maximum number of airport classes
79 /** Allow incrementing of AirportClassID variables */
80 DECLARE_POSTFIX_INCREMENT(AirportClassID)
82 /** TTDP airport types. Used to map our types to TTDPatch's */
83 enum TTDPAirportType {
84 ATP_TTDP_SMALL, ///< Same as AT_SMALL
85 ATP_TTDP_LARGE, ///< Same as AT_LARGE
86 ATP_TTDP_HELIPORT, ///< Same as AT_HELIPORT
87 ATP_TTDP_OILRIG, ///< Same as AT_OILRIG
90 /** A list of all hangar tiles in an airport */
91 struct HangarTileTable {
92 TileIndexDiffC ti; ///< Tile offset from the top-most airport tile.
93 Direction dir; ///< Direction of the exit.
94 byte hangar_num; ///< The hangar to which this tile belongs.
97 /**
98 * Defines the data structure for an airport.
100 struct AirportSpec {
101 const struct AirportFTAClass *fsm; ///< the finite statemachine for the default airports
102 const AirportTileTable * const *table; ///< list of the tiles composing the airport
103 const Direction *rotation; ///< the rotation of each tiletable
104 byte num_table; ///< number of elements in the table
105 const HangarTileTable *depot_table; ///< gives the position of the depots on the airports
106 byte nof_depots; ///< the number of hangar tiles in this airport
107 byte size_x; ///< size of airport in x direction
108 byte size_y; ///< size of airport in y direction
109 byte noise_level; ///< noise that this airport generates
110 byte catchment; ///< catchment area of this airport
111 Year min_year; ///< first year the airport is available
112 Year max_year; ///< last year the airport is available
113 StringID name; ///< name of this airport
114 TTDPAirportType ttd_airport_type; ///< ttdpatch airport type (Small/Large/Helipad/Oilrig)
115 AirportClassID cls_id; ///< the class to which this airport type belongs
116 SpriteID preview_sprite; ///< preview sprite for this airport
117 uint16 maintenance_cost; ///< maintenance cost multiplier
118 /* Newgrf data */
119 bool enabled; ///< Entity still available (by default true). Newgrf can disable it, though.
120 struct GRFFileProps grf_prop; ///< Properties related to the grf file.
122 static const AirportSpec *Get(byte type);
123 static AirportSpec *GetWithoutOverride(byte type);
125 bool IsAvailable() const;
127 static void ResetAirports();
129 /** Get the index of this spec. */
130 byte GetIndex() const
132 assert(this >= specs && this < endof(specs));
133 return (byte)(this - specs);
136 static const AirportSpec dummy; ///< The dummy airport.
138 private:
139 static AirportSpec specs[NUM_AIRPORTS]; ///< Specs of the airports.
142 /** Information related to airport classes. */
143 typedef NewGRFClass<AirportSpec, AirportClassID, APC_MAX> AirportClass;
145 void BindAirportSpecs();
147 StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback);
149 #endif /* NEWGRF_AIRPORT_H */