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

Function remove_rooms

src/mkmap.c:378–401  ·  view source on GitHub ↗

* TODO: If we really want to remove rooms after a map is plopped down * in a special level, this needs to be rewritten - the maps may have * holes in them ("x" mapchar), leaving parts of rooms still on the map. * * When level processed by join_map is overlaid by a MAP, some rooms may no * longer be valid. All rooms in the region lx <= x < hx, ly <= y < hy are * removed. Rooms partially in

Source from the content-addressed store, hash-verified

376 * region are all set.
377 */
378void
379remove_rooms(coordxy lx, coordxy ly, coordxy hx, coordxy hy)
380{
381 int i;
382 struct mkroom *croom;
383
384 for (i = svn.nroom - 1; i >= 0; --i) {
385 croom = &svr.rooms[i];
386 if (croom->hx < lx || croom->lx >= hx || croom->hy < ly
387 || croom->ly >= hy)
388 continue; /* no overlap */
389
390 if (croom->lx < lx || croom->hx >= hx || croom->ly < ly
391 || croom->hy >= hy) { /* partial overlap */
392 /* TODO: ensure remaining parts of room are still joined */
393
394 if (!croom->irregular)
395 impossible("regular room in joined map");
396 } else {
397 /* total overlap, remove the room */
398 remove_room((unsigned) i);
399 }
400 }
401}
402
403/*
404 * Remove roomno from the rooms array, decrementing nroom.

Callers

nothing calls this directly

Calls 2

remove_roomFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected