MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Intersects

Method Intersects

src/tilearea.cpp:75–97  ·  view source on GitHub ↗

* Does this tile area intersect with another? * @param ta the other tile area to check against. * @return true if they intersect. */

Source from the content-addressed store, hash-verified

73 * @return true if they intersect.
74 */
75bool OrthogonalTileArea::Intersects(const OrthogonalTileArea &ta) const
76{
77 if (ta.w == 0 || this->w == 0) return false;
78
79 assert(ta.w != 0 && ta.h != 0 && this->w != 0 && this->h != 0);
80
81 uint left1 = TileX(this->tile);
82 uint top1 = TileY(this->tile);
83 uint right1 = left1 + this->w - 1;
84 uint bottom1 = top1 + this->h - 1;
85
86 uint left2 = TileX(ta.tile);
87 uint top2 = TileY(ta.tile);
88 uint right2 = left2 + ta.w - 1;
89 uint bottom2 = top2 + ta.h - 1;
90
91 return !(
92 left2 > right1 ||
93 right2 < left1 ||
94 top2 > bottom1 ||
95 bottom2 < top1
96 );
97}
98
99/**
100 * Does this tile area contain a tile?

Callers 1

FindClearedObjectFunction · 0.80

Calls 2

TileXFunction · 0.85
TileYFunction · 0.85

Tested by

no test coverage detected