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

Function split_rects

src/rect.c:181–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179 */
180
181void
182split_rects(NhRect *r1, NhRect *r2)
183{
184 NhRect r, old_r;
185 int i;
186
187 old_r = *r1;
188 remove_rect(r1);
189
190 /* Walk down since rect_cnt & rect[] will change... */
191 for (i = rect_cnt - 1; i >= 0; i--)
192 if (intersect(&rect[i], r2, &r))
193 split_rects(&rect[i], &r);
194
195 if (r2->ly - old_r.ly - 1
196 > (old_r.hy < ROWNO - 1 ? 2 * YLIM : YLIM + 1) + 4) {
197 r = old_r;
198 r.hy = r2->ly - 2;
199 add_rect(&r);
200 }
201 if (r2->lx - old_r.lx - 1
202 > (old_r.hx < COLNO - 1 ? 2 * XLIM : XLIM + 1) + 4) {
203 r = old_r;
204 r.hx = r2->lx - 2;
205 add_rect(&r);
206 }
207 if (old_r.hy - r2->hy - 1 > (old_r.ly > 0 ? 2 * YLIM : YLIM + 1) + 4) {
208 r = old_r;
209 r.ly = r2->hy + 2;
210 add_rect(&r);
211 }
212 if (old_r.hx - r2->hx - 1 > (old_r.lx > 0 ? 2 * XLIM : XLIM + 1) + 4) {
213 r = old_r;
214 r.lx = r2->hx + 2;
215 add_rect(&r);
216 }
217}
218
219/*rect.c*/

Callers 1

create_roomFunction · 0.85

Calls 3

remove_rectFunction · 0.85
intersectFunction · 0.85
add_rectFunction · 0.85

Tested by

no test coverage detected