airport.h

Go to the documentation of this file.
00001 /* $Id: airport.h 11701 2007-12-26 11:45:43Z rubidium $ */
00002 
00005 #ifndef AIRPORT_H
00006 #define AIRPORT_H
00007 
00008 #include "direction_type.h"
00009 #include "map_type.h"
00010 
00011 enum {MAX_TERMINALS =  10};
00012 enum {MAX_HELIPADS  =   4};
00013 enum {MAX_ELEMENTS  = 255};
00014 enum {MAX_HEADINGS  =  22};
00015 
00016 // Airport types
00017 enum {
00018   AT_SMALL         =   0,
00019   AT_LARGE         =   1,
00020   AT_HELIPORT      =   2,
00021   AT_METROPOLITAN  =   3,
00022   AT_INTERNATIONAL =   4,
00023   AT_COMMUTER      =   5,
00024   AT_HELIDEPOT     =   6,
00025   AT_INTERCON      =   7,
00026   AT_HELISTATION   =   8,
00027   AT_OILRIG        =  15,
00028   AT_DUMMY         = 255
00029 };
00030 
00031 
00032 enum {
00033   AMED_NOSPDCLAMP = 1 << 0,
00034   AMED_TAKEOFF    = 1 << 1,
00035   AMED_SLOWTURN   = 1 << 2,
00036   AMED_LAND       = 1 << 3,
00037   AMED_EXACTPOS   = 1 << 4,
00038   AMED_BRAKE      = 1 << 5,
00039   AMED_HELI_RAISE = 1 << 6,
00040   AMED_HELI_LOWER = 1 << 7,
00041   AMED_HOLD       = 1 << 8
00042 };
00043 
00044 /* Movement States on Airports (headings target) */
00045 enum {
00046   TO_ALL         =  0,
00047   HANGAR         =  1,
00048   TERM1          =  2,
00049   TERM2          =  3,
00050   TERM3          =  4,
00051   TERM4          =  5,
00052   TERM5          =  6,
00053   TERM6          =  7,
00054   HELIPAD1       =  8,
00055   HELIPAD2       =  9,
00056   TAKEOFF        = 10,
00057   STARTTAKEOFF   = 11,
00058   ENDTAKEOFF     = 12,
00059   HELITAKEOFF    = 13,
00060   FLYING         = 14,
00061   LANDING        = 15,
00062   ENDLANDING     = 16,
00063   HELILANDING    = 17,
00064   HELIENDLANDING = 18,
00065   TERM7          = 19,
00066   TERM8          = 20,
00067   HELIPAD3       = 21,
00068   HELIPAD4       = 22
00069 };
00070 
00071 /* Movement Blocks on Airports */
00072 // blocks (eg_airport_flags)
00073 static const uint64
00074   TERM1_block              = 1ULL <<  0,
00075   TERM2_block              = 1ULL <<  1,
00076   TERM3_block              = 1ULL <<  2,
00077   TERM4_block              = 1ULL <<  3,
00078   TERM5_block              = 1ULL <<  4,
00079   TERM6_block              = 1ULL <<  5,
00080   HELIPAD1_block           = 1ULL <<  6,
00081   HELIPAD2_block           = 1ULL <<  7,
00082   RUNWAY_IN_OUT_block      = 1ULL <<  8,
00083   RUNWAY_IN_block          = 1ULL <<  8,
00084   AIRPORT_BUSY_block       = 1ULL <<  8,
00085   RUNWAY_OUT_block         = 1ULL <<  9,
00086   TAXIWAY_BUSY_block       = 1ULL << 10,
00087   OUT_WAY_block            = 1ULL << 11,
00088   IN_WAY_block             = 1ULL << 12,
00089   AIRPORT_ENTRANCE_block   = 1ULL << 13,
00090   TERM_GROUP1_block        = 1ULL << 14,
00091   TERM_GROUP2_block        = 1ULL << 15,
00092   HANGAR2_AREA_block       = 1ULL << 16,
00093   TERM_GROUP2_ENTER1_block = 1ULL << 17,
00094   TERM_GROUP2_ENTER2_block = 1ULL << 18,
00095   TERM_GROUP2_EXIT1_block  = 1ULL << 19,
00096   TERM_GROUP2_EXIT2_block  = 1ULL << 20,
00097   PRE_HELIPAD_block        = 1ULL << 21,
00098 
00099 // blocks for new airports
00100   TERM7_block              = 1ULL << 22,
00101   TERM8_block              = 1ULL << 23,
00102   TERM9_block              = 1ULL << 24,
00103   HELIPAD3_block           = 1ULL << 24,
00104   TERM10_block             = 1ULL << 25,
00105   HELIPAD4_block           = 1ULL << 25,
00106   HANGAR1_AREA_block       = 1ULL << 26,
00107   OUT_WAY2_block           = 1ULL << 27,
00108   IN_WAY2_block            = 1ULL << 28,
00109   RUNWAY_IN2_block         = 1ULL << 29,
00110   RUNWAY_OUT2_block        = 1ULL << 10,   // note re-uses TAXIWAY_BUSY
00111   HELIPAD_GROUP_block      = 1ULL << 13,   // note re-uses AIRPORT_ENTRANCE
00112   OUT_WAY_block2           = 1ULL << 31,
00113 // end of new blocks
00114 
00115   NOTHING_block            = 1ULL << 30;
00116 
00117 struct AirportMovingData {
00118   int16 x;
00119   int16 y;
00120   uint16 flag;
00121   DirectionByte direction;
00122 };
00123 
00124 struct AirportFTAbuildup;
00125 
00126 // Finite sTate mAchine --> FTA
00127 struct AirportFTAClass {
00128   public:
00129     enum Flags {
00130       AIRPLANES   = 0x1,
00131       HELICOPTERS = 0x2,
00132       ALL         = AIRPLANES | HELICOPTERS,
00133       SHORT_STRIP = 0x4
00134     };
00135 
00136     AirportFTAClass(
00137       const AirportMovingData *moving_data,
00138       const byte *terminals,
00139       const byte *helipads,
00140       const byte *entry_points,
00141       Flags flags,
00142       const AirportFTAbuildup *apFA,
00143       const TileIndexDiffC *depots,
00144       byte nof_depots,
00145       uint size_x,
00146       uint size_y,
00147       byte delta_z,
00148       byte catchment
00149     );
00150 
00151     ~AirportFTAClass();
00152 
00153     const AirportMovingData *MovingData(byte position) const
00154     {
00155       assert(position < nofelements);
00156       return &moving_data[position];
00157     }
00158 
00159   const AirportMovingData *moving_data;
00160   struct AirportFTA *layout;            // state machine for airport
00161   const byte *terminals;
00162   const byte *helipads;
00163   const TileIndexDiffC *airport_depots; // gives the position of the depots on the airports
00164   Flags flags;
00165   byte nof_depots;                      // number of depots this airport has
00166   byte nofelements;                     // number of positions the airport consists of
00167   const byte *entry_points;             
00168   byte size_x;
00169   byte size_y;
00170   byte delta_z;                         // Z adjustment for helicopter pads
00171   byte catchment;
00172 };
00173 
00174 DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
00175 
00176 
00177 // internal structure used in openttd - Finite sTate mAchine --> FTA
00178 struct AirportFTA {
00179   AirportFTA *next;        // possible extra movement choices from this position
00180   uint64 block;            // 64 bit blocks (st->airport_flags), should be enough for the most complex airports
00181   byte position;           // the position that an airplane is at
00182   byte next_position;      // next position from this position
00183   byte heading;            // heading (current orders), guiding an airplane to its target on an airport
00184 };
00185 
00186 void InitializeAirports();
00187 void UnInitializeAirports();
00188 const AirportFTAClass *GetAirport(const byte airport_type);
00189 
00195 uint32 GetValidAirports();
00196 
00197 #endif /* AIRPORT_H */

Generated on Mon Sep 22 20:34:14 2008 for openttd by  doxygen 1.5.6