OpenTTD Source  12.0-beta2
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:
41  {
42  }
43 
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;
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:
139 };
140 
143 
144 void BindAirportSpecs();
145 
146 StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback);
147 
148 #endif /* NEWGRF_AIRPORT_H */
AirportSpec::min_year
Year min_year
first year the airport is available
Definition: newgrf_airport.h:109
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
TileIterator::tile
TileIndex tile
The current tile we are at.
Definition: tilearea_type.h:107
AirportTileTableIterator::Clone
virtual AirportTileTableIterator * Clone() const
Allocate a new iterator that is a copy of this one.
Definition: newgrf_airport.h:61
StationGfx
byte StationGfx
Copy from station_map.h.
Definition: newgrf_airport.h:20
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:24
AirportSpec::IsWithinMapBounds
bool IsWithinMapBounds(byte table, TileIndex index) const
Check if the airport would be within the map bounds at the given tile.
Definition: newgrf_airport.cpp:138
AirportTileTableIterator::GetStationGfx
StationGfx GetStationGfx() const
Get the StationGfx for the current tile.
Definition: newgrf_airport.h:56
AirportTileTableIterator::base_tile
TileIndex base_tile
The tile we base the offsets off.
Definition: newgrf_airport.h:32
newgrf_commons.h
AirportSpec::size_y
byte size_y
size of airport in y direction
Definition: newgrf_airport.h:106
AirportSpec::name
StringID name
name of this airport
Definition: newgrf_airport.h:111
APC_HUB
@ APC_HUB
id for hub airports class
Definition: newgrf_airport.h:72
AirportSpec::max_year
Year max_year
last year the airport is available
Definition: newgrf_airport.h:110
AirportSpec::noise_level
byte noise_level
noise that this airport generates
Definition: newgrf_airport.h:107
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:18
AirportSpec::ResetAirports
static void ResetAirports()
This function initializes the airportspec array.
Definition: newgrf_airport.cpp:153
GetAirportTextCallback
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
Get a custom text for the airport.
Definition: newgrf_airport.cpp:295
AirportSpec
Defines the data structure for an airport.
Definition: newgrf_airport.h:98
AirportSpec::maintenance_cost
uint16 maintenance_cost
maintenance cost multiplier
Definition: newgrf_airport.h:115
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:14
ToTileIndexDiff
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
Definition: map_func.h:230
AirportSpec::rotation
const Direction * rotation
the rotation of each tiletable
Definition: newgrf_airport.h:101
AirportSpec::Get
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
Definition: newgrf_airport.cpp:97
AirportSpec::cls_id
AirportClassID cls_id
the class to which this airport type belongs
Definition: newgrf_airport.h:113
AirportClass
NewGRFClass< AirportSpec, AirportClassID, APC_MAX > AirportClass
Information related to airport classes.
Definition: newgrf_airport.h:142
AirportSpec::fsm
const struct AirportFTAClass * fsm
the finite statemachine for the default airports
Definition: newgrf_airport.h:99
AirportSpec::num_table
byte num_table
number of elements in the table
Definition: newgrf_airport.h:102
AirportTileTable::gfx
StationGfx gfx
AirportTile to use for this tile.
Definition: newgrf_airport.h:25
TileIterator
Base class for tile iterators.
Definition: tilearea_type.h:105
AirportSpec::GetIndex
byte GetIndex() const
Get the index of this spec.
Definition: newgrf_airport.h:129
GRFFileProps
Data related to the handling of grf files.
Definition: newgrf_commons.h:325
AirportTileTableIterator::att
const AirportTileTable * att
The offsets.
Definition: newgrf_airport.h:31
AirportTileTableIterator
Iterator to iterate over all tiles belonging to an airport spec.
Definition: newgrf_airport.h:29
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:19
AirportSpec::ttd_airport_type
TTDPAirportType ttd_airport_type
ttdpatch airport type (Small/Large/Helipad/Oilrig)
Definition: newgrf_airport.h:112
NUM_AIRPORTS
@ NUM_AIRPORTS
Maximal number of airports in total.
Definition: airport.h:41
TTDPAirportType
TTDPAirportType
Allow incrementing of AirportClassID variables.
Definition: newgrf_airport.h:81
BindAirportSpecs
void BindAirportSpecs()
Tie all airportspecs to their class.
Definition: newgrf_airport.cpp:165
AirportFTAClass
Finite sTate mAchine (FTA) of an airport.
Definition: airport.h:143
AirportSpec::dummy
static const AirportSpec dummy
The dummy airport.
Definition: newgrf_airport.h:135
AirportTileTable
Tile-offset / AirportTileID pair.
Definition: newgrf_airport.h:23
APC_HELIPORT
@ APC_HELIPORT
id for heliports
Definition: newgrf_airport.h:73
AirportSpec::specs
static AirportSpec specs[NUM_AIRPORTS]
Specs of the airports.
Definition: newgrf_airport.h:138
HangarTileTable::dir
Direction dir
Direction of the exit.
Definition: newgrf_airport.h:91
AirportSpec::IsAvailable
bool IsAvailable() const
Check whether this airport is available to build.
Definition: newgrf_airport.cpp:124
date_type.h
AirportSpec::size_x
byte size_x
size of airport in x direction
Definition: newgrf_airport.h:105
TileIndexDiffC
A pair-construct of a TileIndexDiff.
Definition: map_type.h:57
tilearea_type.h
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
HangarTileTable::ti
TileIndexDiffC ti
Tile offset from the top-most airport tile.
Definition: newgrf_airport.h:90
AirportSpec::enabled
bool enabled
Entity still available (by default true). Newgrf can disable it, though.
Definition: newgrf_airport.h:117
AirportSpec::preview_sprite
SpriteID preview_sprite
preview sprite for this airport
Definition: newgrf_airport.h:114
AirportClassID
AirportClassID
List of default airport classes.
Definition: newgrf_airport.h:68
ATP_TTDP_HELIPORT
@ ATP_TTDP_HELIPORT
Same as AT_HELIPORT.
Definition: newgrf_airport.h:84
APC_LARGE
@ APC_LARGE
id for large airports class
Definition: newgrf_airport.h:71
newgrf_class.h
endof
#define endof(x)
Get the end element of an fixed size array.
Definition: stdafx.h:386
AirportSpec::grf_prop
struct GRFFileProps grf_prop
Properties related to the grf file.
Definition: newgrf_airport.h:118
APC_MAX
@ APC_MAX
maximum number of airport classes
Definition: newgrf_airport.h:74
APC_SMALL
@ APC_SMALL
id for small airports class
Definition: newgrf_airport.h:70
AirportTileTableIterator::operator++
TileIterator & operator++()
Move ourselves to the next tile in the rectangle on the map.
Definition: newgrf_airport.h:44
AirportSpec::GetWithoutOverride
static AirportSpec * GetWithoutOverride(byte type)
Retrieve airport spec for the given airport.
Definition: newgrf_airport.cpp:117
AirportTileTableIterator::AirportTileTableIterator
AirportTileTableIterator(const AirportTileTable *att, TileIndex base_tile)
Construct the iterator.
Definition: newgrf_airport.h:40
AirportSpec::depot_table
const HangarTileTable * depot_table
gives the position of the depots on the airports
Definition: newgrf_airport.h:103
HangarTileTable::hangar_num
byte hangar_num
The hangar to which this tile belongs.
Definition: newgrf_airport.h:92
ATP_TTDP_SMALL
@ ATP_TTDP_SMALL
Same as AT_SMALL.
Definition: newgrf_airport.h:82
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:88
ATP_TTDP_LARGE
@ ATP_TTDP_LARGE
Same as AT_LARGE.
Definition: newgrf_airport.h:83
ATP_TTDP_OILRIG
@ ATP_TTDP_OILRIG
Same as AT_OILRIG.
Definition: newgrf_airport.h:85
airport.h
AirportSpec::nof_depots
byte nof_depots
the number of hangar tiles in this airport
Definition: newgrf_airport.h:104
AirportTileTable::ti
TileIndexDiffC ti
Tile offset from the top-most airport tile.
Definition: newgrf_airport.h:24
AirportSpec::table
const AirportTileTable *const * table
list of the tiles composing the airport
Definition: newgrf_airport.h:100
HangarTileTable
A list of all hangar tiles in an airport.
Definition: newgrf_airport.h:89
APC_BEGIN
@ APC_BEGIN
Lowest valid airport class id.
Definition: newgrf_airport.h:69
AirportSpec::catchment
byte catchment
catchment area of this airport
Definition: newgrf_airport.h:108
TileIndexDiffC::x
int16 x
The x value of the coordinate.
Definition: map_type.h:58