summaryrefslogtreecommitdiff
path: root/src/station.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/station.cpp')
-rw-r--r--src/station.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/station.cpp b/src/station.cpp
index a3c58052a..659ece367 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -539,6 +539,30 @@ void TileArea::Add(TileIndex to_add)
this->h = ey - sy + 1;
}
+bool TileArea::Intersects(const TileArea &ta) const
+{
+ if (ta.w == 0 || this->w == 0) return false;
+
+ assert(ta.w != 0 && ta.h != 0 && this->w != 0 && this->h != 0);
+
+ uint left1 = TileX(this->tile);
+ uint top1 = TileY(this->tile);
+ uint right1 = left1 + this->w - 1;
+ uint bottom1 = top1 + this->h - 1;
+
+ uint left2 = TileX(ta.tile);
+ uint top2 = TileY(ta.tile);
+ uint right2 = left2 + ta.w - 1;
+ uint bottom2 = top2 + ta.h - 1;
+
+ return !(
+ left2 > right1 ||
+ right2 < left1 ||
+ top2 > bottom1 ||
+ bottom2 < top1
+ );
+}
+
void InitializeStations()
{