Remove OrthogonalTileIteratorStep

Step sizes other than 1 are no longer used
pull/332/head
Jonathan G Rennison 3 years ago
parent f9e3c012f6
commit 1174b0c53f

@ -15,7 +15,7 @@
#include "map_func.h"
#include <tuple>
template<uint N> 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<uint N>
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.
*/

Loading…
Cancel
Save