From 61a0ed5225861eed544f082e860de8e0f4f837ca Mon Sep 17 00:00:00 2001 From: cirdan Date: Sun, 23 Feb 2014 21:07:12 +0100 Subject: [PATCH] Rename TileArea to OrthogonalTileArea Rename TileArea to OrthogonalTileArea and make TileArea an alias for it. --- src/map/tilearea.cpp | 14 +++++++------- src/map/tilearea.h | 18 +++++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/map/tilearea.cpp b/src/map/tilearea.cpp index 4cf9a18f3..abb10080f 100644 --- a/src/map/tilearea.cpp +++ b/src/map/tilearea.cpp @@ -18,7 +18,7 @@ * @param x1 final x of the area * @param y1 final y of the area */ -inline void TileArea::Set(uint x0, uint y0, uint x1, uint y1) +inline void OrthogonalTileArea::Set(uint x0, uint y0, uint x1, uint y1) { this->tile = TileXY(x0, y0); this->w = x1 - x0 + 1; @@ -30,7 +30,7 @@ inline void TileArea::Set(uint x0, uint y0, uint x1, uint y1) * @param start the start of the area * @param end the end of the area */ -TileArea::TileArea(TileIndex start, TileIndex end) +OrthogonalTileArea::OrthogonalTileArea(TileIndex start, TileIndex end) { uint sx = TileX(start); uint sy = TileY(start); @@ -47,7 +47,7 @@ TileArea::TileArea(TileIndex start, TileIndex end) * Add a single tile to a tile area; enlarge if needed. * @param to_add The tile to add */ -void TileArea::Add(TileIndex to_add) +void OrthogonalTileArea::Add(TileIndex to_add) { if (this->tile == INVALID_TILE) { this->tile = to_add; @@ -71,7 +71,7 @@ void TileArea::Add(TileIndex to_add) * Add another tile area to a tile area; enlarge if needed. * @param to_add The tile area to add */ -void TileArea::Add(const TileArea &to_add) +void OrthogonalTileArea::Add(const OrthogonalTileArea &to_add) { if (to_add.tile == INVALID_TILE) return; @@ -100,7 +100,7 @@ void TileArea::Add(const TileArea &to_add) * @param ta the other tile area to check against. * @return true if they intersect. */ -bool TileArea::Intersects(const TileArea &ta) const +bool OrthogonalTileArea::Intersects(const OrthogonalTileArea &ta) const { if (ta.w == 0 || this->w == 0) return false; @@ -129,7 +129,7 @@ bool TileArea::Intersects(const TileArea &ta) const * @param tile Tile to test for. * @return True if the tile is inside the area. */ -bool TileArea::Contains(TileIndex tile) const +bool OrthogonalTileArea::Contains(TileIndex tile) const { if (this->w == 0) return false; @@ -146,7 +146,7 @@ bool TileArea::Contains(TileIndex tile) const /** * Clamp the tile area to map borders. */ -void TileArea::ClampToMap() +void OrthogonalTileArea::ClampToMap() { assert(this->tile < MapSize()); this->w = min(this->w, MapSizeX() - TileX(this->tile)); diff --git a/src/map/tilearea.h b/src/map/tilearea.h index 520b66b1d..924d93542 100644 --- a/src/map/tilearea.h +++ b/src/map/tilearea.h @@ -13,13 +13,13 @@ #include "coord.h" /** Represents the covered area of e.g. a rail station */ -struct TileArea { +struct OrthogonalTileArea { TileIndex tile; ///< The base tile of the area uint16 w; ///< The width of the area uint16 h; ///< The height of the area /** Just construct this tile area */ - TileArea() : tile(INVALID_TILE), w(0), h(0) {} + OrthogonalTileArea() : tile(INVALID_TILE), w(0), h(0) {} /** * Construct this tile area with some set values @@ -27,15 +27,15 @@ struct TileArea { * @param w the width * @param h the height */ - TileArea(TileIndex tile, uint8 w, uint8 h) : tile(tile), w(w), h(h) {} + OrthogonalTileArea(TileIndex tile, uint8 w, uint8 h) : tile(tile), w(w), h(h) {} - TileArea(TileIndex start, TileIndex end); + OrthogonalTileArea(TileIndex start, TileIndex end); void Set(uint x0, uint y0, uint x1, uint y1); void Add(TileIndex to_add); - void Add(const TileArea &to_add); + void Add(const OrthogonalTileArea &to_add); /** * Clears the 'tile area', i.e. make the tile invalid. @@ -47,7 +47,7 @@ struct TileArea { this->h = 0; } - bool Intersects(const TileArea &ta) const; + bool Intersects(const OrthogonalTileArea &ta) const; bool Contains(TileIndex tile) const; @@ -84,6 +84,10 @@ struct TileArea { } }; +/** Shorthand for the much more common orthogonal tile area. */ +typedef OrthogonalTileArea TileArea; + + /** Base class for tile iterators. */ class TileIterator { protected: @@ -164,7 +168,7 @@ public: * Construct the iterator. * @param ta Area, i.e. begin point and width/height of to-be-iterated area. */ - OrthogonalTileIterator(const TileArea &ta) + OrthogonalTileIterator(const OrthogonalTileArea &ta) : TileIterator(ta.w == 0 || ta.h == 0 ? INVALID_TILE : ta.tile), w(ta.w), rowdiff(TileDiffXY(1, 1) - ta.w), x(ta.w), y(ta.h) { -- 2.11.4.GIT