src/airport.h
author richk
Thu, 24 Apr 2008 21:52:22 +0000
branchNewGRF_ports
changeset 10336 d15acd4a2baf
parent 10200 aba3af04cdbd
child 10731 67db0d431d5e
permissions -rw-r--r--
(svn r12877) [NewGRF_ports] -Change: Added names for additional BLIMP states.
/* $Id$ */

/** @file airport.h Various declarations for airports */

#ifndef AIRPORT_H
#define AIRPORT_H

#include "fsmport.h"
#include <list>

typedef FSMCommand AirportFTA;
typedef FSMPortMovingData AirportMovingData;

enum {MAX_TERMINALS =  36};
enum {MAX_HELIPADS  =  24};
enum {MAX_ELEMENTS  = 255};
enum {MAX_HEADINGS  =  30};

/* Airport types */
enum {
	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
};

/* Airport movements & speeds */
enum {
	AMED_EXACTPOS   = 1 << 0,
	AMED_NOSPDCLAMP = 1 << 4,
	AMED_SLOWTURN   = 1 << 5,
	AMED_BRAKE      = 1 << 6,
	AMED_HOLD       = 1 << 7,
	AMED_LAND       = 1 << 8,
	AMED_HELI_RAISE = 1 << 8,
	AMED_TAKEOFF    = 1 << 8,
	AMED_HELI_LOWER = 1 << 8,
};

/* Movement States on Airports (headings target) */
enum {
	TO_ALL            = 0x00,
	FIRST_TERMINAL    = 0x01,
	LAST_TERMINAL     = 0x24,
	FIRST_HELIPAD     = 0x25,
	LAST_HELIPAD      = 0x3C,
	HANGAR            = 0x40,
	TAKEOFF           = 0x41,
	STARTTAKEOFF      = 0x42,
	ENDTAKEOFF        = 0x43,
	LANDING           = 0x44,
	ENDLANDING        = 0x45,
	SMALLHANGAR       = 0x48,
	SMALLTAKEOFF      = 0x49,  /* Only used in movement command choices. If used as the heading in the first command element, treated as TAKEOFF.
						   * This is best placed on the TAKEOFF line at the start of the runway. The aircraft will make the acceleration noise,
						   * and then you give the instruction of where to go to for the SHORTTAKEOFF instruction sequence. eg.:
						   * { 40, TAKEOFF, RUNWAY_OUT_block, 0 }, { 40, SHORTTAKEOFF, RUNWAY_OUT_block2, 42 }, { 40, 0, RUNWAY_OUT_block2, 41 },
						   */
	SMALLSTARTTAKEOFF = 0x4A,
	SMALLENDTAKEOFF   = 0x4B,
	SMALLLANDING      = 0x4C,
	SMALLENDLANDING   = 0x4D,
	HELITAKEOFF       = 0x51,
	HELIENDTAKEOFF    = 0x53,
	HELILANDING       = 0x54,
	HELIENDLANDING    = 0x55,
	BLIMPHANGAR       = 0x58,
	BLIMPTAKEOFF      = 0x59,
	BLIMPSTARTTAKEOFF = 0x5A,
	BLIMPENDTAKEOFF   = 0x5B,
	BLIMPLANDING      = 0x5C,
	BLIMPENDLANDING   = 0x5D,
	CHOOSEHELIPAD     = 0x7D,
	CHOOSETERMINAL    = 0x7E,
	FLYING            = 0x7F,
};

/** Finite sTate mAchine --> FTA */
struct AirportFTAClass : FSMPortClass {
public:
	static AirportFTAClass *oil_rig; ///< "Special" holding pattern used for oil rigs.
	static AirportFTAClass *dummy;   ///< A dummy holding pattern to be used when an airport has been removed, but the order to go to the airport has not been removed.

	enum Flags {
		AIRPLANES   = 0x1,
		HELICOPTERS = 0x2,
		ALL         = AIRPLANES | HELICOPTERS,
		SHORT_STRIP = 0x4,
		SEAPLANES   = 0x8
	};

	AirportFTAClass(FSMportsSpec *spec) : FSMPortClass(spec), terminals(NULL), helipads(NULL), flags((Flags)0), entry_points(NULL) {}

	~AirportFTAClass();

	byte *terminals;
	byte *helipads;
	Flags flags;
	byte *entry_points;             ///< when an airplane arrives at this airport, enter it at position entry_point, index depends on direction
};

DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)

/**
 * Get a list of currently available airports.
 * @return the list with available airports.
 * @note return is "class index" << 8 | "index within class"
 */
std::list<uint16> GetAvailableAirports();

#endif /* AIRPORT_H */