# airport.h

Go to the documentation of this file.

    00001 /* $Id$ */
    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 "tile_type.h"
    00018 #include "date_type.h"
    00019
    00021 enum {
    00022   MAX_TERMINALS =  10,
    00023   MAX_HELIPADS  =   4,
    00024   MAX_ELEMENTS  = 255,
    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
    00044 enum {
    00045   AMED_NOSPDCLAMP = 1 << 0,
    00046   AMED_TAKEOFF    = 1 << 1,
    00047   AMED_SLOWTURN   = 1 << 2,
    00048   AMED_LAND       = 1 << 3,
    00049   AMED_EXACTPOS   = 1 << 4,
    00050   AMED_BRAKE      = 1 << 5,
    00051   AMED_HELI_RAISE = 1 << 6,
    00052   AMED_HELI_LOWER = 1 << 7,
    00053   AMED_HOLD       = 1 << 8
    00054 };
    00055
    00056 /* Movement States on Airports (headings target) */
    00057 enum {
    00058   TO_ALL         =  0,
    00059   HANGAR         =  1,
    00060   TERM1          =  2,
    00061   TERM2          =  3,
    00062   TERM3          =  4,
    00063   TERM4          =  5,
    00064   TERM5          =  6,
    00065   TERM6          =  7,
    00066   HELIPAD1       =  8,
    00067   HELIPAD2       =  9,
    00068   TAKEOFF        = 10,
    00069   STARTTAKEOFF   = 11,
    00070   ENDTAKEOFF     = 12,
    00071   HELITAKEOFF    = 13,
    00072   FLYING         = 14,
    00073   LANDING        = 15,
    00074   ENDLANDING     = 16,
    00075   HELILANDING    = 17,
    00076   HELIENDLANDING = 18,
    00077   TERM7          = 19,
    00078   TERM8          = 20,
    00079   HELIPAD3       = 21,
    00080   HELIPAD4       = 22,
    00081   MAX_HEADINGS   = 22,
    00082 };
    00083
    00084 /* Movement Blocks on Airports
    00085  * blocks (eg_airport_flags) */
    00086 static const uint64
    00087   TERM1_block              = 1ULL <<  0,
    00088   TERM2_block              = 1ULL <<  1,
    00089   TERM3_block              = 1ULL <<  2,
    00090   TERM4_block              = 1ULL <<  3,
    00091   TERM5_block              = 1ULL <<  4,
    00092   TERM6_block              = 1ULL <<  5,
    00093   HELIPAD1_block           = 1ULL <<  6,
    00094   HELIPAD2_block           = 1ULL <<  7,
    00095   RUNWAY_IN_OUT_block      = 1ULL <<  8,
    00096   RUNWAY_IN_block          = 1ULL <<  8,
    00097   AIRPORT_BUSY_block       = 1ULL <<  8,
    00098   RUNWAY_OUT_block         = 1ULL <<  9,
    00099   TAXIWAY_BUSY_block       = 1ULL << 10,
    00100   OUT_WAY_block            = 1ULL << 11,
    00101   IN_WAY_block             = 1ULL << 12,
    00102   AIRPORT_ENTRANCE_block   = 1ULL << 13,
    00103   TERM_GROUP1_block        = 1ULL << 14,
    00104   TERM_GROUP2_block        = 1ULL << 15,
    00105   HANGAR2_AREA_block       = 1ULL << 16,
    00106   TERM_GROUP2_ENTER1_block = 1ULL << 17,
    00107   TERM_GROUP2_ENTER2_block = 1ULL << 18,
    00108   TERM_GROUP2_EXIT1_block  = 1ULL << 19,
    00109   TERM_GROUP2_EXIT2_block  = 1ULL << 20,
    00110   PRE_HELIPAD_block        = 1ULL << 21,
    00111
    00112   /* blocks for new airports */
    00113   TERM7_block              = 1ULL << 22,
    00114   TERM8_block              = 1ULL << 23,
    00115   TERM9_block              = 1ULL << 24,
    00116   HELIPAD3_block           = 1ULL << 24,
    00117   TERM10_block             = 1ULL << 25,
    00118   HELIPAD4_block           = 1ULL << 25,
    00119   HANGAR1_AREA_block       = 1ULL << 26,
    00120   OUT_WAY2_block           = 1ULL << 27,
    00121   IN_WAY2_block            = 1ULL << 28,
    00122   RUNWAY_IN2_block         = 1ULL << 29,
    00123   RUNWAY_OUT2_block        = 1ULL << 10,
    00124   HELIPAD_GROUP_block      = 1ULL << 13,
    00125   OUT_WAY_block2           = 1ULL << 31,
    00126   /* end of new blocks */
    00127
    00128   NOTHING_block            = 1ULL << 30;
    00129
    00130 struct AirportMovingData {
    00131   int16 x;
    00132   int16 y;
    00133   uint16 flag;
    00134   DirectionByte direction;
    00135 };
    00136
    00137 struct AirportFTAbuildup;
    00138
    00140 struct AirportFTAClass {
    00141 public:
    00142   enum Flags {
    00143     AIRPLANES   = 0x1,
    00144     HELICOPTERS = 0x2,
    00145     ALL         = AIRPLANES | HELICOPTERS,
    00146     SHORT_STRIP = 0x4
    00147   };
    00148
    00149   AirportFTAClass(
    00150     const AirportMovingData *moving_data,
    00151     const byte *terminals,
    00152     const byte *helipads,
    00153     const byte *entry_points,
    00154     Flags flags,
    00155     const AirportFTAbuildup *apFA,
    00156     const TileIndexDiffC *depots,
    00157     byte nof_depots,
    00158     uint size_x,
    00159     uint size_y,
    00160     uint8 noise_level,
    00161     byte delta_z,
    00162     byte catchment,
    00163     Year first_available,
    00164     Year last_available
    00165   );
    00166
    00167   ~AirportFTAClass();
    00168
    00169   const AirportMovingData *MovingData(byte position) const
    00170   {
    00171     assert(position < nofelements);
    00172     return &moving_data[position];
    00173   }
    00174
    00176   bool IsAvailable() const;
    00177
    00178   const AirportMovingData *moving_data;
    00179   struct AirportFTA *layout;
    00180   const byte *terminals;
    00181   const byte *helipads;
    00182   const TileIndexDiffC *airport_depots;
    00183   Flags flags;
    00184   byte nof_depots;
    00185   byte nofelements;
    00186   const byte *entry_points;
    00187   byte size_x;
    00188   byte size_y;
    00189   uint8 noise_level;
    00190   byte delta_z;
    00191   byte catchment;
    00192   Year first_available;
    00193   Year last_available;
    00194 };
    00195
    00196 DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
    00197
    00198
    00199
    00200 struct AirportFTA {
    00201   AirportFTA *next;
    00202   uint64 block;
    00203   byte position;
    00204   byte next_position;
    00205   byte heading;
    00206 };
    00207
    00208 void InitializeAirports();
    00209 void UnInitializeAirports();
    00210 const AirportFTAClass *GetAirport(const byte airport_type);
    00211
    00212 extern const byte * const _airport_sections[];
    00213
    00214 #endif /* AIRPORT_H */