diff options
author | glx22 <glx@openttd.org> | 2021-05-12 16:45:28 +0200 |
---|---|---|
committer | Loïc Guilloux <glx22@users.noreply.github.com> | 2021-05-13 00:13:54 +0200 |
commit | 38c97e14926f4bc538c20b24f8a3decdef1668f9 (patch) | |
tree | 2138fa9979f463c5b946653c23313fbb977be652 /src/tilearea_type.h | |
parent | 5bd81448539b63519d70ba85d4833e446f0597fe (diff) | |
download | openttd-38c97e14926f4bc538c20b24f8a3decdef1668f9.tar.xz |
Codechange: Replace TILE_AREA_LOOP with range-based for loops
Diffstat (limited to 'src/tilearea_type.h')
-rw-r--r-- | src/tilearea_type.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/tilearea_type.h b/src/tilearea_type.h index 264821985..e6d9bad60 100644 --- a/src/tilearea_type.h +++ b/src/tilearea_type.h @@ -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. */ @@ -124,6 +130,15 @@ public: } /** + * 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. */ virtual TileIterator& operator ++() = 0; @@ -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 */ |