src/airport.h
author richk
Tue, 31 Jul 2007 00:36:55 +0000
branchNewGRF_ports
changeset 6739 3f2ca4d0abda
parent 6738 72d1a2997952
child 6740 0dec022fa01a
permissions -rw-r--r--
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
rb_airport2.grf updated. Commuter airport FSM working.
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"
6739
3f2ca4d0abda (svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents: 6738
diff changeset
     9
#include "fsmblockmap.h"
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    10
6739
3f2ca4d0abda (svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents: 6738
diff changeset
    11
enum {MAX_TERMINALS =  36};
3f2ca4d0abda (svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents: 6738
diff changeset
    12
enum {MAX_HELIPADS  =  24};
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
    13
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
    14
enum {MAX_HEADINGS  =  30};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
// Airport types
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
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
    18
	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
    19
	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
    20
	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
    21
	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
    22
	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
    23
	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
    24
	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
    25
	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
    26
	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
    27
	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
    28
	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
    29
	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
    30
	AT_AMS           = 12,
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6715
diff changeset
    31
	AT_OILRIG        = 15,
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6715
diff changeset
    32
	AT_DUMMY         = 255
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    35
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    36
struct AirportMovingData {
6189
2b1ae5e373e9 (svn r8582) -Fix
tron
parents: 6183
diff changeset
    37
	int16 x;
2b1ae5e373e9 (svn r8582) -Fix
tron
parents: 6183
diff changeset
    38
	int16 y;
6739
3f2ca4d0abda (svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents: 6738
diff changeset
    39
	byte z;
3f2ca4d0abda (svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents: 6738
diff changeset
    40
	byte state;
3f2ca4d0abda (svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents: 6738
diff changeset
    41
	byte block;  //block number for this specific location
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
    42
	uint16 flag;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    43
	DirectionByte direction;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    44
};
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
    45
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    46
struct AirportFTAbuildup;
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    47
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
// Finite sTate mAchine --> FTA
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    49
struct AirportFTAClass {
6175
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    50
	public:
6350
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    51
		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
    52
			AIRPLANES   = 0x1,
6350
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    53
			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
    54
			ALL         = AIRPLANES | HELICOPTERS,
6351
afb1e3960181 (svn r8748) -Fix
tron
parents: 6350
diff changeset
    55
			SHORT_STRIP = 0x4
6350
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    56
		};
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    57
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    58
		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
    59
			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
    60
			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
    61
			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
    62
			byte *entry_points,
6350
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    63
			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
    64
			AirportFTAbuildup *apFA,
6734
6e4db2fda167 (svn r10666) [NewGRF_ports] -Change: portFSM added to FSMportsSpec.
richk
parents: 6719
diff changeset
    65
			TileIndexDiffC *depots,
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    66
			byte nof_depots,
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    67
			uint size_x,
6346
4aad704385e1 (svn r8743) -Fix
tron
parents: 6337
diff changeset
    68
			uint size_y,
6367
2f569d554980 (svn r8767) -Fix
tron
parents: 6362
diff changeset
    69
			byte delta_z,
2f569d554980 (svn r8767) -Fix
tron
parents: 6362
diff changeset
    70
			byte catchment
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    71
		);
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    72
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    73
		~AirportFTAClass();
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    74
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
    75
		const AirportMovingData *MovingData(byte position) const
6175
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    76
		{
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    77
			assert(position < nofelements);
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    78
			return &moving_data[position];
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    79
		}
26674ca57aac (svn r8559) -Fix
tron
parents: 6005
diff changeset
    80
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
    81
	AirportMovingData *moving_data;
6189
2b1ae5e373e9 (svn r8582) -Fix
tron
parents: 6183
diff changeset
    82
	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
    83
	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
    84
	byte *helipads;
6734
6e4db2fda167 (svn r10666) [NewGRF_ports] -Change: portFSM added to FSMportsSpec.
richk
parents: 6719
diff changeset
    85
	TileIndexDiffC *airport_depots; // gives the position of the depots on the airports
6350
c644e180cdf8 (svn r8747) -Fix
tron
parents: 6346
diff changeset
    86
	Flags flags;
3697
bd03de677555 (svn r4638) - Codestyle: replacing aligning tabs with spaces
peter1138
parents: 2186
diff changeset
    87
	byte nof_depots;                      // number of depots this airport has
6189
2b1ae5e373e9 (svn r8582) -Fix
tron
parents: 6183
diff changeset
    88
	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
    89
	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
    90
	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
    91
	byte size_y;
6346
4aad704385e1 (svn r8743) -Fix
tron
parents: 6337
diff changeset
    92
	byte delta_z;                         // Z adjustment for helicopter pads
6367
2f569d554980 (svn r8767) -Fix
tron
parents: 6362
diff changeset
    93
	byte catchment;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    94
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
6351
afb1e3960181 (svn r8748) -Fix
tron
parents: 6350
diff changeset
    96
DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
afb1e3960181 (svn r8748) -Fix
tron
parents: 6350
diff changeset
    97
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
// 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
    99
struct AirportFTA {
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   100
	AirportFTA *next;        // possible extra movement choices from this position
6739
3f2ca4d0abda (svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents: 6738
diff changeset
   101
	FSMblockmap reserveblock;       // 2 64 bit blocks
3f2ca4d0abda (svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents: 6738
diff changeset
   102
	FSMblockmap releaseblock;       // 2 64 bit blocks
4842
0757e12896c5 (svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents: 4344
diff changeset
   103
	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
   104
	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
   105
	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
   106
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6519
diff changeset
   108
void InitializeAirports();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6519
diff changeset
   109
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
   110
const AirportFTAClass *GetAirport(const byte airport_type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
1784
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1093
diff changeset
   112
/** 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
   113
 * @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
   114
 * 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
   115
 * @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
   116
 */
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6519
diff changeset
   117
uint32 GetValidAirports();
1784
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1093
diff changeset
   118
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
#endif /* AIRPORT_H */