diff options
Diffstat (limited to 'src/newgrf_airport.h')
-rw-r--r-- | src/newgrf_airport.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h index b00c3667c..ca2ce1576 100644 --- a/src/newgrf_airport.h +++ b/src/newgrf_airport.h @@ -18,6 +18,7 @@ #include "newgrf_class.h" #include "newgrf_commons.h" #include "gfx_type.h" +#include "tilearea_type.h" /** Copy from station_map.h */ typedef byte StationGfx; @@ -28,6 +29,39 @@ struct AirportTileTable { StationGfx gfx; ///< AirportTile to use for this tile. }; +/** Iterator to iterate over all tiles belonging to an airport spec. */ +class AirportTileTableIterator : public TileIterator { +private: + const AirportTileTable *att; ///< The offsets. + TileIndex base_tile; ///< The tile we base the offsets off. + +public: + /** + * Construct the iterator. + * @param att The TileTable we want to iterate over. + * @param base_tile The basetile for all offsets. + */ + AirportTileTableIterator(const AirportTileTable *att, TileIndex base_tile) : TileIterator(base_tile + ToTileIndexDiff(att->ti)), att(att), base_tile(base_tile) + { + } + + FORCEINLINE TileIterator& operator ++() + { + this->att++; + if (this->att->ti.x == -0x80) { + this->tile = INVALID_TILE; + } else { + this->tile = base_tile + ToTileIndexDiff(att->ti); + } + return *this; + } + + virtual AirportTileTableIterator *Clone() const + { + return new AirportTileTableIterator(*this); + } +}; + /** List of default airport classes. */ enum AirportClassID { APC_BEGIN = 0, ///< Lowest valid airport class id |