OpenTTD Source: DiagonalTileIterator Class Reference

OpenTTD Source 15.0-beta1

Public Member Functions | Private Attributes
DiagonalTileIterator Class Reference

Iterator to iterate over a diagonal area of the map. More...

`#include <tilearea_type.h>`

Inheritance diagram for DiagonalTileIterator:

## Public Member Functions
| DiagonalTileIterator (const DiagonalTileArea &ta)
| Construct the iterator.
| DiagonalTileIterator (TileIndex corner1, TileIndex corner2)
| Construct the iterator.
TileIterator & | operator++ () override
| Move ourselves to the next tile in the rectangle on the map.
std::unique_ptr< TileIterator > | Clone () const override
| Allocate a new iterator that is a copy of this one.
Public Member Functions inherited from TileIterator
| operator TileIndex () const
| Get the tile we are currently at.
TileIndex | operator* () const
| Get the tile we are currently at.
bool | operator== (const TileIterator &rhs) const
| Equality comparison.
bool | operator!= (const TileIterator &rhs) const
| Inequality comparison.
bool | operator== (const TileIndex &rhs) const
| Equality comparison.
bool | operator!= (const TileIndex &rhs) const
| Inequality comparison.

## Private Attributes
uint | base_x
| The base tile x coordinate from where the iterating happens.
uint | base_y
| The base tile y coordinate from where the iterating happens.
int | a_cur
| The current (rotated) x coordinate of the iteration.
int | b_cur
| The current (rotated) y coordinate of the iteration.
int | a_max
| The (rotated) x coordinate of the end of the iteration.
int | b_max
| The (rotated) y coordinate of the end of the iteration.

## Additional Inherited Members
Static Public Member Functions inherited from TileIterator
static std::unique_ptr< TileIterator > | Create (TileIndex corner1, TileIndex corner2, bool diagonal)
| Create either an OrthogonalTileIterator or DiagonalTileIterator given the diagonal parameter.
Protected Member Functions inherited from TileIterator
| TileIterator (TileIndex tile=INVALID_TILE)
| Initialise the iterator starting at this tile.
Protected Attributes inherited from TileIterator
TileIndex | tile
| The current tile we are at.

## Detailed Description

Iterator to iterate over a diagonal area of the map.

Definition at line 232 of file tilearea_type.h.

## Constructor & Destructor Documentation

## ◆ DiagonalTileIterator() [1/2]

DiagonalTileIterator::DiagonalTileIterator | ( | const DiagonalTileArea & | ta | ) |
| inline

Construct the iterator.

Parameters

  ta | Area, i.e. begin point and (diagonal) width/height of to-be-iterated area.

Definition at line 247 of file tilearea_type.h.

## ◆ DiagonalTileIterator() [2/2]

DiagonalTileIterator::DiagonalTileIterator | ( | TileIndex | corner1,
|  | TileIndex | corner2
| ) |  |
| inline

Construct the iterator.

Parameters

  corner1 | Tile from where to begin iterating.
  corner2 | Tile where to end the iterating.

Definition at line 257 of file tilearea_type.h.

## Member Function Documentation

## ◆ Clone()

std::unique_ptr< TileIterator > DiagonalTileIterator::Clone | ( |  | ) | const
| inlineoverridevirtual

Allocate a new iterator that is a copy of this one.

Implements TileIterator.

Definition at line 264 of file tilearea_type.h.

## ◆ operator++()

TileIterator & DiagonalTileIterator::operator++ | ( |  | ) |
| overridevirtual

Move ourselves to the next tile in the rectangle on the map.

Implements TileIterator.

Definition at line 234 of file tilearea.cpp.

References a_cur, a_max, abs(), b_cur, b_max, base_x, base_y, INVALID_TILE, Map::Size(), Map::SizeX(), Map::SizeY(), TileIterator::tile, and TileXY().

## Field Documentation

## ◆ a_cur

int DiagonalTileIterator::a_cur
| private

The current (rotated) x coordinate of the iteration.

Definition at line 236 of file tilearea_type.h.

Referenced by operator++().

## ◆ a_max

int DiagonalTileIterator::a_max
| private

The (rotated) x coordinate of the end of the iteration.

Definition at line 238 of file tilearea_type.h.

Referenced by operator++().

## ◆ b_cur

int DiagonalTileIterator::b_cur
| private

The current (rotated) y coordinate of the iteration.

Definition at line 237 of file tilearea_type.h.

Referenced by operator++().

## ◆ b_max

int DiagonalTileIterator::b_max
| private

The (rotated) y coordinate of the end of the iteration.

Definition at line 239 of file tilearea_type.h.

Referenced by operator++().

## ◆ base_x

uint DiagonalTileIterator::base_x
| private

The base tile x coordinate from where the iterating happens.

Definition at line 234 of file tilearea_type.h.

Referenced by operator++().

## ◆ base_y

uint DiagonalTileIterator::base_y
| private

The base tile y coordinate from where the iterating happens.

Definition at line 235 of file tilearea_type.h.

Referenced by operator++().

The documentation for this class was generated from the following files:

- src/tilearea_type.h
- src/tilearea.cpp