|
OpenTTD Source 20260903-master-ged04d336ed
|
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 |
| DiagDirectionIndexArray< uint > | extent |
| uint | cur_radius |
| DiagDirection | dir |
| uint | position |
| uint | x |
| uint | y |
Helper class for SpiralTileSequence.
Definition at line 273 of file tilearea_type.h.
| using SpiralTileIterator::difference_type = std::ptrdiff_t |
Definition at line 276 of file tilearea_type.h.
| using SpiralTileIterator::iterator_category = std::forward_iterator_tag |
Definition at line 277 of file tilearea_type.h.
| using SpiralTileIterator::pointer = void |
Definition at line 278 of file tilearea_type.h.
| using SpiralTileIterator::reference = void |
Definition at line 279 of file tilearea_type.h.
| using SpiralTileIterator::value_type = TileIndex |
Definition at line 275 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 Begin, InitPosition(), Invalid, 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 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 Begin, End, InitPosition(), Invalid, IsEnd(), TileIndexDiffCByDiagDir(), TileIndexDiffCByDir(), and W.
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 322 of file tilearea_type.h.
References Invalid.
Referenced by Increment(), and SkipOutsideMap().
|
inline |
Definition at line 287 of file tilearea_type.h.
|
inline |
Definition at line 289 of file tilearea_type.h.
|
inline |
Definition at line 296 of file tilearea_type.h.
|
inline |
Definition at line 284 of file tilearea_type.h.
|
inline |
Definition at line 285 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 309 of file tilearea_type.h.
|
private |
Definition at line 310 of file tilearea_type.h.
|
private |
Definition at line 306 of file tilearea_type.h.
|
private |
Definition at line 305 of file tilearea_type.h.
|
private |
Definition at line 311 of file tilearea_type.h.
|
private |
Definition at line 312 of file tilearea_type.h.
|
private |
Definition at line 312 of file tilearea_type.h.