OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
26 uint sx =
TileX(start);
27 uint sy =
TileY(start);
31 if (sx > ex)
Swap(sx, ex);
32 if (sy > ey)
Swap(sy, ey);
35 this->
w = ex - sx + 1;
36 this->
h = ey - sy + 1;
54 uint ex = sx + this->
w - 1;
55 uint ey = sy + this->
h - 1;
57 uint ax =
TileX(to_add);
58 uint ay =
TileY(to_add);
60 sx = std::min(ax, sx);
61 sy = std::min(ay, sy);
62 ex = std::max(ax, ex);
63 ey = std::max(ay, ey);
66 this->w = ex - sx + 1;
67 this->h = ey - sy + 1;
77 if (ta.
w == 0 || this->w == 0)
return false;
79 assert(ta.
w != 0 && ta.
h != 0 && this->w != 0 && this->h != 0);
83 uint right1 = left1 + this->
w - 1;
84 uint bottom1 = top1 + this->
h - 1;
88 uint right2 = left2 + ta.
w - 1;
89 uint bottom2 = top2 + ta.
h - 1;
106 if (this->
w == 0)
return false;
108 assert(this->
w != 0 && this->
h != 0);
110 uint left =
TileX(this->tile);
111 uint top =
TileY(this->tile);
128 int sx = std::max<int>(x - rad, 0);
129 int sy = std::max<int>(y - rad, 0);
130 int ex = std::min<int>(x + this->
w + rad,
MapSizeX());
131 int ey = std::min<int>(y + this->
h + rad,
MapSizeY());
210 int start_a =
TileY(this->tile) +
TileX(this->tile);
211 int start_b =
TileY(this->tile) -
TileX(this->tile);
213 int end_a = start_a + this->
a;
214 int end_b = start_b + this->
b;
217 if (start_a > end_a) {
222 if (start_b > end_b) {
228 return (
a >= start_a && a < end_a && b >= start_b &&
b < end_b);
239 bool new_line =
false;
245 if (this->
b_max > 0) {
252 if (this->
a_max > 0) {
265 if (this->
b_max > 0) {
uint32 TileIndex
The index/ID of a Tile.
TileIndex tile
The current tile we are at.
DiagonalTileArea(TileIndex tile=INVALID_TILE, int8 a=0, int8 b=0)
Construct this tile area with some set values.
int b_cur
The current (rotated) y coordinate of the iteration.
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.
bool Contains(TileIndex tile) const
Does this tile area contain a tile?
static uint TileX(TileIndex tile)
Get the X component of a tile.
bool Intersects(const OrthogonalTileArea &ta) const
Does this tile area intersect with another?
static uint MapSizeX()
Get the size of the map along the X.
Iterator to iterate over a tile area (rectangle) of the map.
static uint MapSize()
Get the size of the map.
Base class for tile iterators.
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
uint16 w
The width of the area.
OrthogonalTileIterator begin() const
Returns an iterator to the beginning of the tile area.
Represents the covered area of e.g.
uint base_y
The base tile y coordinate from where the iterating happens.
OrthogonalTileIterator end() const
Returns an iterator to the end of the tile area.
static uint MapSizeY()
Get the size of the map along the Y.
int16 b
Extent in diagonal "y" direction (may be negative to signify the area stretches upwards)
int a_max
The (rotated) x coordinate of the end of the iteration.
uint16 h
The height of the area.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
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.
static T abs(const T a)
Returns the absolute value of (scalar) variable.
TileIterator & operator++()
Move ourselves to the next tile in the rectangle on the map.
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.
static void Swap(T &a, T &b)
Type safe swap operation.
void ClampToMap()
Clamp the tile area to map borders.
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.