MCPcopy Index your code
hub / github.com/NetHack/NetHack / wallify_vault

Function wallify_vault

src/vault.c:645–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643}
644
645staticfn void
646wallify_vault(struct monst *grd)
647{
648 int typ;
649 coordxy x, y;
650 int vlt = EGD(grd)->vroom;
651 char tmp_viz;
652 coordxy lox = svr.rooms[vlt].lx - 1, hix = svr.rooms[vlt].hx + 1,
653 loy = svr.rooms[vlt].ly - 1, hiy = svr.rooms[vlt].hy + 1;
654 struct monst *mon;
655 struct obj *gold, *rocks;
656 struct trap *trap;
657 boolean fixed = FALSE;
658 boolean movedgold = FALSE;
659
660 for (x = lox; x <= hix; x++)
661 for (y = loy; y <= hiy; y++) {
662 /* if not on the room boundary, skip ahead */
663 if (x != lox && x != hix && y != loy && y != hiy)
664 continue;
665
666 if ((!IS_WALL(levl[x][y].typ) || g_at(x, y)
667 || sobj_at(ROCK, x, y) || sobj_at(BOULDER, x, y))
668 && !in_fcorridor(grd, x, y)) {
669 if ((mon = m_at(x, y)) != 0 && mon != grd) {
670 if (mon->mtame)
671 yelp(mon);
672 if (!rloc(mon, RLOC_MSG))
673 m_into_limbo(mon);
674 }
675 /* move gold at wall locations into the vault */
676 if ((gold = g_at(x, y)) != 0) {
677 move_gold(gold, EGD(grd)->vroom);
678 movedgold = TRUE;
679 }
680 /* destroy rocks and boulders (subsume them into the walls);
681 other objects present stay intact and become embedded */
682 while ((rocks = sobj_at(ROCK, x, y)) != 0) {
683 obj_extract_self(rocks);
684 obfree(rocks, (struct obj *) 0);
685 }
686 while ((rocks = sobj_at(BOULDER, x, y)) != 0) {
687 obj_extract_self(rocks);
688 obfree(rocks, (struct obj *) 0);
689 }
690 if ((trap = t_at(x, y)) != 0)
691 deltrap(trap);
692
693 if (x == lox)
694 typ = (y == loy) ? TLCORNER
695 : (y == hiy) ? BLCORNER
696 : VWALL;
697 else if (x == hix)
698 typ = (y == loy) ? TRCORNER
699 : (y == hiy) ? BRCORNER
700 : VWALL;
701 else /* not left or right side, must be top or bottom */
702 typ = HWALL;

Callers 2

gd_move_cleanupFunction · 0.85
gd_moveFunction · 0.85

Calls 15

g_atFunction · 0.85
sobj_atFunction · 0.85
in_fcorridorFunction · 0.85
yelpFunction · 0.85
rlocFunction · 0.85
m_into_limboFunction · 0.85
move_goldFunction · 0.85
obj_extract_selfFunction · 0.85
obfreeFunction · 0.85
t_atFunction · 0.85
deltrapFunction · 0.85
xy_set_wall_stateFunction · 0.85

Tested by

no test coverage detected