OpenTTD
newgrf_airport.h
Go to the documentation of this file.
1 /* $Id: newgrf_airport.h 27908 2017-08-31 06:55:38Z adf88 $ */
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 
28 };
29 
32 private:
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 
59  {
60  return this->att->gfx;
61  }
62 
64  {
65  return new AirportTileTableIterator(*this);
66  }
67 };
68 
71  APC_BEGIN = 0,
72  APC_SMALL = 0,
76  APC_MAX = 16,
77 };
78 
81 
82 
88 };
89 
94  byte hangar_num;
95 };
96 
100 struct AirportSpec {
101  const struct AirportFTAClass *fsm;
102  const AirportTileTable * const *table;
104  byte num_table;
106  byte nof_depots;
107  byte size_x;
108  byte size_y;
109  byte noise_level;
110  byte catchment;
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 const AirportSpec dummy;
137 
138 private:
139  static AirportSpec specs[NUM_AIRPORTS];
140 };
141 
144 
145 void BindAirportSpecs();
146 
147 StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback);
148 
149 #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:144
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:20
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
Direction
Defines the 8 directions on the map.
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:43
byte noise_level
noise that this airport generates
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:21
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:59
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:18
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:58
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
Definition: map_func.h:232
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:19
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
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:427
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:85
Defines the data structure for an airport.
#define DECLARE_POSTFIX_INCREMENT(type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:16
TTDPAirportType
Allow incrementing of AirportClassID variables.
Year max_year
last year the airport is available
id for large airports class