Codechange: Replace TILE_AREA_LOOP with range-based for loops

This commit is contained in:
glx22
2021-05-12 16:45:28 +02:00
committed by Loïc Guilloux
parent 5bd8144853
commit 38c97e1492
23 changed files with 101 additions and 76 deletions

View File

@@ -12,6 +12,8 @@
#include "map_func.h"
class OrthogonalTileIterator;
/** Represents the covered area of e.g. a rail station */
struct OrthogonalTileArea {
TileIndex tile; ///< The base tile of the area
@@ -58,6 +60,10 @@ struct OrthogonalTileArea {
{
return TILE_ADDXY(this->tile, this->w / 2, this->h / 2);
}
OrthogonalTileIterator begin() const;
OrthogonalTileIterator end() const;
};
/** Represents a diagonal tile area. */
@@ -123,6 +129,15 @@ public:
return this->tile;
}
/**
* Get the tile we are currently at.
* @return The tile we are at, or INVALID_TILE when we're done.
*/
inline TileIndex operator *() const
{
return this->tile;
}
/**
* Move ourselves to the next tile in the rectangle on the map.
*/
@@ -223,12 +238,4 @@ public:
}
};
/**
* A loop which iterates over the tiles of a TileArea.
* @param var The name of the variable which contains the current tile.
* This variable will be allocated in this \c for of this loop.
* @param ta The tile area to search over.
*/
#define TILE_AREA_LOOP(var, ta) for (OrthogonalTileIterator var(ta); var != INVALID_TILE; ++var)
#endif /* TILEAREA_TYPE_H */