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

Function mkcavepos

src/dig.c:47–85  ·  view source on GitHub ↗

Change level topology. Messes with vision tables and ignores things like * boulders in the name of a nice effect. Vision will get fixed up again * immediately after the effect is complete. */

Source from the content-addressed store, hash-verified

45 * immediately after the effect is complete.
46 */
47staticfn void
48mkcavepos(coordxy x, coordxy y, int dist, boolean waslit, boolean rockit)
49{
50 struct rm *lev;
51
52 if (!isok(x, y))
53 return;
54 lev = &levl[x][y];
55
56 if (rockit) {
57 struct monst *mtmp;
58
59 if (IS_OBSTRUCTED(lev->typ))
60 return;
61 if (t_at(x, y))
62 return; /* don't cover the portal */
63 if ((mtmp = m_at(x, y)) != 0) /* make sure crucial monsters survive */
64 if (!passes_walls(mtmp->data))
65 (void) rloc(mtmp, RLOC_NOMSG);
66 } else if (lev->typ == ROOM)
67 return;
68
69 unblock_point(x, y); /* make sure vision knows this location is open */
70
71 /* fake out saved state */
72 lev->seenv = 0;
73 lev->doormask = 0;
74 if (dist < 3)
75 lev->lit = (rockit ? FALSE : TRUE);
76 if (waslit)
77 lev->waslit = (rockit ? FALSE : TRUE);
78 lev->horizontal = FALSE;
79 /* short-circuit vision recalc */
80 gv.viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) : COULD_SEE;
81 lev->typ = (rockit ? STONE : ROOM); /* flags set via doormask above */
82 if (dist >= 3)
83 impossible("mkcavepos called with dist %d", dist);
84 feel_newsym(x, y);
85}
86
87staticfn void
88mkcavearea(boolean rockit)

Callers 1

mkcaveareaFunction · 0.85

Calls 6

isokFunction · 0.85
t_atFunction · 0.85
rlocFunction · 0.85
unblock_pointFunction · 0.85
feel_newsymFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected