Go to the documentation of this file.
10 #ifndef TILEAREA_TYPE_H
11 #define TILEAREA_TYPE_H
59 return TILE_ADDXY(this->tile, this->w / 2, this->h / 2);
172 }
else if (--this->y > 0) {
232 #define TILE_AREA_LOOP(var, ta) for (OrthogonalTileIterator var(ta); var != INVALID_TILE; ++var)
uint32 TileIndex
The index/ID of a Tile.
TileIndex tile
The current tile we are at.
Iterator to iterate over a diagonal area of the map.
DiagonalTileArea(TileIndex tile=INVALID_TILE, int8 a=0, int8 b=0)
Construct this tile area with some set values.
int y
The current 'y' position in the rectangle.
virtual TileIterator & operator++()=0
Move ourselves to the next tile in the rectangle on the map.
OrthogonalTileIterator(const OrthogonalTileArea &ta)
Construct the iterator.
int b_cur
The current (rotated) y coordinate of the iteration.
virtual ~TileIterator()
Some compilers really like this.
virtual TileIterator * Clone() const
Allocate a new iterator that is a copy of this one.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
uint base_x
The base tile x coordinate from where the iterating happens.
Represents a diagonal tile area.
bool Contains(TileIndex tile) const
Does this tile area contain a tile?
static uint TileX(TileIndex tile)
Get the X component of a tile.
virtual TileIterator * Clone() const =0
Allocate a new iterator that is a copy of this one.
void Clear()
Clears the 'tile area', i.e.
bool Intersects(const OrthogonalTileArea &ta) const
Does this tile area intersect with another?
Iterator to iterate over a tile area (rectangle) of the map.
Base class for tile iterators.
uint16 w
The width of the area.
Represents the covered area of e.g.
uint base_y
The base tile y coordinate from where the iterating happens.
int16 b
Extent in diagonal "y" direction (may be negative to signify the area stretches upwards)
DiagonalTileIterator(TileIndex corner1, TileIndex corner2)
Construct the iterator.
int a_max
The (rotated) x coordinate of the end of the iteration.
TileIndex GetCenterTile() const
Get the center tile.
uint16 h
The height of the area.
TileIterator & operator++()
Move ourselves to the next tile in the rectangle on the map.
TileIterator(TileIndex tile=INVALID_TILE)
Initialise the iterator starting at this tile.
int16 a
Extent in diagonal "x" direction (may be negative to signify the area stretches to the left)
TileIndex tile
The base tile of the area.
OrthogonalTileIterator(TileIndex corner1, TileIndex corner2)
Construct the iterator.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
void Clear()
Clears the TileArea by making the tile invalid and setting a and b to 0.
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
TileIterator & operator++()
Move ourselves to the next tile in the rectangle on the map.
DiagonalTileIterator(const DiagonalTileArea &ta)
Construct the iterator.
TileIndex tile
Base tile of the area.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
OrthogonalTileArea(TileIndex tile=INVALID_TILE, uint8 w=0, uint8 h=0)
Construct this tile area with some set values.
void ClampToMap()
Clamp the tile area to map borders.
int x
The current 'x' position in the rectangle.
virtual TileIterator * Clone() const
Allocate a new iterator that is a copy of this one.
int w
The width of the iterated area.
int b_max
The (rotated) y coordinate of the end of the iteration.
bool Contains(TileIndex tile) const
Does this tile area contain a tile?
int a_cur
The current (rotated) x coordinate of the iteration.