OpenTTD Source
20240915-master-g3784a3d3d6
|
Go to the documentation of this file.
10 #ifndef TILEAREA_TYPE_H
11 #define TILEAREA_TYPE_H
61 return TileAddXY(this->tile, this->w / 2, this->h / 2);
149 virtual std::unique_ptr<TileIterator>
Clone()
const = 0;
156 return this->tile == rhs.
tile;
163 return this->tile != rhs.
tile;
171 return this->tile == rhs;
178 return this->tile != rhs;
219 }
else if (--this->y > 0) {
228 std::unique_ptr<TileIterator>
Clone()
const override
230 return std::make_unique<OrthogonalTileIterator>(*
this);
267 std::unique_ptr<TileIterator>
Clone()
const override
269 return std::make_unique<DiagonalTileIterator>(*
this);
std::unique_ptr< TileIterator > Clone() const override
Allocate a new iterator that is a copy of this one.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
TileIndex tile
The current tile we are at.
Iterator to iterate over a diagonal area of the map.
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.
OrthogonalTileArea(TileIndex tile=INVALID_TILE, uint16_t w=0, uint16_t h=0)
Construct this tile area with some set values.
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
OrthogonalTileIterator(const OrthogonalTileArea &ta)
Construct the iterator.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
int b_cur
The current (rotated) y coordinate of the iteration.
static std::unique_ptr< TileIterator > Create(TileIndex corner1, TileIndex corner2, bool diagonal)
Create either an OrthogonalTileIterator or DiagonalTileIterator given the diagonal parameter.
virtual ~TileIterator()
Some compilers really like this.
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.
int16_t a
Extent in diagonal "x" direction (may be negative to signify the area stretches to the left)
Represents a diagonal tile area.
uint16_t h
The height of the area.
bool Contains(TileIndex tile) const
Does this tile area contain a tile?
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.
virtual std::unique_ptr< TileIterator > Clone() const =0
Allocate a new iterator that is a copy of this one.
Base class for tile iterators.
OrthogonalTileIterator begin() const
Returns an iterator to the beginning of the tile area.
DiagonalTileArea(TileIndex tile=INVALID_TILE, int16_t a=0, int16_t b=0)
Construct this tile area with some set values.
Represents the covered area of e.g.
uint base_y
The base tile y coordinate from where the iterating happens.
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
OrthogonalTileIterator end() const
Returns an iterator to the end of the tile area.
DiagonalTileIterator(TileIndex corner1, TileIndex corner2)
Construct the iterator.
std::unique_ptr< TileIterator > Clone() const override
Allocate a new iterator that is a copy of this one.
int a_max
The (rotated) x coordinate of the end of the iteration.
TileIndex GetCenterTile() const
Get the center tile.
TileIterator(TileIndex tile=INVALID_TILE)
Initialise the iterator starting at this tile.
TileIterator & operator++() override
Move ourselves to the next tile in the rectangle on the map.
bool operator!=(const TileIterator &rhs) const
Inequality comparison.
bool operator==(const TileIterator &rhs) const
Equality comparison.
TileIndex tile
The base tile of the area.
OrthogonalTileIterator(TileIndex corner1, TileIndex corner2)
Construct the iterator.
TileIndex operator*() const
Get the tile we are currently at.
void Clear()
Clears the TileArea by making the tile invalid and setting a and b to 0.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
uint16_t w
The width of the area.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
DiagonalTileIterator(const DiagonalTileArea &ta)
Construct the iterator.
TileIndex tile
Base tile of the area.
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
void ClampToMap()
Clamp the tile area to map borders.
int x
The current 'x' position in the rectangle.
int16_t b
Extent in diagonal "y" direction (may be negative to signify the area stretches upwards)
TileIterator & operator++() override
Move ourselves to the next tile in the rectangle on the map.
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.