summaryrefslogtreecommitdiff
path: root/src/tilearea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tilearea.cpp')
-rw-r--r--src/tilearea.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tilearea.cpp b/src/tilearea.cpp
index 29a164351..e6efd0559 100644
--- a/src/tilearea.cpp
+++ b/src/tilearea.cpp
@@ -94,6 +94,25 @@ bool TileArea::Intersects(const TileArea &ta) const
}
/**
+ * Does this tile area contain a tile?
+ * @param tile Tile to test for.
+ * @return True if the tile is inside the area.
+ */
+bool TileArea::Contains(TileIndex tile) const
+{
+ if (this->w == 0) return false;
+
+ assert(this->w != 0 && this->h != 0);
+
+ uint left = TileX(this->tile);
+ uint top = TileY(this->tile);
+ uint tile_x = TileX(tile);
+ uint tile_y = TileY(tile);
+
+ return IsInsideBS(tile_x, left, this->w) && IsInsideBS(tile_y, top, this->h);
+}
+
+/**
* Clamp the tile area to map borders.
*/
void TileArea::ClampToMap()