tron@2186: /* $Id$ */ tron@2186: belugas@6117: /** @file airport.h Various declarations for airports */ belugas@6117: truelight@0: #ifndef AIRPORT_H truelight@0: #define AIRPORT_H truelight@0: rubidium@5587: #include "direction.h" rubidium@5587: 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 { celestar@6394: AT_SMALL = 0, celestar@6394: AT_LARGE = 1, celestar@6394: AT_HELIPORT = 2, celestar@6394: AT_METROPOLITAN = 3, celestar@6394: AT_INTERNATIONAL = 4, celestar@6394: AT_COMMUTER = 5, celestar@6394: AT_HELIDEPOT = 6, celestar@6394: AT_INTERCON = 7, celestar@6394: AT_HELISTATION = 8, celestar@6394: AT_OILRIG = 15, celestar@6394: AT_DUMMY = 255 truelight@0: }; truelight@0: rubidium@5587: 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, celestar@6193: AMED_HOLD = 1 << 8 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) celestar@5995: static const uint64 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: celestar@5995: NOTHING_block = 1 << 30; peter1138@3701: rubidium@6248: struct AirportMovingData { tron@5938: int16 x; tron@5938: int16 y; celestar@6193: uint16 flag; rubidium@5587: DirectionByte direction; rubidium@6248: }; peter1138@3701: tron@5932: struct AirportFTAbuildup; tron@5932: truelight@0: // Finite sTate mAchine --> FTA rubidium@6248: struct AirportFTAClass { tron@5924: public: tron@6024: enum Flags { KUDr@6027: AIRPLANES = 0x1, tron@6024: HELICOPTERS = 0x2, KUDr@6027: ALL = AIRPLANES | HELICOPTERS, tron@6025: SHORT_STRIP = 0x4 tron@6024: }; tron@6024: tron@5932: AirportFTAClass( tron@5932: const AirportMovingData *moving_data, tron@5932: const byte *terminals, tron@5932: const byte *helipads, celestar@6036: const byte *entry_points, tron@6024: Flags flags, tron@5932: const AirportFTAbuildup *apFA, tron@5932: const TileIndexDiffC *depots, tron@5932: byte nof_depots, tron@5932: uint size_x, tron@6020: uint size_y, tron@6041: byte delta_z, tron@6041: byte catchment tron@5932: ); tron@5932: tron@5932: ~AirportFTAClass(); tron@5932: tron@5924: const AirportMovingData *MovingData(byte position) const tron@5924: { tron@5924: assert(position < nofelements); tron@5924: return &moving_data[position]; tron@5924: } tron@5924: tron@5924: const AirportMovingData *moving_data; tron@5938: 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 tron@6024: Flags flags; peter1138@3697: byte nof_depots; // number of depots this airport has tron@5938: byte nofelements; // number of positions the airport consists of celestar@6036: const byte *entry_points; ///< when an airplane arrives at this airport, enter it at position entry_point, index depends on direction tron@3876: byte size_x; tron@3876: byte size_y; tron@6020: byte delta_z; // Z adjustment for helicopter pads tron@6041: byte catchment; rubidium@6248: }; truelight@0: tron@6025: DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags) tron@6025: tron@6025: truelight@0: // internal structure used in openttd - Finite sTate mAchine --> FTA rubidium@6248: struct AirportFTA { rubidium@6248: AirportFTA *next; // possible extra movement choices from this position celestar@6011: uint64 block; // 64 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 rubidium@6248: }; truelight@0: rubidium@6247: void InitializeAirports(); rubidium@6247: void UnInitializeAirports(); 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: */ rubidium@6247: uint32 GetValidAirports(); Darkvater@1784: truelight@0: #endif /* AIRPORT_H */