# airport.h

Go to the documentation of this file.

    00001 /* $Id: airport.h 25841 2013-10-12 16:34:59Z frosch $ */
    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 "tile_type.h"
    00017
    00019 static const uint MAX_TERMINALS =   8;
    00020 static const uint MAX_HELIPADS  =   3;
    00021 static const uint MAX_ELEMENTS  = 255;
    00022
    00023 static const uint NUM_AIRPORTTILES_PER_GRF = 255;
    00024
    00025 static const uint NUM_AIRPORTTILES       = 256;
    00026 static const uint NEW_AIRPORTTILE_OFFSET = 74;
    00027 static const uint INVALID_AIRPORTTILE    = NUM_AIRPORTTILES;
    00028
    00030 enum AirportTypes {
    00031   AT_SMALL           =   0,
    00032   AT_LARGE           =   1,
    00033   AT_HELIPORT        =   2,
    00034   AT_METROPOLITAN    =   3,
    00035   AT_INTERNATIONAL   =   4,
    00036   AT_COMMUTER        =   5,
    00037   AT_HELIDEPOT       =   6,
    00038   AT_INTERCON        =   7,
    00039   AT_HELISTATION     =   8,
    00040   AT_OILRIG          =   9,
    00041   NEW_AIRPORT_OFFSET =  10,
    00042   NUM_AIRPORTS_PER_GRF = 128,
    00043   NUM_AIRPORTS       = 128,
    00044   AT_INVALID         = 254,
    00045   AT_DUMMY           = 255,
    00046 };
    00047
    00049 enum AirportMovingDataFlags {
    00050   AMED_NOSPDCLAMP = 1 << 0,
    00051   AMED_TAKEOFF    = 1 << 1,
    00052   AMED_SLOWTURN   = 1 << 2,
    00053   AMED_LAND       = 1 << 3,
    00054   AMED_EXACTPOS   = 1 << 4,
    00055   AMED_BRAKE      = 1 << 5,
    00056   AMED_HELI_RAISE = 1 << 6,
    00057   AMED_HELI_LOWER = 1 << 7,
    00058   AMED_HOLD       = 1 << 8,
    00059 };
    00060
    00062 enum AirportMovementStates {
    00063   TO_ALL         =  0,
    00064   HANGAR         =  1,
    00065   TERM1          =  2,
    00066   TERM2          =  3,
    00067   TERM3          =  4,
    00068   TERM4          =  5,
    00069   TERM5          =  6,
    00070   TERM6          =  7,
    00071   HELIPAD1       =  8,
    00072   HELIPAD2       =  9,
    00073   TAKEOFF        = 10,
    00074   STARTTAKEOFF   = 11,
    00075   ENDTAKEOFF     = 12,
    00076   HELITAKEOFF    = 13,
    00077   FLYING         = 14,
    00078   LANDING        = 15,
    00079   ENDLANDING     = 16,
    00080   HELILANDING    = 17,
    00081   HELIENDLANDING = 18,
    00082   TERM7          = 19,
    00083   TERM8          = 20,
    00084   HELIPAD3       = 21,
    00085   MAX_HEADINGS   = 21,
    00086 };
    00087
    00089 static const uint64
    00090   TERM1_block              = 1ULL <<  0,
    00091   TERM2_block              = 1ULL <<  1,
    00092   TERM3_block              = 1ULL <<  2,
    00093   TERM4_block              = 1ULL <<  3,
    00094   TERM5_block              = 1ULL <<  4,
    00095   TERM6_block              = 1ULL <<  5,
    00096   HELIPAD1_block           = 1ULL <<  6,
    00097   HELIPAD2_block           = 1ULL <<  7,
    00098   RUNWAY_IN_OUT_block      = 1ULL <<  8,
    00099   RUNWAY_IN_block          = 1ULL <<  8,
    00100   AIRPORT_BUSY_block       = 1ULL <<  8,
    00101   RUNWAY_OUT_block         = 1ULL <<  9,
    00102   TAXIWAY_BUSY_block       = 1ULL << 10,
    00103   OUT_WAY_block            = 1ULL << 11,
    00104   IN_WAY_block             = 1ULL << 12,
    00105   AIRPORT_ENTRANCE_block   = 1ULL << 13,
    00106   TERM_GROUP1_block        = 1ULL << 14,
    00107   TERM_GROUP2_block        = 1ULL << 15,
    00108   HANGAR2_AREA_block       = 1ULL << 16,
    00109   TERM_GROUP2_ENTER1_block = 1ULL << 17,
    00110   TERM_GROUP2_ENTER2_block = 1ULL << 18,
    00111   TERM_GROUP2_EXIT1_block  = 1ULL << 19,
    00112   TERM_GROUP2_EXIT2_block  = 1ULL << 20,
    00113   PRE_HELIPAD_block        = 1ULL << 21,
    00114
    00115   /* blocks for new airports */
    00116   TERM7_block              = 1ULL << 22,
    00117   TERM8_block              = 1ULL << 23,
    00118   HELIPAD3_block           = 1ULL << 24,
    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   AIRPORT_CLOSED_block     = 1ULL << 63;
    00130
    00132 struct AirportMovingData {
    00133   int16 x;
    00134   int16 y;
    00135   uint16 flag;
    00136   DirectionByte direction;
    00137 };
    00138
    00139 AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Direction rotation, uint num_tiles_x, uint num_tiles_y);
    00140
    00141 struct AirportFTAbuildup;
    00142
    00144 struct AirportFTAClass {
    00145 public:
    00147   enum Flags {
    00148     AIRPLANES   = 0x1,
    00149     HELICOPTERS = 0x2,
    00150     ALL         = AIRPLANES | HELICOPTERS,
    00151     SHORT_STRIP = 0x4,
    00152   };
    00153
    00154   AirportFTAClass(
    00155     const AirportMovingData *moving_data,
    00156     const byte *terminals,
    00157     const byte num_helipads,
    00158     const byte *entry_points,
    00159     Flags flags,
    00160     const AirportFTAbuildup *apFA,
    00161     byte delta_z
    00162   );
    00163
    00164   ~AirportFTAClass();
    00165
    00171   const AirportMovingData *MovingData(byte position) const
    00172   {
    00173     assert(position < nofelements);
    00174     return &moving_data[position];
    00175   }
    00176
    00177   const AirportMovingData *moving_data;
    00178   struct AirportFTA *layout;
    00179   const byte *terminals;
    00180   const byte num_helipads;
    00181   Flags flags;
    00182   byte nofelements;
    00183   const byte *entry_points;
    00184   byte delta_z;
    00185 };
    00186
    00187 DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
    00188
    00189
    00190
    00191 struct AirportFTA {
    00192   AirportFTA *next;
    00193   uint64 block;
    00194   byte position;
    00195   byte next_position;
    00196   byte heading;
    00197 };
    00198
    00199 const AirportFTAClass *GetAirport(const byte airport_type);
    00200 byte GetVehiclePosOnBuild(TileIndex hangar_tile);
    00201
    00202 #endif /* AIRPORT_H */