# newgrf_airport.h

Go to the documentation of this file.

    00001 /* $Id: newgrf_airport.h 25705 2013-08-09 18:43:44Z rubidium $ */
    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 "newgrf_class.h"
    00018 #include "newgrf_commons.h"
    00019 #include "tilearea_type.h"
    00020
    00022 typedef byte StationGfx;
    00023
    00025 struct AirportTileTable {
    00026   TileIndexDiffC ti;
    00027   StationGfx gfx;
    00028 };
    00029
    00031 class AirportTileTableIterator : public TileIterator {
    00032 private:
    00033   const AirportTileTable *att;
    00034   TileIndex base_tile;
    00035
    00036 public:
    00042   AirportTileTableIterator(const AirportTileTable *att, TileIndex base_tile) : TileIterator(base_tile + ToTileIndexDiff(att->ti)), att(att), base_tile(base_tile)
    00043   {
    00044   }
    00045
    00046   inline TileIterator& operator ++()
    00047   {
    00048     this->att++;
    00049     if (this->att->ti.x == -0x80) {
    00050       this->tile = INVALID_TILE;
    00051     } else {
    00052       this->tile = this->base_tile + ToTileIndexDiff(this->att->ti);
    00053     }
    00054     return *this;
    00055   }
    00056
    00058   StationGfx GetStationGfx() const
    00059   {
    00060     return this->att->gfx;
    00061   }
    00062
    00063   virtual AirportTileTableIterator *Clone() const
    00064   {
    00065     return new AirportTileTableIterator(*this);
    00066   }
    00067 };
    00068
    00070 enum AirportClassID {
    00071   APC_BEGIN     = 0,
    00072   APC_SMALL     = 0,
    00073   APC_LARGE,
    00074   APC_HUB,
    00075   APC_HELIPORT,
    00076   APC_MAX       = 16,
    00077 };
    00078
    00080 DECLARE_POSTFIX_INCREMENT(AirportClassID)
    00081
    00082
    00083 enum TTDPAirportType {
    00084   ATP_TTDP_SMALL,
    00085   ATP_TTDP_LARGE,
    00086   ATP_TTDP_HELIPORT,
    00087   ATP_TTDP_OILRIG,
    00088 };
    00089
    00091 struct HangarTileTable {
    00092   TileIndexDiffC ti;
    00093   Direction dir;
    00094   byte hangar_num;
    00095 };
    00096
    00100 struct AirportSpec {
    00101   const struct AirportFTAClass *fsm;
    00102   const AirportTileTable * const *table;
    00103   Direction *rotation;
    00104   byte num_table;
    00105   const HangarTileTable *depot_table;
    00106   byte nof_depots;
    00107   byte size_x;
    00108   byte size_y;
    00109   byte noise_level;
    00110   byte catchment;
    00111   Year min_year;
    00112   Year max_year;
    00113   StringID name;
    00114   TTDPAirportType ttd_airport_type;
    00115   AirportClassID cls_id;
    00116   SpriteID preview_sprite;
    00117   uint16 maintenance_cost;
    00118   /* Newgrf data */
    00119   bool enabled;
    00120   struct GRFFileProps grf_prop;
    00121
    00122   static const AirportSpec *Get(byte type);
    00123   static AirportSpec *GetWithoutOverride(byte type);
    00124
    00125   bool IsAvailable() const;
    00126
    00127   static void ResetAirports();
    00128
    00130   byte GetIndex() const
    00131   {
    00132     assert(this >= specs && this < endof(specs));
    00133     return (byte)(this - specs);
    00134   }
    00135
    00136   static AirportSpec dummy;
    00137
    00138 private:
    00139   static AirportSpec specs[NUM_AIRPORTS];
    00140 };
    00141
    00143 typedef NewGRFClass<AirportSpec, AirportClassID, APC_MAX> AirportClass;
    00144
    00145 void BindAirportSpecs();
    00146
    00147 StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback);
    00148
    00149 #endif /* NEWGRF_AIRPORT_H */