# airport.h

Go to the documentation of this file.

    00001 /* $Id: airport.h 18912 2010-01-24 20:25:28Z yexo $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef AIRPORT_H
    00013 #define AIRPORT_H
    00014
    00015 #include "direction_type.h"
    00016 #include "map_type.h"
    00017 #include "date_type.h"
    00018
    00020 enum {
    00021   MAX_TERMINALS =  10,
    00022   MAX_HELIPADS  =   4,
    00023   MAX_ELEMENTS  = 255,
    00024   NUM_AIRPORTTILES = 74,
    00025 };
    00026
    00028 enum {
    00029   AT_SMALL         =   0,
    00030   AT_LARGE         =   1,
    00031   AT_HELIPORT      =   2,
    00032   AT_METROPOLITAN  =   3,
    00033   AT_INTERNATIONAL =   4,
    00034   AT_COMMUTER      =   5,
    00035   AT_HELIDEPOT     =   6,
    00036   AT_INTERCON      =   7,
    00037   AT_HELISTATION   =   8,
    00038   NUM_AIRPORTS     =   9,
    00039   AT_OILRIG        =  15,
    00040   AT_DUMMY         = 255
    00041 };
    00042
    00043 /* Copy from station_map.h */
    00044 typedef byte StationGfx;
    00045
    00046 struct AirportTileTable {
    00047   TileIndexDiffC ti;
    00048   StationGfx gfx;
    00049 };
    00050
    00054 struct AirportSpec {
    00055   const AirportTileTable * const *table;
    00056   const TileIndexDiffC *depot_table;
    00057   byte nof_depots;
    00058   byte size_x;
    00059   byte size_y;
    00060   byte noise_level;
    00061   byte catchment;
    00062   Year min_year;
    00063   Year max_year;
    00064
    00065   static const AirportSpec *Get(byte type);
    00066
    00067   bool IsAvailable() const;
    00068
    00069   static AirportSpec dummy;
    00070   static AirportSpec oilrig;
    00071 };
    00072
    00073
    00077 struct AirportTileSpec {
    00078   uint16 animation_info;
    00079   uint8 animation_speed;
    00080
    00081   static const AirportTileSpec *Get(StationGfx gfx);
    00082 };
    00083
    00084 enum {
    00085   AMED_NOSPDCLAMP = 1 << 0,
    00086   AMED_TAKEOFF    = 1 << 1,
    00087   AMED_SLOWTURN   = 1 << 2,
    00088   AMED_LAND       = 1 << 3,
    00089   AMED_EXACTPOS   = 1 << 4,
    00090   AMED_BRAKE      = 1 << 5,
    00091   AMED_HELI_RAISE = 1 << 6,
    00092   AMED_HELI_LOWER = 1 << 7,
    00093   AMED_HOLD       = 1 << 8
    00094 };
    00095
    00096 /* Movement States on Airports (headings target) */
    00097 enum {
    00098   TO_ALL         =  0,
    00099   HANGAR         =  1,
    00100   TERM1          =  2,
    00101   TERM2          =  3,
    00102   TERM3          =  4,
    00103   TERM4          =  5,
    00104   TERM5          =  6,
    00105   TERM6          =  7,
    00106   HELIPAD1       =  8,
    00107   HELIPAD2       =  9,
    00108   TAKEOFF        = 10,
    00109   STARTTAKEOFF   = 11,
    00110   ENDTAKEOFF     = 12,
    00111   HELITAKEOFF    = 13,
    00112   FLYING         = 14,
    00113   LANDING        = 15,
    00114   ENDLANDING     = 16,
    00115   HELILANDING    = 17,
    00116   HELIENDLANDING = 18,
    00117   TERM7          = 19,
    00118   TERM8          = 20,
    00119   HELIPAD3       = 21,
    00120   HELIPAD4       = 22,
    00121   MAX_HEADINGS   = 22,
    00122 };
    00123
    00124 /* Movement Blocks on Airports
    00125  * blocks (eg_airport_flags) */
    00126 static const uint64
    00127   TERM1_block              = 1ULL <<  0,
    00128   TERM2_block              = 1ULL <<  1,
    00129   TERM3_block              = 1ULL <<  2,
    00130   TERM4_block              = 1ULL <<  3,
    00131   TERM5_block              = 1ULL <<  4,
    00132   TERM6_block              = 1ULL <<  5,
    00133   HELIPAD1_block           = 1ULL <<  6,
    00134   HELIPAD2_block           = 1ULL <<  7,
    00135   RUNWAY_IN_OUT_block      = 1ULL <<  8,
    00136   RUNWAY_IN_block          = 1ULL <<  8,
    00137   AIRPORT_BUSY_block       = 1ULL <<  8,
    00138   RUNWAY_OUT_block         = 1ULL <<  9,
    00139   TAXIWAY_BUSY_block       = 1ULL << 10,
    00140   OUT_WAY_block            = 1ULL << 11,
    00141   IN_WAY_block             = 1ULL << 12,
    00142   AIRPORT_ENTRANCE_block   = 1ULL << 13,
    00143   TERM_GROUP1_block        = 1ULL << 14,
    00144   TERM_GROUP2_block        = 1ULL << 15,
    00145   HANGAR2_AREA_block       = 1ULL << 16,
    00146   TERM_GROUP2_ENTER1_block = 1ULL << 17,
    00147   TERM_GROUP2_ENTER2_block = 1ULL << 18,
    00148   TERM_GROUP2_EXIT1_block  = 1ULL << 19,
    00149   TERM_GROUP2_EXIT2_block  = 1ULL << 20,
    00150   PRE_HELIPAD_block        = 1ULL << 21,
    00151
    00152   /* blocks for new airports */
    00153   TERM7_block              = 1ULL << 22,
    00154   TERM8_block              = 1ULL << 23,
    00155   TERM9_block              = 1ULL << 24,
    00156   HELIPAD3_block           = 1ULL << 24,
    00157   TERM10_block             = 1ULL << 25,
    00158   HELIPAD4_block           = 1ULL << 25,
    00159   HANGAR1_AREA_block       = 1ULL << 26,
    00160   OUT_WAY2_block           = 1ULL << 27,
    00161   IN_WAY2_block            = 1ULL << 28,
    00162   RUNWAY_IN2_block         = 1ULL << 29,
    00163   RUNWAY_OUT2_block        = 1ULL << 10,
    00164   HELIPAD_GROUP_block      = 1ULL << 13,
    00165   OUT_WAY_block2           = 1ULL << 31,
    00166   /* end of new blocks */
    00167
    00168   NOTHING_block            = 1ULL << 30;
    00169
    00170 struct AirportMovingData {
    00171   int16 x;
    00172   int16 y;
    00173   uint16 flag;
    00174   DirectionByte direction;
    00175 };
    00176
    00177 struct AirportFTAbuildup;
    00178
    00180 struct AirportFTAClass {
    00181 public:
    00182   enum Flags {
    00183     AIRPLANES   = 0x1,
    00184     HELICOPTERS = 0x2,
    00185     ALL         = AIRPLANES | HELICOPTERS,
    00186     SHORT_STRIP = 0x4
    00187   };
    00188
    00189   AirportFTAClass(
    00190     const AirportMovingData *moving_data,
    00191     const byte *terminals,
    00192     const byte *helipads,
    00193     const byte *entry_points,
    00194     Flags flags,
    00195     const AirportFTAbuildup *apFA,
    00196     byte delta_z
    00197   );
    00198
    00199   ~AirportFTAClass();
    00200
    00201   const AirportMovingData *MovingData(byte position) const
    00202   {
    00203     assert(position < nofelements);
    00204     return &moving_data[position];
    00205   }
    00206
    00207   const AirportMovingData *moving_data;
    00208   struct AirportFTA *layout;
    00209   const byte *terminals;
    00210   const byte *helipads;
    00211   Flags flags;
    00212   byte nofelements;
    00213   const byte *entry_points;
    00214   byte delta_z;
    00215 };
    00216
    00217 DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
    00218
    00219
    00220
    00221 struct AirportFTA {
    00222   AirportFTA *next;
    00223   uint64 block;
    00224   byte position;
    00225   byte next_position;
    00226   byte heading;
    00227 };
    00228
    00229 void InitializeAirports();
    00230 void UnInitializeAirports();
    00231 const AirportFTAClass *GetAirport(const byte airport_type);
    00232
    00233 extern const byte * const _airport_sections[];
    00234
    00235 #endif /* AIRPORT_H */