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