diff options
Diffstat (limited to 'src/station_base.h')
-rw-r--r-- | src/station_base.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/station_base.h b/src/station_base.h index 2a7fedbf7..5ec337f56 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -17,6 +17,7 @@ #include "cargopacket.h" #include "industry_type.h" #include "newgrf_storage.h" +#include "town.h" typedef Pool<BaseStation, StationID, 32, 64000> StationPool; extern StationPool _station_pool; @@ -261,4 +262,34 @@ public: #define FOR_ALL_STATIONS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Station, var) +/** Iterator to iterate over all tiles belonging to an airport. */ +class AirportTileIterator : public OrthogonalTileIterator { +private: + const Station *st; ///< The station the airport is a part of. + +public: + /** + * Construct the iterator. + * @param ta Area, i.e. begin point and width/height of to-be-iterated area. + */ + AirportTileIterator(const Station *st) : OrthogonalTileIterator(st->airport), st(st) + { + if (!st->TileBelongsToAirport(this->tile)) ++(*this); + } + + FORCEINLINE TileIterator& operator ++() + { + (*this).OrthogonalTileIterator::operator++(); + while (this->tile != INVALID_TILE && !st->TileBelongsToAirport(this->tile)) { + (*this).OrthogonalTileIterator::operator++(); + } + return *this; + } + + virtual TileIterator *Clone() const + { + return new AirportTileIterator(*this); + } +}; + #endif /* STATION_BASE_H */ |