|
OpenTTD Source 20260311-master-g511d3794ce
|
Helper class for SpiralTileSequence. More...
#include <tilearea_type.h>
Public Types | |
| using | value_type = TileIndex |
| using | difference_type = std::ptrdiff_t |
| using | iterator_category = std::forward_iterator_tag |
| using | pointer = void |
| using | reference = void |
Public Member Functions | |
| SpiralTileIterator (TileIndex center, uint diameter) | |
| Create the iterator. | |
| SpiralTileIterator (TileIndex start_north, uint radius, uint w, uint h) | |
| Create the iterator. | |
| bool | operator== (const SpiralTileIterator &rhs) const |
| bool | operator== (const std::default_sentinel_t &) const |
| TileIndex | operator* () const |
| SpiralTileIterator & | operator++ () |
| SpiralTileIterator | operator++ (int) |
Private Member Functions | |
| void | SkipOutsideMap () |
| Advance the internal state until it reaches a valid tile or the end. | |
| void | InitPosition () |
| Initialise "position" after "dir" was changed. | |
| void | Increment () |
| Advance the internal state to the next potential tile. | |
| bool | IsEnd () const |
| Test whether the iterator reached the end. | |
Private Attributes | |
| uint | max_radius |
| std::array< uint, DIAGDIR_END > | extent |
| uint | cur_radius |
| DiagDirection | dir |
| uint | position |
| uint | x |
| uint | y |
Helper class for SpiralTileSequence.
Definition at line 267 of file tilearea_type.h.
| using SpiralTileIterator::difference_type = std::ptrdiff_t |
Definition at line 270 of file tilearea_type.h.
| using SpiralTileIterator::iterator_category = std::forward_iterator_tag |
Definition at line 271 of file tilearea_type.h.
| using SpiralTileIterator::pointer = void |
Definition at line 272 of file tilearea_type.h.
| using SpiralTileIterator::reference = void |
Definition at line 273 of file tilearea_type.h.
| using SpiralTileIterator::value_type = TileIndex |
Definition at line 269 of file tilearea_type.h.
| SpiralTileIterator::SpiralTileIterator | ( | TileIndex | center, |
| uint | diameter ) |
Create the iterator.
Generate TileIndices for a square area around a center tile.
The size of the square is given by the length of the edge. If the size is even, the south extent will be larger than the north extent.
Example for diameter=4, [ ] is the "center": 1 1 1 1 [0] 1 1 0 0 1 1 0 1 1 1 1 The sequence starts with the "0" tiles, and continues with the shells around it.
| center | Center of the square area. |
| diameter | Edge length of the square. |
Definition at line 301 of file tilearea.cpp.
References DIAGDIR_BEGIN, InitPosition(), INVALID_DIAGDIR, SkipOutsideMap(), TileX(), and TileY().
| SpiralTileIterator::SpiralTileIterator | ( | TileIndex | start_north, |
| uint | radius, | ||
| uint | w, | ||
| uint | h ) |
Create the iterator.
Generate TileIndices for a rectangular area with an optional rectangular hole in the center.
The TileIndices will be sorted by increasing distance from the center (hole).
Example for radius=2, w=2, h=1, [ ] is "start_north": 1 1 1 1 [0] 1 1 0 0 1 1 0 H 0 1 1 0 H 0 1 1 0 0 1 1 0 1 1 1 1 The sequence starts with the "0" tiles, and continues with the shells around it.
| start_north | Tile directly north from the center hole. |
| radius | Radial distance between outer rectangle and center hole. |
| w | Width of the inner rectangular hole. |
| h | Height of the inner rectangular hole. |
Definition at line 328 of file tilearea.cpp.
References DIAGDIR_BEGIN, InitPosition(), SkipOutsideMap(), TileX(), and TileY().
|
private |
Advance the internal state to the next potential tile.
The tile may be outside the map though.
Definition at line 362 of file tilearea.cpp.
References DIAGDIR_BEGIN, DIAGDIR_END, DIR_W, InitPosition(), INVALID_DIAGDIR, IsEnd(), TileIndexDiffCByDiagDir(), and TileIndexDiffCByDir().
Referenced by SkipOutsideMap().
|
private |
Initialise "position" after "dir" was changed.
Definition at line 353 of file tilearea.cpp.
Referenced by Increment(), SpiralTileIterator(), and SpiralTileIterator().
|
inlineprivate |
Test whether the iterator reached the end.
true iff the end of the iteration is reached. Definition at line 316 of file tilearea_type.h.
References INVALID_DIAGDIR.
Referenced by Increment(), and SkipOutsideMap().
|
inline |
Definition at line 281 of file tilearea_type.h.
|
inline |
Definition at line 283 of file tilearea_type.h.
|
inline |
Definition at line 290 of file tilearea_type.h.
|
inline |
Definition at line 278 of file tilearea_type.h.
|
inline |
Definition at line 279 of file tilearea_type.h.
|
private |
Advance the internal state until it reaches a valid tile or the end.
Definition at line 345 of file tilearea.cpp.
References Increment(), IsEnd(), Map::SizeX(), and Map::SizeY().
Referenced by SpiralTileIterator(), and SpiralTileIterator().
|
private |
Definition at line 303 of file tilearea_type.h.
|
private |
Definition at line 304 of file tilearea_type.h.
|
private |
Definition at line 300 of file tilearea_type.h.
|
private |
Definition at line 299 of file tilearea_type.h.
|
private |
Definition at line 305 of file tilearea_type.h.
|
private |
Definition at line 306 of file tilearea_type.h.
|
private |
Definition at line 306 of file tilearea_type.h.