airport.h

Go to the documentation of this file.
00001 /* $Id: airport.h 18845 2010-01-17 14:22:07Z 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 = 144, 
00025 };
00026 
00027 enum {
00028   AIRPORTTILE_NOANIM    = 0xFF, 
00029 };
00030 
00032 enum {
00033   AT_SMALL         =   0,
00034   AT_LARGE         =   1,
00035   AT_HELIPORT      =   2,
00036   AT_METROPOLITAN  =   3,
00037   AT_INTERNATIONAL =   4,
00038   AT_COMMUTER      =   5,
00039   AT_HELIDEPOT     =   6,
00040   AT_INTERCON      =   7,
00041   AT_HELISTATION   =   8,
00042   NUM_AIRPORTS     =   9,
00043   AT_OILRIG        =  15,
00044   AT_DUMMY         = 255
00045 };
00046 
00047 /* Copy from station_map.h */
00048 typedef byte StationGfx;
00049 
00050 struct AirportTileTable {
00051   TileIndexDiffC ti;
00052   StationGfx gfx;
00053 };
00054 
00058 struct AirportSpec {
00059   const AirportTileTable * const *table; 
00060   const TileIndexDiffC *depot_table;     
00061   byte nof_depots;                       
00062   byte size_x;                           
00063   byte size_y;                           
00064   byte noise_level;                      
00065   byte catchment;                        
00066   Year min_year;                         
00067   Year max_year;                         
00068 
00069   static const AirportSpec *Get(byte type);
00070 
00071   bool IsAvailable() const;
00072 
00073   static AirportSpec dummy;
00074   static AirportSpec oilrig;
00075 };
00076 
00077 
00081 struct AirportTileSpec {
00082   StationGfx anim_next;                 
00083   uint8 animation_speed;                
00084 
00085   static const AirportTileSpec *Get(StationGfx gfx);
00086 };
00087 
00088 enum {
00089   AMED_NOSPDCLAMP = 1 << 0,
00090   AMED_TAKEOFF    = 1 << 1,
00091   AMED_SLOWTURN   = 1 << 2,
00092   AMED_LAND       = 1 << 3,
00093   AMED_EXACTPOS   = 1 << 4,
00094   AMED_BRAKE      = 1 << 5,
00095   AMED_HELI_RAISE = 1 << 6,
00096   AMED_HELI_LOWER = 1 << 7,
00097   AMED_HOLD       = 1 << 8
00098 };
00099 
00100 /* Movement States on Airports (headings target) */
00101 enum {
00102   TO_ALL         =  0,
00103   HANGAR         =  1,
00104   TERM1          =  2,
00105   TERM2          =  3,
00106   TERM3          =  4,
00107   TERM4          =  5,
00108   TERM5          =  6,
00109   TERM6          =  7,
00110   HELIPAD1       =  8,
00111   HELIPAD2       =  9,
00112   TAKEOFF        = 10,
00113   STARTTAKEOFF   = 11,
00114   ENDTAKEOFF     = 12,
00115   HELITAKEOFF    = 13,
00116   FLYING         = 14,
00117   LANDING        = 15,
00118   ENDLANDING     = 16,
00119   HELILANDING    = 17,
00120   HELIENDLANDING = 18,
00121   TERM7          = 19,
00122   TERM8          = 20,
00123   HELIPAD3       = 21,
00124   HELIPAD4       = 22,
00125   MAX_HEADINGS   = 22,
00126 };
00127 
00128 /* Movement Blocks on Airports
00129  * blocks (eg_airport_flags) */
00130 static const uint64
00131   TERM1_block              = 1ULL <<  0,
00132   TERM2_block              = 1ULL <<  1,
00133   TERM3_block              = 1ULL <<  2,
00134   TERM4_block              = 1ULL <<  3,
00135   TERM5_block              = 1ULL <<  4,
00136   TERM6_block              = 1ULL <<  5,
00137   HELIPAD1_block           = 1ULL <<  6,
00138   HELIPAD2_block           = 1ULL <<  7,
00139   RUNWAY_IN_OUT_block      = 1ULL <<  8,
00140   RUNWAY_IN_block          = 1ULL <<  8,
00141   AIRPORT_BUSY_block       = 1ULL <<  8,
00142   RUNWAY_OUT_block         = 1ULL <<  9,
00143   TAXIWAY_BUSY_block       = 1ULL << 10,
00144   OUT_WAY_block            = 1ULL << 11,
00145   IN_WAY_block             = 1ULL << 12,
00146   AIRPORT_ENTRANCE_block   = 1ULL << 13,
00147   TERM_GROUP1_block        = 1ULL << 14,
00148   TERM_GROUP2_block        = 1ULL << 15,
00149   HANGAR2_AREA_block       = 1ULL << 16,
00150   TERM_GROUP2_ENTER1_block = 1ULL << 17,
00151   TERM_GROUP2_ENTER2_block = 1ULL << 18,
00152   TERM_GROUP2_EXIT1_block  = 1ULL << 19,
00153   TERM_GROUP2_EXIT2_block  = 1ULL << 20,
00154   PRE_HELIPAD_block        = 1ULL << 21,
00155 
00156   /* blocks for new airports */
00157   TERM7_block              = 1ULL << 22,
00158   TERM8_block              = 1ULL << 23,
00159   TERM9_block              = 1ULL << 24,
00160   HELIPAD3_block           = 1ULL << 24,
00161   TERM10_block             = 1ULL << 25,
00162   HELIPAD4_block           = 1ULL << 25,
00163   HANGAR1_AREA_block       = 1ULL << 26,
00164   OUT_WAY2_block           = 1ULL << 27,
00165   IN_WAY2_block            = 1ULL << 28,
00166   RUNWAY_IN2_block         = 1ULL << 29,
00167   RUNWAY_OUT2_block        = 1ULL << 10,   
00168   HELIPAD_GROUP_block      = 1ULL << 13,   
00169   OUT_WAY_block2           = 1ULL << 31,
00170   /* end of new blocks */
00171 
00172   NOTHING_block            = 1ULL << 30;
00173 
00174 struct AirportMovingData {
00175   int16 x;
00176   int16 y;
00177   uint16 flag;
00178   DirectionByte direction;
00179 };
00180 
00181 struct AirportFTAbuildup;
00182 
00184 struct AirportFTAClass {
00185 public:
00186   enum Flags {
00187     AIRPLANES   = 0x1,
00188     HELICOPTERS = 0x2,
00189     ALL         = AIRPLANES | HELICOPTERS,
00190     SHORT_STRIP = 0x4
00191   };
00192 
00193   AirportFTAClass(
00194     const AirportMovingData *moving_data,
00195     const byte *terminals,
00196     const byte *helipads,
00197     const byte *entry_points,
00198     Flags flags,
00199     const AirportFTAbuildup *apFA,
00200     byte delta_z
00201   );
00202 
00203   ~AirportFTAClass();
00204 
00205   const AirportMovingData *MovingData(byte position) const
00206   {
00207     assert(position < nofelements);
00208     return &moving_data[position];
00209   }
00210 
00211   const AirportMovingData *moving_data;
00212   struct AirportFTA *layout;            
00213   const byte *terminals;
00214   const byte *helipads;
00215   Flags flags;
00216   byte nofelements;                     
00217   const byte *entry_points;             
00218   byte delta_z;                         
00219 };
00220 
00221 DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
00222 
00223 
00224 
00225 struct AirportFTA {
00226   AirportFTA *next;        
00227   uint64 block;            
00228   byte position;           
00229   byte next_position;      
00230   byte heading;            
00231 };
00232 
00233 void InitializeAirports();
00234 void UnInitializeAirports();
00235 const AirportFTAClass *GetAirport(const byte airport_type);
00236 
00237 extern const byte * const _airport_sections[];
00238 
00239 #endif /* AIRPORT_H */

Generated on Wed Jan 20 23:38:34 2010 for OpenTTD by  doxygen 1.5.6