Remove OrthogonalTileIteratorStep

Step sizes other than 1 are no longer used
This commit is contained in:
Jonathan G Rennison
2021-11-03 02:26:08 +00:00
parent f9e3c012f6
commit 1174b0c53f

View File

@@ -15,7 +15,7 @@
#include "map_func.h" #include "map_func.h"
#include <tuple> #include <tuple>
template<uint N> class OrthogonalTileIteratorStep; class OrthogonalTileIterator;
/** Represents the covered area of e.g. a rail station */ /** Represents the covered area of e.g. a rail station */
struct OrthogonalTileArea { struct OrthogonalTileArea {
@@ -69,9 +69,9 @@ struct OrthogonalTileArea {
return std::tie(tile, w, h) == std::tie(other.tile, other.w, other.h); 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. */ /** Represents a diagonal tile area. */
@@ -158,8 +158,7 @@ public:
}; };
/** Iterator to iterate over a tile area (rectangle) of the map. */ /** Iterator to iterate over a tile area (rectangle) of the map. */
template<uint N> class OrthogonalTileIterator : public TileIterator {
class OrthogonalTileIteratorStep : public TileIterator {
private: private:
int w; ///< The width of the iterated area. int w; ///< The width of the iterated area.
int x; ///< The current 'x' position in the rectangle. int x; ///< The current 'x' position in the rectangle.
@@ -170,7 +169,7 @@ public:
* Construct the iterator. * Construct the iterator.
* @param ta Area, i.e. begin point and width/height of to-be-iterated area. * @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 corner1 Tile from where to begin iterating.
* @param corner2 Tile where to end the 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); assert(this->tile != INVALID_TILE);
if (--this->x > 0) { if (--this->x > 0) {
this->tile += N; this->tile++;
} else if (--this->y > 0) { } else if (--this->y > 0) {
this->x = this->w; this->x = this->w;
this->tile += TileDiffXY(N, N) - (N * this->w); this->tile += TileDiffXY(1, 1) - this->w;
} else { } else {
this->tile = INVALID_TILE; this->tile = INVALID_TILE;
} }
@@ -204,12 +203,10 @@ public:
virtual TileIterator *Clone() const 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. /** Iterator to iterate over a tile area (rectangle) of the map.
* It prefetches tiles once per row. * It prefetches tiles once per row.
*/ */