newgrf_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 NEWGRF_AIRPORT_H
00013 #define NEWGRF_AIRPORT_H
00014 
00015 #include "airport.h"
00016 #include "date_type.h"
00017 #include "map_type.h"
00018 #include "newgrf_class.h"
00019 #include "newgrf_commons.h"
00020 #include "gfx_type.h"
00021 
00023 typedef byte StationGfx;
00024 
00026 struct AirportTileTable {
00027   TileIndexDiffC ti; 
00028   StationGfx gfx;    
00029 };
00030 
00032 enum AirportClassID {
00033   APC_BEGIN     = 0,  
00034   APC_SMALL     = 0,  
00035   APC_LARGE,          
00036   APC_HUB,            
00037   APC_HELIPORT,       
00038   APC_MAX       = 16, 
00039 };
00040 
00042 DECLARE_POSTFIX_INCREMENT(AirportClassID)
00043 
00044 
00045 enum TTDPAirportType {
00046   ATP_TTDP_SMALL,    
00047   ATP_TTDP_LARGE,    
00048   ATP_TTDP_HELIPORT, 
00049   ATP_TTDP_OILRIG,   
00050 };
00051 
00053 struct HangarTileTable {
00054   TileIndexDiffC ti; 
00055   Direction dir;     
00056   byte hangar_num;   
00057 };
00058 
00062 struct AirportSpec {
00063   const struct AirportFTAClass *fsm;     
00064   const AirportTileTable * const *table; 
00065   Direction *rotation;                   
00066   byte num_table;                        
00067   const HangarTileTable *depot_table;    
00068   byte nof_depots;                       
00069   byte size_x;                           
00070   byte size_y;                           
00071   byte noise_level;                      
00072   byte catchment;                        
00073   Year min_year;                         
00074   Year max_year;                         
00075   StringID name;                         
00076   TTDPAirportType ttd_airport_type;      
00077   AirportClassID cls_id;                 
00078   SpriteID preview_sprite;               
00079   uint16 maintenance_cost;               
00080   /* Newgrf data */
00081   bool enabled;                          
00082   struct GRFFileProps grf_prop;          
00083 
00084   static const AirportSpec *Get(byte type);
00085   static AirportSpec *GetWithoutOverride(byte type);
00086 
00087   bool IsAvailable() const;
00088 
00089   static void ResetAirports();
00090 
00092   byte GetIndex() const
00093   {
00094     assert(this >= specs && this < endof(specs));
00095     return (byte)(this - specs);
00096   }
00097 
00098   static AirportSpec dummy; 
00099 
00100 private:
00101   static AirportSpec specs[NUM_AIRPORTS]; 
00102 };
00103 
00105 typedef NewGRFClass<AirportSpec, AirportClassID, APC_MAX> AirportClass;
00106 
00107 void BindAirportSpecs();
00108 
00109 StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback);
00110 
00111 #endif /* NEWGRF_AIRPORT_H */