From 1174b0c53fe05bfc3198b7a68d9d11364cc1e434 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 3 Nov 2021 02:26:08 +0000 Subject: [PATCH] Remove OrthogonalTileIteratorStep Step sizes other than 1 are no longer used --- src/tilearea_type.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/tilearea_type.h b/src/tilearea_type.h index d4d585d7e4..dd6ef8d0c3 100644 --- a/src/tilearea_type.h +++ b/src/tilearea_type.h @@ -15,7 +15,7 @@ #include "map_func.h" #include -template class OrthogonalTileIteratorStep; +class OrthogonalTileIterator; /** Represents the covered area of e.g. a rail station */ struct OrthogonalTileArea { @@ -69,9 +69,9 @@ struct OrthogonalTileArea { return std::tie(tile, w, h) == std::tie(other.tile, other.w, other.h); } - OrthogonalTileIteratorStep<1> begin() const; + OrthogonalTileIterator begin() const; - OrthogonalTileIteratorStep<1> end() const; + OrthogonalTileIterator end() const; }; /** Represents a diagonal tile area. */ @@ -158,8 +158,7 @@ public: }; /** Iterator to iterate over a tile area (rectangle) of the map. */ -template -class OrthogonalTileIteratorStep : public TileIterator { +class OrthogonalTileIterator : public TileIterator { private: int w; ///< The width of the iterated area. int x; ///< The current 'x' position in the rectangle. @@ -170,7 +169,7 @@ public: * Construct the iterator. * @param ta Area, i.e. begin point and width/height of to-be-iterated area. */ - OrthogonalTileIteratorStep(const OrthogonalTileArea &ta) : TileIterator(ta.w == 0 || ta.h == 0 ? INVALID_TILE : ta.tile), w(ta.w / N), x(ta.w / N), y(ta.h / N) + OrthogonalTileIterator(const OrthogonalTileArea &ta) : TileIterator(ta.w == 0 || ta.h == 0 ? INVALID_TILE : ta.tile), w(ta.w), x(ta.w), y(ta.h) { } @@ -179,9 +178,9 @@ public: * @param corner1 Tile from where to begin iterating. * @param corner2 Tile where to end the iterating. */ - OrthogonalTileIteratorStep(TileIndex corner1, TileIndex corner2) + OrthogonalTileIterator(TileIndex corner1, TileIndex corner2) { - *this = OrthogonalTileIteratorStep(OrthogonalTileArea(corner1, corner2)); + *this = OrthogonalTileIterator(OrthogonalTileArea(corner1, corner2)); } /** @@ -192,10 +191,10 @@ public: assert(this->tile != INVALID_TILE); if (--this->x > 0) { - this->tile += N; + this->tile++; } else if (--this->y > 0) { this->x = this->w; - this->tile += TileDiffXY(N, N) - (N * this->w); + this->tile += TileDiffXY(1, 1) - this->w; } else { this->tile = INVALID_TILE; } @@ -204,12 +203,10 @@ public: virtual TileIterator *Clone() const { - return new OrthogonalTileIteratorStep(*this); + return new OrthogonalTileIterator(*this); } }; -using OrthogonalTileIterator = class OrthogonalTileIteratorStep<1>; - /** Iterator to iterate over a tile area (rectangle) of the map. * It prefetches tiles once per row. */