OpenTTD: src/newgrf_airport.h Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

newgrf_airport.h
Go to the documentation of this file.
1 /* $Id: newgrf_airport.h 25705 2013-08-09 18:43:44Z rubidium $ */
2
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 */
9
12 #ifndef NEWGRF_AIRPORT_H
13 #define NEWGRF_AIRPORT_H
14
15 #include "airport.h"
16 #include "date_type.h"
17 #include "newgrf_class.h"
18 #include "newgrf_commons.h"
19 #include "tilearea_type.h"
20
22 typedef byte StationGfx;
23
25 struct AirportTileTable {
26 TileIndexDiffC ti;
27 StationGfx gfx;
28 };
29
31 class AirportTileTableIterator : public TileIterator {
32 private:
33 const AirportTileTable *att;
34 TileIndex base_tile;
35
36 public:
42 AirportTileTableIterator(const AirportTileTable *att, TileIndex base_tile) : TileIterator(base_tile + ToTileIndexDiff(att->ti)), att(att), base_tile(base_tile)
43 {
44 }
45
46 inline TileIterator& operator ++()
47 {
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);
53 }
54 return *this;
55 }
56
58 StationGfx GetStationGfx() const
59 {
60 return this->att->gfx;
61 }
62
63 virtual AirportTileTableIterator *Clone() const
64 {
65 return new AirportTileTableIterator(*this);
66 }
67 };
68
70 enum AirportClassID {
71 APC_BEGIN = 0,
72 APC_SMALL = 0,
73 APC_LARGE,
74 APC_HUB,
75 APC_HELIPORT,
76 APC_MAX = 16,
77 };
78
80 DECLARE_POSTFIX_INCREMENT(AirportClassID)
81
82
83 enum TTDPAirportType {
84 ATP_TTDP_SMALL,
85 ATP_TTDP_LARGE,
86 ATP_TTDP_HELIPORT,
87 ATP_TTDP_OILRIG,
88 };
89
91 struct HangarTileTable {
92 TileIndexDiffC ti;
93 Direction dir;
94 byte hangar_num;
95 };
96
100 struct AirportSpec {
101 const struct AirportFTAClass *fsm;
102 const AirportTileTable * const *table;
103 Direction *rotation;
104 byte num_table;
105 const HangarTileTable *depot_table;
106 byte nof_depots;
107 byte size_x;
108 byte size_y;
109 byte noise_level;
110 byte catchment;
111 Year min_year;
112 Year max_year;
113 StringID name;
114 TTDPAirportType ttd_airport_type;
115 AirportClassID cls_id;
116 SpriteID preview_sprite;
117 uint16 maintenance_cost;
118 /* Newgrf data */
119 bool enabled;
120 struct GRFFileProps grf_prop;
121
122 static const AirportSpec *Get(byte type);
123 static AirportSpec *GetWithoutOverride(byte type);
124
125 bool IsAvailable() const;
126
127 static void ResetAirports();
128
130 byte GetIndex() const
131 {
132 assert(this >= specs && this < endof(specs));
133 return (byte)(this - specs);
134 }
135
136 static AirportSpec dummy;
137
138 private:
139 static AirportSpec specs[NUM_AIRPORTS];
140 };
141
143 typedef NewGRFClass<AirportSpec, AirportClassID, APC_MAX> AirportClass;
144
145 void BindAirportSpecs();
146
147 StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback);
148
149 #endif /* NEWGRF_AIRPORT_H */