src/airport.h
author richk
Tue, 24 Jul 2007 22:16:32 +0000
branchNewGRF_ports
changeset 6738 72d1a2997952
parent 6737 2b971fcc9a08
child 6739 3f2ca4d0abda
permissions -rw-r--r--
(svn r10683) [NewGRF_ports] -Revert: Too eager to un-const... global search/replace removed too many. Restores necessary ones... for the moment ;)
Thanks to Rubidium for corrections.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     2
6443
b8f06d8eb7be (svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents: 6367
diff changeset
     3
/** @file airport.h Various declarations for airports */
b8f06d8eb7be (svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents: 6367
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#ifndef AIRPORT_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#define AIRPORT_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
     8
#include "direction.h"
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
     9
6715
ce1614834bc3 (svn r9507) [NewGRF_ports] -Codechange: Moved airport state definitions into their own separate file to permit better logical grouping of state machine related data & code.
richk
parents: 6574
diff changeset
    10
enum {MAX_TERMINALS =  12};
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
    11
enum {MAX_HELIPADS  =   4};
3701
13911c5df3e7 (svn r4642) - Codechange: reorganise airport.h and airport_movement.h to avoid having 8 copies of the airport FTAs, and make the enums used available elsewhere.
peter1138
parents: 3697
diff changeset
    12
enum {MAX_ELEMENTS  = 255};
6715
ce1614834bc3 (svn r9507) [NewGRF_ports] -Codechange: Moved airport state definitions into their own separate file to permit better logical grouping of state machine related data & code.
richk
parents: 6574
diff changeset
    13
enum {MAX_HEADINGS  =  30};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
// Airport types
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
enum {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
    17
	AT_SMALL         =  0,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
    18
	AT_LARGE         =  1,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
    19
	AT_HELIPORT      =  2,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
    20
	AT_METROPOLITAN  =  3,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
    21
	AT_INTERNATIONAL =  4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
    22
	AT_COMMUTER      =  5,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
    23
	AT_HELIDEPOT     =  6,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
    24
	AT_INTERCON      =  7,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
    25
	AT_HELISTATION   =  8,
6715
ce1614834bc3 (svn r9507) [NewGRF_ports] -Codechange: Moved airport state definitions into their own separate file to permit better logical grouping of state machine related data & code.
richk
parents: 6574
diff changeset
    26
	AT_LGA           =  9,
ce1614834bc3 (svn r9507) [NewGRF_ports] -Codechange: Moved airport state definitions into their own separate file to permit better logical grouping of state machine related data & code.
richk
parents: 6574
diff changeset
    27
	AT_MUC           = 10,
ce1614834bc3 (svn r9507) [NewGRF_ports] -Codechange: Moved airport state definitions into their own separate file to permit better logical grouping of state machine related data & code.
richk
parents: 6574
diff changeset
    28
	AT_SFO           = 11,
ce1614834bc3 (svn r9507) [NewGRF_ports] -Codechange: Moved airport state definitions into their own separate file to permit better logical grouping of state machine related data & code.
richk
parents: 6574
diff changeset
    29
	AT_AMS           = 12,
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6715
diff changeset
    30
	AT_OILRIG        = 15,
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6715
diff changeset
    31
	AT_DUMMY         = 255
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    34
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    35
struct AirportMovingData {
6189
2b1ae5e373e9 (svn r8582) -Fix
tron
parents: 6183
diff changeset
    36
	int16 x;
2b1ae5e373e9 (svn r8582) -Fix
tron
parents: 6183
diff changeset
    37
	int16 y;
6519
367d6f96e23f (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar
parents: 6443
diff changeset
    38
	uint16 flag;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    39
	DirectionByte direction;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    40
};
3701
13911c5df3e7 (svn r4642) - Codechange: reorganise airport.h and airport_movement.h to avoid having 8 copies of the airport FTAs, and make the enums used available elsewhere.
peter1138
parents: 3697
diff changeset
    41
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    42
struct AirportFTAbuildup;
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    43
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
// Finite sTate mAchine --> FTA
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    45
struct AirportFTAClass {
6175
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    46
	public:
6350
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    47
		enum Flags {
6353
75b086ef8ef1 (svn r8750) -Fix (r8747): PLANES defined in wingdi.h caused compilation error under Win32. Changed to AIRPLANES
KUDr
parents: 6351
diff changeset
    48
			AIRPLANES   = 0x1,
6350
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    49
			HELICOPTERS = 0x2,
6353
75b086ef8ef1 (svn r8750) -Fix (r8747): PLANES defined in wingdi.h caused compilation error under Win32. Changed to AIRPLANES
KUDr
parents: 6351
diff changeset
    50
			ALL         = AIRPLANES | HELICOPTERS,
6351
afb1e3960181 (svn r8748) -Fix
tron
parents: 6350
diff changeset
    51
			SHORT_STRIP = 0x4
6350
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    52
		};
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    53
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    54
		AirportFTAClass(
6737
2b971fcc9a08 (svn r10682) [NewGRF_ports] -Feature: Added code to import FSM from within the newgrf, and allocate to compatible structures within Airport. Eventually, it will load to its own dedicated structures.
richk
parents: 6734
diff changeset
    55
			AirportMovingData *moving_data,
2b971fcc9a08 (svn r10682) [NewGRF_ports] -Feature: Added code to import FSM from within the newgrf, and allocate to compatible structures within Airport. Eventually, it will load to its own dedicated structures.
richk
parents: 6734
diff changeset
    56
			byte *terminals,
2b971fcc9a08 (svn r10682) [NewGRF_ports] -Feature: Added code to import FSM from within the newgrf, and allocate to compatible structures within Airport. Eventually, it will load to its own dedicated structures.
richk
parents: 6734
diff changeset
    57
			byte *helipads,
2b971fcc9a08 (svn r10682) [NewGRF_ports] -Feature: Added code to import FSM from within the newgrf, and allocate to compatible structures within Airport. Eventually, it will load to its own dedicated structures.
richk
parents: 6734
diff changeset
    58
			byte *entry_points,
6350
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    59
			Flags flags,
6737
2b971fcc9a08 (svn r10682) [NewGRF_ports] -Feature: Added code to import FSM from within the newgrf, and allocate to compatible structures within Airport. Eventually, it will load to its own dedicated structures.
richk
parents: 6734
diff changeset
    60
			AirportFTAbuildup *apFA,
6734
6e4db2fda167 (svn r10666) [NewGRF_ports] -Change: portFSM added to FSMportsSpec.
richk
parents: 6719
diff changeset
    61
			TileIndexDiffC *depots,
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    62
			byte nof_depots,
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    63
			uint size_x,
6346
4aad704385e1 (svn r8743) -Fix
tron
parents: 6337
diff changeset
    64
			uint size_y,
6367
2f569d554980 (svn r8767) -Fix
tron
parents: 6362
diff changeset
    65
			byte delta_z,
2f569d554980 (svn r8767) -Fix
tron
parents: 6362
diff changeset
    66
			byte catchment
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    67
		);
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    68
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    69
		~AirportFTAClass();
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    70
6738
72d1a2997952 (svn r10683) [NewGRF_ports] -Revert: Too eager to un-const... global search/replace removed too many. Restores necessary ones... for the moment ;)
richk
parents: 6737
diff changeset
    71
		const AirportMovingData *MovingData(byte position) const
6175
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    72
		{
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    73
			assert(position < nofelements);
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    74
			return &moving_data[position];
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    75
		}
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    76
6737
2b971fcc9a08 (svn r10682) [NewGRF_ports] -Feature: Added code to import FSM from within the newgrf, and allocate to compatible structures within Airport. Eventually, it will load to its own dedicated structures.
richk
parents: 6734
diff changeset
    77
	AirportMovingData *moving_data;
6189
2b1ae5e373e9 (svn r8582) -Fix
tron
parents: 6183
diff changeset
    78
	struct AirportFTA *layout;            // state machine for airport
6737
2b971fcc9a08 (svn r10682) [NewGRF_ports] -Feature: Added code to import FSM from within the newgrf, and allocate to compatible structures within Airport. Eventually, it will load to its own dedicated structures.
richk
parents: 6734
diff changeset
    79
	byte *terminals;
2b971fcc9a08 (svn r10682) [NewGRF_ports] -Feature: Added code to import FSM from within the newgrf, and allocate to compatible structures within Airport. Eventually, it will load to its own dedicated structures.
richk
parents: 6734
diff changeset
    80
	byte *helipads;
6734
6e4db2fda167 (svn r10666) [NewGRF_ports] -Change: portFSM added to FSMportsSpec.
richk
parents: 6719
diff changeset
    81
	TileIndexDiffC *airport_depots; // gives the position of the depots on the airports
6350
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    82
	Flags flags;
3697
bd03de677555 (svn r4638) - Codestyle: replacing aligning tabs with spaces
peter1138
parents: 2186
diff changeset
    83
	byte nof_depots;                      // number of depots this airport has
6189
2b1ae5e373e9 (svn r8582) -Fix
tron
parents: 6183
diff changeset
    84
	byte nofelements;                     // number of positions the airport consists of
6737
2b971fcc9a08 (svn r10682) [NewGRF_ports] -Feature: Added code to import FSM from within the newgrf, and allocate to compatible structures within Airport. Eventually, it will load to its own dedicated structures.
richk
parents: 6734
diff changeset
    85
	byte *entry_points;             ///< when an airplane arrives at this airport, enter it at position entry_point, index depends on direction
3876
c0d426e78b56 (svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
tron
parents: 3701
diff changeset
    86
	byte size_x;
c0d426e78b56 (svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
tron
parents: 3701
diff changeset
    87
	byte size_y;
6346
4aad704385e1 (svn r8743) -Fix
tron
parents: 6337
diff changeset
    88
	byte delta_z;                         // Z adjustment for helicopter pads
6367
2f569d554980 (svn r8767) -Fix
tron
parents: 6362
diff changeset
    89
	byte catchment;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    90
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
6351
afb1e3960181 (svn r8748) -Fix
tron
parents: 6350
diff changeset
    92
DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
afb1e3960181 (svn r8748) -Fix
tron
parents: 6350
diff changeset
    93
afb1e3960181 (svn r8748) -Fix
tron
parents: 6350
diff changeset
    94
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
// internal structure used in openttd - Finite sTate mAchine --> FTA
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    96
struct AirportFTA {
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    97
	AirportFTA *next;        // possible extra movement choices from this position
6337
6f3f247870f1 (svn r8733) -Fix(r8705): Forgot to change some more places where airport blocks are stored
celestar
parents: 6321
diff changeset
    98
	uint64 block;            // 64 bit blocks (st->airport_flags), should be enough for the most complex airports
4842
0757e12896c5 (svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents: 4344
diff changeset
    99
	byte position;           // the position that an airplane is at
0757e12896c5 (svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents: 4344
diff changeset
   100
	byte next_position;      // next position from this position
0757e12896c5 (svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents: 4344
diff changeset
   101
	byte heading;            // heading (current orders), guiding an airplane to its target on an airport
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   102
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6519
diff changeset
   104
void InitializeAirports();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6519
diff changeset
   105
void UnInitializeAirports();
6738
72d1a2997952 (svn r10683) [NewGRF_ports] -Revert: Too eager to un-const... global search/replace removed too many. Restores necessary ones... for the moment ;)
richk
parents: 6737
diff changeset
   106
const AirportFTAClass *GetAirport(const byte airport_type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
1784
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1093
diff changeset
   108
/** Get buildable airport bitmask.
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1093
diff changeset
   109
 * @return get all buildable airports at this given time, bitmasked.
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1093
diff changeset
   110
 * Bit 0 means the small airport is buildable, etc.
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1093
diff changeset
   111
 * @todo set availability of airports by year, instead of airplane
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1093
diff changeset
   112
 */
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6519
diff changeset
   113
uint32 GetValidAirports();
1784
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1093
diff changeset
   114
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
#endif /* AIRPORT_H */