tron@2186: /* $Id$ */ tron@2186: truelight@0: #ifndef AIRPORT_H truelight@0: #define AIRPORT_H truelight@0: rubidium@5838: #include "direction.h" rubidium@5838: rubidium@4344: enum {MAX_TERMINALS = 10}; rubidium@4344: enum {MAX_HELIPADS = 4}; peter1138@3701: enum {MAX_ELEMENTS = 255}; rubidium@4344: enum {MAX_HEADINGS = 22}; truelight@0: truelight@0: // Airport types truelight@0: enum { rubidium@4344: AT_SMALL = 0, rubidium@4344: AT_LARGE = 1, rubidium@4344: AT_HELIPORT = 2, rubidium@4344: AT_METROPOLITAN = 3, rubidium@4344: AT_INTERNATIONAL = 4, rubidium@4344: AT_COMMUTER = 5, rubidium@4344: AT_HELIDEPOT = 6, rubidium@4344: AT_INTERCON = 7, rubidium@4344: AT_HELISTATION = 8, richk@4059: AT_OILRIG = 15 truelight@0: }; truelight@0: truelight@0: // do not change unless you change v->subtype too. This aligns perfectly with its current setting rubidium@5838: enum AcceptPlanes { rubidium@5838: ACC_BEGIN = 0, peter1138@3697: AIRCRAFT_ONLY = 0, peter1138@3697: ALL = 1, peter1138@3697: HELICOPTERS_ONLY = 2, rubidium@5838: ACC_END truelight@0: }; truelight@0: rubidium@5838: /** Define basic enum properties */ rubidium@5838: template <> struct EnumPropsT : MakeEnumPropsT {}; rubidium@5838: typedef TinyEnumT AcceptPlanesByte; rubidium@5838: peter1138@3701: enum { rubidium@4344: AMED_NOSPDCLAMP = 1 << 0, rubidium@4344: AMED_TAKEOFF = 1 << 1, rubidium@4344: AMED_SLOWTURN = 1 << 2, rubidium@4344: AMED_LAND = 1 << 3, rubidium@4344: AMED_EXACTPOS = 1 << 4, rubidium@4344: AMED_BRAKE = 1 << 5, rubidium@4344: AMED_HELI_RAISE = 1 << 6, rubidium@4344: AMED_HELI_LOWER = 1 << 7, peter1138@3701: }; peter1138@3701: peter1138@3701: /* Movement States on Airports (headings target) */ peter1138@3701: enum { rubidium@4344: TO_ALL = 0, rubidium@4344: HANGAR = 1, rubidium@4344: TERM1 = 2, rubidium@4344: TERM2 = 3, rubidium@4344: TERM3 = 4, rubidium@4344: TERM4 = 5, rubidium@4344: TERM5 = 6, rubidium@4344: TERM6 = 7, rubidium@4344: HELIPAD1 = 8, rubidium@4344: HELIPAD2 = 9, richk@4059: TAKEOFF = 10, richk@4059: STARTTAKEOFF = 11, richk@4059: ENDTAKEOFF = 12, richk@4059: HELITAKEOFF = 13, richk@4059: FLYING = 14, richk@4059: LANDING = 15, richk@4059: ENDLANDING = 16, richk@4059: HELILANDING = 17, richk@4059: HELIENDLANDING = 18, richk@4059: TERM7 = 19, richk@4059: TERM8 = 20, richk@4059: HELIPAD3 = 21, richk@4059: HELIPAD4 = 22 peter1138@3701: }; peter1138@3701: peter1138@3701: /* Movement Blocks on Airports */ peter1138@3701: // blocks (eg_airport_flags) peter1138@3701: enum { rubidium@4344: TERM1_block = 1 << 0, rubidium@4344: TERM2_block = 1 << 1, rubidium@4344: TERM3_block = 1 << 2, rubidium@4344: TERM4_block = 1 << 3, rubidium@4344: TERM5_block = 1 << 4, rubidium@4344: TERM6_block = 1 << 5, rubidium@4344: HELIPAD1_block = 1 << 6, rubidium@4344: HELIPAD2_block = 1 << 7, rubidium@4344: RUNWAY_IN_OUT_block = 1 << 8, rubidium@4344: RUNWAY_IN_block = 1 << 8, rubidium@4344: AIRPORT_BUSY_block = 1 << 8, rubidium@4344: RUNWAY_OUT_block = 1 << 9, peter1138@3701: TAXIWAY_BUSY_block = 1 << 10, peter1138@3701: OUT_WAY_block = 1 << 11, peter1138@3701: IN_WAY_block = 1 << 12, peter1138@3701: AIRPORT_ENTRANCE_block = 1 << 13, peter1138@3701: TERM_GROUP1_block = 1 << 14, peter1138@3701: TERM_GROUP2_block = 1 << 15, peter1138@3701: HANGAR2_AREA_block = 1 << 16, peter1138@3701: TERM_GROUP2_ENTER1_block = 1 << 17, peter1138@3701: TERM_GROUP2_ENTER2_block = 1 << 18, peter1138@3701: TERM_GROUP2_EXIT1_block = 1 << 19, peter1138@3701: TERM_GROUP2_EXIT2_block = 1 << 20, peter1138@3701: PRE_HELIPAD_block = 1 << 21, richk@4059: richk@4059: // blocks for new airports richk@4059: TERM7_block = 1 << 22, richk@4059: TERM8_block = 1 << 23, richk@4059: TERM9_block = 1 << 24, richk@4059: HELIPAD3_block = 1 << 24, richk@4059: TERM10_block = 1 << 25, richk@4059: HELIPAD4_block = 1 << 25, richk@4059: HANGAR1_AREA_block = 1 << 26, richk@4059: OUT_WAY2_block = 1 << 27, richk@4059: IN_WAY2_block = 1 << 28, richk@4059: RUNWAY_IN2_block = 1 << 29, richk@4059: RUNWAY_OUT2_block = 1 << 10, // note re-uses TAXIWAY_BUSY richk@4059: HELIPAD_GROUP_block = 1 << 13, // note re-uses AIRPORT_ENTRANCE richk@4059: OUT_WAY_block2 = 1 << 31, richk@4059: // end of new blocks richk@4059: richk@4059: NOTHING_block = 1 << 30 peter1138@3701: }; peter1138@3701: peter1138@3701: typedef struct AirportMovingData { tron@6189: int16 x; tron@6189: int16 y; peter1138@3701: byte flag; rubidium@5838: DirectionByte direction; peter1138@3701: } AirportMovingData; peter1138@3701: tron@6183: struct AirportFTAbuildup; tron@6183: truelight@0: // Finite sTate mAchine --> FTA truelight@0: typedef struct AirportFTAClass { tron@6175: public: tron@6183: AirportFTAClass( tron@6183: const AirportMovingData *moving_data, tron@6183: const byte *terminals, tron@6183: const byte *helipads, tron@6183: byte entry_point, tron@6183: AcceptPlanes acc_planes, tron@6183: const AirportFTAbuildup *apFA, tron@6183: const TileIndexDiffC *depots, tron@6183: byte nof_depots, tron@6183: uint size_x, tron@6183: uint size_y tron@6183: ); tron@6183: tron@6183: ~AirportFTAClass(); tron@6183: tron@6175: const AirportMovingData *MovingData(byte position) const tron@6175: { tron@6175: assert(position < nofelements); tron@6175: return &moving_data[position]; tron@6175: } tron@6175: tron@6175: const AirportMovingData *moving_data; tron@6189: struct AirportFTA *layout; // state machine for airport celestar@950: const byte *terminals; celestar@950: const byte *helipads; peter1138@3697: const TileIndexDiffC *airport_depots; // gives the position of the depots on the airports peter1138@3697: byte nof_depots; // number of depots this airport has tron@6189: byte nofelements; // number of positions the airport consists of tron@6189: byte entry_point; // when an airplane arrives at this airport, enter it at position entry_point tron@6189: AcceptPlanesByte acc_planes; // accept airplanes or helicopters or both tron@3876: byte size_x; tron@3876: byte size_y; truelight@0: } AirportFTAClass; truelight@0: truelight@0: // internal structure used in openttd - Finite sTate mAchine --> FTA truelight@0: typedef struct AirportFTA { tron@6189: struct AirportFTA *next; // possible extra movement choices from this position tron@6189: uint32 block; // 32 bit blocks (st->airport_flags), should be enough for the most complex airports Darkvater@4842: byte position; // the position that an airplane is at Darkvater@4842: byte next_position; // next position from this position Darkvater@4842: byte heading; // heading (current orders), guiding an airplane to its target on an airport truelight@0: } AirportFTA; truelight@0: tron@1093: void InitializeAirports(void); tron@1093: void UnInitializeAirports(void); belugas@4171: const AirportFTAClass *GetAirport(const byte airport_type); truelight@0: Darkvater@1784: /** Get buildable airport bitmask. Darkvater@1784: * @return get all buildable airports at this given time, bitmasked. Darkvater@1784: * Bit 0 means the small airport is buildable, etc. Darkvater@1784: * @todo set availability of airports by year, instead of airplane Darkvater@1784: */ tron@2159: uint32 GetValidAirports(void); Darkvater@1784: truelight@0: #endif /* AIRPORT_H */