OpenTTD
newgrf_airport.h
Go to the documentation of this file.
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  */
7 
10 #ifndef NEWGRF_AIRPORT_H
11 #define NEWGRF_AIRPORT_H
12 
13 #include "airport.h"
14 #include "date_type.h"
15 #include "newgrf_class.h"
16 #include "newgrf_commons.h"
17 #include "tilearea_type.h"
18 
20 typedef byte StationGfx;
21 
26 };
27 
30 private:
33 
34 public:
40  AirportTileTableIterator(const AirportTileTable *att, TileIndex base_tile) : TileIterator(base_tile + ToTileIndexDiff(att->ti)), att(att), base_tile(base_tile)
41  {
42  }
43 
44  inline TileIterator& operator ++()
45  {
46  this->att++;
47  if (this->att->ti.x == -0x80) {
48  this->tile = INVALID_TILE;
49  } else {
50  this->tile = this->base_tile + ToTileIndexDiff(this->att->ti);
51  }
52  return *this;
53  }
54 
57  {
58  return this->att->gfx;
59  }
60 
62  {
63  return new AirportTileTableIterator(*this);
64  }
65 };
66 
69  APC_BEGIN = 0,
70  APC_SMALL = 0,
74  APC_MAX = 16,
75 };
76 
79 
80 
86 };
87 
92  byte hangar_num;
93 };
94 
98 struct AirportSpec {
99  const struct AirportFTAClass *fsm;
100  const AirportTileTable * const *table;
102  byte num_table;
104  byte nof_depots;
105  byte size_x;
106  byte size_y;
107  byte noise_level;
108  byte catchment;
116  /* Newgrf data */
117  bool enabled;
118  struct GRFFileProps grf_prop;
119 
120  static const AirportSpec *Get(byte type);
121  static AirportSpec *GetWithoutOverride(byte type);
122 
123  bool IsAvailable() const;
124  bool IsWithinMapBounds(byte table, TileIndex index) const;
125 
126  static void ResetAirports();
127 
129  byte GetIndex() const
130  {
131  assert(this >= specs && this < endof(specs));
132  return (byte)(this - specs);
133  }
134 
135  static const AirportSpec dummy;
136 
137 private:
138  static AirportSpec specs[NUM_AIRPORTS];
139 };
140 
143 
144 void BindAirportSpecs();
145 
146 StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback);
147 
148 #endif /* NEWGRF_AIRPORT_H */
id for small airports class
TTDPAirportType ttd_airport_type
ttdpatch airport type (Small/Large/Helipad/Oilrig)
Finite sTate mAchine (FTA) of an airport.
Definition: airport.h:143
AirportClassID
List of default airport classes.
TileIndexDiffC ti
Tile offset from the top-most airport tile.
byte size_y
size of airport in y direction
byte hangar_num
The hangar to which this tile belongs.
void BindAirportSpecs()
Tie all airportspecs to their class.
const HangarTileTable * depot_table
gives the position of the depots on the airports
byte GetIndex() const
Get the index of this spec.
Iterator to iterate over all tiles belonging to an airport spec.
static const AirportSpec dummy
The dummy airport.
A list of all hangar tiles in an airport.
Lowest valid airport class id.
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:18
const struct AirportFTAClass * fsm
the finite statemachine for the default airports
Year min_year
first year the airport is available
byte nof_depots
the number of hangar tiles in this airport
uint16 maintenance_cost
maintenance cost multiplier
const AirportTileTable *const * table
list of the tiles composing the airport
Various declarations for airports.
byte catchment
catchment area of this airport
Maximal number of airports in total.
Definition: airport.h:41
byte noise_level
noise that this airport generates
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:19
AirportClassID cls_id
the class to which this airport type belongs
NewGRFClass< AirportSpec, AirportClassID, APC_MAX > AirportClass
Information related to airport classes.
const Direction * rotation
the rotation of each tiletable
Data related to the handling of grf files.
maximum number of airport classes
const AirportTileTable * att
The offsets.
int16 x
The x value of the coordinate.
Definition: map_type.h:58
Direction
Defines the 8 directions on the map.
Same as AT_OILRIG.
byte num_table
number of elements in the table
Base class for tile iterators.
Definition: tilearea_type.h:99
StationGfx gfx
AirportTile to use for this tile.
virtual AirportTileTableIterator * Clone() const
Allocate a new iterator that is a copy of this one.
id for heliports
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
TileIndex base_tile
The tile we base the offsets off.
TileIndexDiffC ti
Tile offset from the top-most airport tile.
StationGfx GetStationGfx() const
Get the StationGfx for the current tile.
A pair-construct of a TileIndexDiff.
Definition: map_type.h:57
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
Definition: map_func.h:230
byte StationGfx
Copy from station_map.h.
Header file for classes to be used by e.g.
Same as AT_HELIPORT.
Direction dir
Direction of the exit.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
StringID name
name of this airport
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
Get a custom text for the airport.
AirportTileTableIterator(const AirportTileTable *att, TileIndex base_tile)
Construct the iterator.
byte size_x
size of airport in x direction
Tile-offset / AirportTileID pair.
#define endof(x)
Get the end element of an fixed size array.
Definition: stdafx.h:384
id for hub airports class
Same as AT_LARGE.
Type for storing the &#39;area&#39; of something uses on the map.
Types related to the dates in OpenTTD.
This file simplyfies and embeds a common mechanism of loading/saving and mapping of grf entities...
bool enabled
Entity still available (by default true). Newgrf can disable it, though.
Same as AT_SMALL.
SpriteID preview_sprite
preview sprite for this airport
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:83
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:14
Defines the data structure for an airport.
TTDPAirportType
Allow incrementing of AirportClassID variables.
Year max_year
last year the airport is available
id for large airports class