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

Function remove_region

src/region.c:343–386  ·  view source on GitHub ↗

* Remove a region from the list & free it. */

Source from the content-addressed store, hash-verified

341 * Remove a region from the list & free it.
342 */
343void
344remove_region(NhRegion *reg)
345{
346 int i, x, y;
347
348 for (i = 0; i < svn.n_regions; i++)
349 if (gr.regions[i] == reg)
350 break;
351 if (i == svn.n_regions)
352 return;
353
354 /* remove region before potential newsym() calls, but don't free it yet */
355 if (--svn.n_regions != i)
356 gr.regions[i] = gr.regions[svn.n_regions];
357 gr.regions[svn.n_regions] = (NhRegion *) 0;
358
359 /* Update screen if necessary */
360 reg->ttl = -2L; /* for visible_region_at */
361 if (reg->visible) {
362 int pass;
363 boolean tmp_uinwater = u.uinwater;
364
365 /* need to process the region's spots twice, first unblocking all
366 locations which no longer block line-of-sight, then redrawing
367 spots within revised line-of-sight; skip second pass if blind */
368 for (pass = 1; pass <= (Blind ? 1 : 2); ++pass) {
369 u.uinwater = (pass == 1) ? 0 : tmp_uinwater;
370
371 for (x = reg->bounding_box.lx; x <= reg->bounding_box.hx; x++)
372 for (y = reg->bounding_box.ly; y <= reg->bounding_box.hy; y++)
373 if (isok(x, y) && inside_region(reg, x, y)) {
374 if (pass == 1) {
375 if (!does_block(x, y, &levl[x][y]))
376 unblock_point(x, y);
377 } else { /* pass==2 */
378 if (cansee(x, y))
379 newsym(x, y);
380 }
381 }
382 }
383 u.uinwater = tmp_uinwater;
384 }
385 free_region(reg);
386}
387#endif /* !SFCTOOL */
388
389/*

Callers 3

run_regionsFunction · 0.85
rest_regionsFunction · 0.85
region_safetyFunction · 0.85

Calls 5

isokFunction · 0.85
inside_regionFunction · 0.85
unblock_pointFunction · 0.85
newsymFunction · 0.85
free_regionFunction · 0.85

Tested by

no test coverage detected