MCPcopy Create free account
hub / github.com/NetHack/NetHack / intersect

Function intersect

src/rect.c:115–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113 */
114
115staticfn boolean
116intersect(NhRect *r1, NhRect *r2, NhRect *r3)
117{
118 if (r2->lx > r1->hx || r2->ly > r1->hy || r2->hx < r1->lx
119 || r2->hy < r1->ly)
120 return FALSE;
121
122 r3->lx = (r2->lx > r1->lx ? r2->lx : r1->lx);
123 r3->ly = (r2->ly > r1->ly ? r2->ly : r1->ly);
124 r3->hx = (r2->hx > r1->hx ? r1->hx : r2->hx);
125 r3->hy = (r2->hy > r1->hy ? r1->hy : r2->hy);
126
127 if (r3->lx > r3->hx || r3->ly > r3->hy)
128 return FALSE;
129 return TRUE;
130}
131
132/* Put the rectangle containing both r1 and r2 into r3 */
133void

Callers 1

split_rectsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected