tron@2186: /* $Id$ */ tron@2186: belugas@6443: /** @file airport.h Various declarations for airports */ belugas@6443: truelight@0: #ifndef AIRPORT_H truelight@0: #define AIRPORT_H truelight@0: rubidium@8596: #include "direction_type.h" rubidium@8635: #include "map_type.h" belugas@10682: #include "tile_type.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: belugas@10131: /* Airport types */ truelight@0: enum { celestar@6890: AT_SMALL = 0, celestar@6890: AT_LARGE = 1, celestar@6890: AT_HELIPORT = 2, celestar@6890: AT_METROPOLITAN = 3, celestar@6890: AT_INTERNATIONAL = 4, celestar@6890: AT_COMMUTER = 5, celestar@6890: AT_HELIDEPOT = 6, celestar@6890: AT_INTERCON = 7, celestar@6890: AT_HELISTATION = 8, celestar@6890: AT_OILRIG = 15, celestar@6890: AT_DUMMY = 255 truelight@0: }; truelight@0: 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, celestar@6519: 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 */ belugas@10131: /* blocks (eg_airport_flags) */ celestar@6321: static const uint64 KUDr@7644: TERM1_block = 1ULL << 0, KUDr@7644: TERM2_block = 1ULL << 1, KUDr@7644: TERM3_block = 1ULL << 2, KUDr@7644: TERM4_block = 1ULL << 3, KUDr@7644: TERM5_block = 1ULL << 4, KUDr@7644: TERM6_block = 1ULL << 5, KUDr@7644: HELIPAD1_block = 1ULL << 6, KUDr@7644: HELIPAD2_block = 1ULL << 7, KUDr@7644: RUNWAY_IN_OUT_block = 1ULL << 8, KUDr@7644: RUNWAY_IN_block = 1ULL << 8, KUDr@7644: AIRPORT_BUSY_block = 1ULL << 8, KUDr@7644: RUNWAY_OUT_block = 1ULL << 9, KUDr@7644: TAXIWAY_BUSY_block = 1ULL << 10, KUDr@7644: OUT_WAY_block = 1ULL << 11, KUDr@7644: IN_WAY_block = 1ULL << 12, KUDr@7644: AIRPORT_ENTRANCE_block = 1ULL << 13, KUDr@7644: TERM_GROUP1_block = 1ULL << 14, KUDr@7644: TERM_GROUP2_block = 1ULL << 15, KUDr@7644: HANGAR2_AREA_block = 1ULL << 16, KUDr@7644: TERM_GROUP2_ENTER1_block = 1ULL << 17, KUDr@7644: TERM_GROUP2_ENTER2_block = 1ULL << 18, KUDr@7644: TERM_GROUP2_EXIT1_block = 1ULL << 19, KUDr@7644: TERM_GROUP2_EXIT2_block = 1ULL << 20, KUDr@7644: PRE_HELIPAD_block = 1ULL << 21, richk@4059: belugas@10131: /* blocks for new airports */ KUDr@7644: TERM7_block = 1ULL << 22, KUDr@7644: TERM8_block = 1ULL << 23, KUDr@7644: TERM9_block = 1ULL << 24, KUDr@7644: HELIPAD3_block = 1ULL << 24, KUDr@7644: TERM10_block = 1ULL << 25, KUDr@7644: HELIPAD4_block = 1ULL << 25, KUDr@7644: HANGAR1_AREA_block = 1ULL << 26, KUDr@7644: OUT_WAY2_block = 1ULL << 27, KUDr@7644: IN_WAY2_block = 1ULL << 28, KUDr@7644: RUNWAY_IN2_block = 1ULL << 29, belugas@10131: RUNWAY_OUT2_block = 1ULL << 10, ///< note re-uses TAXIWAY_BUSY belugas@10131: HELIPAD_GROUP_block = 1ULL << 13, ///< note re-uses AIRPORT_ENTRANCE KUDr@7644: OUT_WAY_block2 = 1ULL << 31, belugas@10131: /* end of new blocks */ richk@4059: KUDr@7644: NOTHING_block = 1ULL << 30; peter1138@3701: rubidium@6574: struct AirportMovingData { tron@6189: int16 x; tron@6189: int16 y; celestar@6519: uint16 flag; rubidium@5838: DirectionByte direction; rubidium@6574: }; peter1138@3701: tron@6183: struct AirportFTAbuildup; tron@6183: belugas@10131: /** Finite sTate mAchine --> FTA */ rubidium@6574: struct AirportFTAClass { tron@6175: public: tron@6350: enum Flags { KUDr@6353: AIRPLANES = 0x1, tron@6350: HELICOPTERS = 0x2, KUDr@6353: ALL = AIRPLANES | HELICOPTERS, tron@6351: SHORT_STRIP = 0x4 tron@6350: }; tron@6350: tron@6183: AirportFTAClass( tron@6183: const AirportMovingData *moving_data, tron@6183: const byte *terminals, tron@6183: const byte *helipads, celestar@6362: const byte *entry_points, tron@6350: Flags flags, tron@6183: const AirportFTAbuildup *apFA, tron@6183: const TileIndexDiffC *depots, tron@6183: byte nof_depots, tron@6183: uint size_x, tron@6346: uint size_y, belugas@10682: uint8 noise_level, tron@6367: byte delta_z, tron@6367: byte catchment 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; belugas@10131: struct AirportFTA *layout; ///< state machine for airport celestar@950: const byte *terminals; celestar@950: const byte *helipads; belugas@10131: const TileIndexDiffC *airport_depots; ///< gives the position of the depots on the airports tron@6350: Flags flags; belugas@10131: byte nof_depots; ///< number of depots this airport has belugas@10131: byte nofelements; ///< number of positions the airport consists of celestar@6362: 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; belugas@10682: uint8 noise_level; ///< noise that this airport generates belugas@10131: byte delta_z; ///< Z adjustment for helicopter pads tron@6367: byte catchment; rubidium@6574: }; truelight@0: tron@6351: DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags) tron@6351: tron@6351: belugas@10131: /** internal structure used in openttd - Finite sTate mAchine --> FTA */ rubidium@6574: struct AirportFTA { belugas@10131: AirportFTA *next; ///< possible extra movement choices from this position belugas@10131: uint64 block; ///< 64 bit blocks (st->airport_flags), should be enough for the most complex airports belugas@10131: byte position; ///< the position that an airplane is at belugas@10131: byte next_position; ///< next position from this position belugas@10131: byte heading; ///< heading (current orders), guiding an airplane to its target on an airport rubidium@6574: }; truelight@0: rubidium@6573: void InitializeAirports(); rubidium@6573: 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@6573: uint32 GetValidAirports(); Darkvater@1784: belugas@10682: belugas@10682: /* Calculate the noise this type airport will generate */ belugas@10682: uint8 GetAirportNoiseLevelForTown(const AirportFTAClass *afc, TileIndex town_tile, TileIndex tile); belugas@10682: truelight@0: #endif /* AIRPORT_H */