2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-02-23 01:48:53 +00:00
|
|
|
/** @file airport.h Various declarations for airports */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#ifndef AIRPORT_H
|
|
|
|
#define AIRPORT_H
|
|
|
|
|
2007-12-18 19:52:14 +00:00
|
|
|
#include "direction_type.h"
|
2007-01-10 18:56:51 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
enum {MAX_TERMINALS = 10};
|
|
|
|
enum {MAX_HELIPADS = 4};
|
2006-05-01 11:27:39 +00:00
|
|
|
enum {MAX_ELEMENTS = 255};
|
2006-08-22 14:38:37 +00:00
|
|
|
enum {MAX_HEADINGS = 22};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
// Airport types
|
|
|
|
enum {
|
2007-03-29 13:52:34 +00:00
|
|
|
AT_SMALL = 0,
|
|
|
|
AT_LARGE = 1,
|
|
|
|
AT_HELIPORT = 2,
|
|
|
|
AT_METROPOLITAN = 3,
|
|
|
|
AT_INTERNATIONAL = 4,
|
|
|
|
AT_COMMUTER = 5,
|
|
|
|
AT_HELIDEPOT = 6,
|
|
|
|
AT_INTERCON = 7,
|
|
|
|
AT_HELISTATION = 8,
|
|
|
|
AT_OILRIG = 15,
|
|
|
|
AT_DUMMY = 255
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
|
2006-05-01 11:27:39 +00:00
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
AMED_NOSPDCLAMP = 1 << 0,
|
|
|
|
AMED_TAKEOFF = 1 << 1,
|
|
|
|
AMED_SLOWTURN = 1 << 2,
|
|
|
|
AMED_LAND = 1 << 3,
|
|
|
|
AMED_EXACTPOS = 1 << 4,
|
|
|
|
AMED_BRAKE = 1 << 5,
|
|
|
|
AMED_HELI_RAISE = 1 << 6,
|
|
|
|
AMED_HELI_LOWER = 1 << 7,
|
2007-03-02 12:01:24 +00:00
|
|
|
AMED_HOLD = 1 << 8
|
2006-05-01 11:27:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Movement States on Airports (headings target) */
|
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
TO_ALL = 0,
|
|
|
|
HANGAR = 1,
|
|
|
|
TERM1 = 2,
|
|
|
|
TERM2 = 3,
|
|
|
|
TERM3 = 4,
|
|
|
|
TERM4 = 5,
|
|
|
|
TERM5 = 6,
|
|
|
|
TERM6 = 7,
|
|
|
|
HELIPAD1 = 8,
|
|
|
|
HELIPAD2 = 9,
|
2006-06-23 22:05:40 +00:00
|
|
|
TAKEOFF = 10,
|
|
|
|
STARTTAKEOFF = 11,
|
|
|
|
ENDTAKEOFF = 12,
|
|
|
|
HELITAKEOFF = 13,
|
|
|
|
FLYING = 14,
|
|
|
|
LANDING = 15,
|
|
|
|
ENDLANDING = 16,
|
|
|
|
HELILANDING = 17,
|
|
|
|
HELIENDLANDING = 18,
|
|
|
|
TERM7 = 19,
|
|
|
|
TERM8 = 20,
|
|
|
|
HELIPAD3 = 21,
|
|
|
|
HELIPAD4 = 22
|
2006-05-01 11:27:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Movement Blocks on Airports */
|
|
|
|
// blocks (eg_airport_flags)
|
2007-02-13 12:34:54 +00:00
|
|
|
static const uint64
|
2007-07-03 23:23:38 +00:00
|
|
|
TERM1_block = 1ULL << 0,
|
|
|
|
TERM2_block = 1ULL << 1,
|
|
|
|
TERM3_block = 1ULL << 2,
|
|
|
|
TERM4_block = 1ULL << 3,
|
|
|
|
TERM5_block = 1ULL << 4,
|
|
|
|
TERM6_block = 1ULL << 5,
|
|
|
|
HELIPAD1_block = 1ULL << 6,
|
|
|
|
HELIPAD2_block = 1ULL << 7,
|
|
|
|
RUNWAY_IN_OUT_block = 1ULL << 8,
|
|
|
|
RUNWAY_IN_block = 1ULL << 8,
|
|
|
|
AIRPORT_BUSY_block = 1ULL << 8,
|
|
|
|
RUNWAY_OUT_block = 1ULL << 9,
|
|
|
|
TAXIWAY_BUSY_block = 1ULL << 10,
|
|
|
|
OUT_WAY_block = 1ULL << 11,
|
|
|
|
IN_WAY_block = 1ULL << 12,
|
|
|
|
AIRPORT_ENTRANCE_block = 1ULL << 13,
|
|
|
|
TERM_GROUP1_block = 1ULL << 14,
|
|
|
|
TERM_GROUP2_block = 1ULL << 15,
|
|
|
|
HANGAR2_AREA_block = 1ULL << 16,
|
|
|
|
TERM_GROUP2_ENTER1_block = 1ULL << 17,
|
|
|
|
TERM_GROUP2_ENTER2_block = 1ULL << 18,
|
|
|
|
TERM_GROUP2_EXIT1_block = 1ULL << 19,
|
|
|
|
TERM_GROUP2_EXIT2_block = 1ULL << 20,
|
|
|
|
PRE_HELIPAD_block = 1ULL << 21,
|
2006-06-23 22:05:40 +00:00
|
|
|
|
|
|
|
// blocks for new airports
|
2007-07-03 23:23:38 +00:00
|
|
|
TERM7_block = 1ULL << 22,
|
|
|
|
TERM8_block = 1ULL << 23,
|
|
|
|
TERM9_block = 1ULL << 24,
|
|
|
|
HELIPAD3_block = 1ULL << 24,
|
|
|
|
TERM10_block = 1ULL << 25,
|
|
|
|
HELIPAD4_block = 1ULL << 25,
|
|
|
|
HANGAR1_AREA_block = 1ULL << 26,
|
|
|
|
OUT_WAY2_block = 1ULL << 27,
|
|
|
|
IN_WAY2_block = 1ULL << 28,
|
|
|
|
RUNWAY_IN2_block = 1ULL << 29,
|
|
|
|
RUNWAY_OUT2_block = 1ULL << 10, // note re-uses TAXIWAY_BUSY
|
|
|
|
HELIPAD_GROUP_block = 1ULL << 13, // note re-uses AIRPORT_ENTRANCE
|
|
|
|
OUT_WAY_block2 = 1ULL << 31,
|
2006-06-23 22:05:40 +00:00
|
|
|
// end of new blocks
|
|
|
|
|
2007-07-03 23:23:38 +00:00
|
|
|
NOTHING_block = 1ULL << 30;
|
2006-05-01 11:27:39 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct AirportMovingData {
|
2007-02-04 13:46:21 +00:00
|
|
|
int16 x;
|
|
|
|
int16 y;
|
2007-03-02 12:01:24 +00:00
|
|
|
uint16 flag;
|
2007-01-10 18:56:51 +00:00
|
|
|
DirectionByte direction;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-05-01 11:27:39 +00:00
|
|
|
|
2007-02-04 10:25:57 +00:00
|
|
|
struct AirportFTAbuildup;
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
// Finite sTate mAchine --> FTA
|
2007-03-07 12:11:48 +00:00
|
|
|
struct AirportFTAClass {
|
2007-02-03 13:03:11 +00:00
|
|
|
public:
|
2007-02-15 20:16:33 +00:00
|
|
|
enum Flags {
|
2007-02-15 22:00:04 +00:00
|
|
|
AIRPLANES = 0x1,
|
2007-02-15 20:16:33 +00:00
|
|
|
HELICOPTERS = 0x2,
|
2007-02-15 22:00:04 +00:00
|
|
|
ALL = AIRPLANES | HELICOPTERS,
|
2007-02-15 20:35:45 +00:00
|
|
|
SHORT_STRIP = 0x4
|
2007-02-15 20:16:33 +00:00
|
|
|
};
|
|
|
|
|
2007-02-04 10:25:57 +00:00
|
|
|
AirportFTAClass(
|
|
|
|
const AirportMovingData *moving_data,
|
|
|
|
const byte *terminals,
|
|
|
|
const byte *helipads,
|
2007-02-16 12:10:19 +00:00
|
|
|
const byte *entry_points,
|
2007-02-15 20:16:33 +00:00
|
|
|
Flags flags,
|
2007-02-04 10:25:57 +00:00
|
|
|
const AirportFTAbuildup *apFA,
|
|
|
|
const TileIndexDiffC *depots,
|
|
|
|
byte nof_depots,
|
|
|
|
uint size_x,
|
2007-02-15 07:43:06 +00:00
|
|
|
uint size_y,
|
2007-02-17 07:45:18 +00:00
|
|
|
byte delta_z,
|
|
|
|
byte catchment
|
2007-02-04 10:25:57 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
~AirportFTAClass();
|
|
|
|
|
2007-02-03 13:03:11 +00:00
|
|
|
const AirportMovingData *MovingData(byte position) const
|
|
|
|
{
|
|
|
|
assert(position < nofelements);
|
|
|
|
return &moving_data[position];
|
|
|
|
}
|
|
|
|
|
|
|
|
const AirportMovingData *moving_data;
|
2007-02-04 13:46:21 +00:00
|
|
|
struct AirportFTA *layout; // state machine for airport
|
2005-01-09 08:49:40 +00:00
|
|
|
const byte *terminals;
|
|
|
|
const byte *helipads;
|
2006-05-01 08:37:54 +00:00
|
|
|
const TileIndexDiffC *airport_depots; // gives the position of the depots on the airports
|
2007-02-15 20:16:33 +00:00
|
|
|
Flags flags;
|
2006-05-01 08:37:54 +00:00
|
|
|
byte nof_depots; // number of depots this airport has
|
2007-02-04 13:46:21 +00:00
|
|
|
byte nofelements; // number of positions the airport consists of
|
2007-02-16 12:10:19 +00:00
|
|
|
const byte *entry_points; ///< when an airplane arrives at this airport, enter it at position entry_point, index depends on direction
|
2006-05-20 15:13:27 +00:00
|
|
|
byte size_x;
|
|
|
|
byte size_y;
|
2007-02-15 07:43:06 +00:00
|
|
|
byte delta_z; // Z adjustment for helicopter pads
|
2007-02-17 07:45:18 +00:00
|
|
|
byte catchment;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-02-15 20:35:45 +00:00
|
|
|
DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
|
|
|
|
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
// internal structure used in openttd - Finite sTate mAchine --> FTA
|
2007-03-07 12:11:48 +00:00
|
|
|
struct AirportFTA {
|
|
|
|
AirportFTA *next; // possible extra movement choices from this position
|
2007-02-14 12:00:43 +00:00
|
|
|
uint64 block; // 64 bit blocks (st->airport_flags), should be enough for the most complex airports
|
2006-10-13 23:08:55 +00:00
|
|
|
byte position; // the position that an airplane is at
|
|
|
|
byte next_position; // next position from this position
|
|
|
|
byte heading; // heading (current orders), guiding an airplane to its target on an airport
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeAirports();
|
|
|
|
void UnInitializeAirports();
|
2006-07-26 03:33:12 +00:00
|
|
|
const AirportFTAClass *GetAirport(const byte airport_type);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-05-09 22:33:00 +00:00
|
|
|
/** Get buildable airport bitmask.
|
|
|
|
* @return get all buildable airports at this given time, bitmasked.
|
|
|
|
* Bit 0 means the small airport is buildable, etc.
|
|
|
|
* @todo set availability of airports by year, instead of airplane
|
|
|
|
*/
|
2007-03-07 11:47:46 +00:00
|
|
|
uint32 GetValidAirports();
|
2005-05-09 22:33:00 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#endif /* AIRPORT_H */
|