tron@2186: /* $Id$ */ tron@2186: truelight@0: #ifndef AIRPORT_H truelight@0: #define AIRPORT_H truelight@0: 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 truelight@0: enum { peter1138@3697: AIRCRAFT_ONLY = 0, peter1138@3697: ALL = 1, peter1138@3697: HELICOPTERS_ONLY = 2, truelight@0: }; truelight@0: 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: richk@4059: // this maps the terminal to its corresponding state and block flag richk@4059: // currently set for 10 terms, 4 helipads richk@4059: static const byte _airport_terminal_state[] = {2, 3, 4, 5, 6, 7, 19, 20, 0, 0, 8, 9, 21, 22}; richk@4059: static const byte _airport_terminal_flag[] = {0, 1, 2, 3, 4, 5, 22, 23, 0, 0, 6, 7, 24, 25}; richk@4059: 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 { peter1138@3701: int x,y; peter1138@3701: byte flag; peter1138@3701: byte direction; peter1138@3701: } AirportMovingData; peter1138@3701: truelight@0: // Finite sTate mAchine --> FTA truelight@0: typedef struct AirportFTAClass { peter1138@3697: byte nofelements; // number of positions the airport consists of celestar@950: const byte *terminals; celestar@950: const byte *helipads; peter1138@3697: byte entry_point; // when an airplane arrives at this airport, enter it at position entry_point peter1138@3697: byte acc_planes; // accept airplanes or helicopters or both 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 peter1138@3697: struct AirportFTA *layout; // state machine for airport 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 { Darkvater@4842: byte position; // the position that an airplane is at Darkvater@4842: byte next_position; // next position from this position Darkvater@4842: uint32 block; // 32 bit blocks (st->airport_flags), should be enough for the most complex airports Darkvater@4842: byte heading; // heading (current orders), guiding an airplane to its target on an airport Darkvater@4842: struct AirportFTA *next; // possible extra movement choices from this position truelight@0: } AirportFTA; truelight@0: tron@1093: void InitializeAirports(void); tron@1093: void UnInitializeAirports(void); belugas@4171: const AirportFTAClass *GetAirport(const byte airport_type); peter1138@3701: const AirportMovingData *GetAirportMovingData(byte airport_type, byte position); 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 */