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

Function mkinvpos

src/mklev.c:2502–2598  ·  view source on GitHub ↗

Change level topology. Boulders in the vicinity are eliminated. * Temporarily overrides vision in the name of a nice effect. */

Source from the content-addressed store, hash-verified

2500 * Temporarily overrides vision in the name of a nice effect.
2501 */
2502staticfn void
2503mkinvpos(coordxy x, coordxy y, int dist)
2504{
2505 struct trap *ttmp;
2506 struct obj *otmp;
2507 boolean make_rocks;
2508 struct rm *lev = &levl[x][y];
2509 struct monst *mon;
2510 /* maze levels have slightly different constraints from normal levels;
2511 these are also defined in mkmaze.c and may not be appropriate for
2512 mazes with corridors wider than 1 or for cavernous levels */
2513#define x_maze_min 2
2514#define y_maze_min 2
2515
2516 /* clip at existing map borders if necessary */
2517 if (!within_bounded_area(x, y, x_maze_min, y_maze_min,
2518 gx.x_maze_max, gy.y_maze_max)) {
2519 /* outermost 2 columns and/or rows may be truncated due to edge */
2520 if (dist < (7 - 2)) { /* panic() or impossible() */
2521 void (*errfunc)(const char *, ...) PRINTF_F(1, 2);
2522
2523 errfunc = !isok(x, y) ? panic : impossible;
2524 (*errfunc)("mkinvpos: <%d,%d> (%d) off map edge!", x, y, dist);
2525 }
2526 return;
2527 }
2528
2529 /* clear traps */
2530 if ((ttmp = t_at(x, y)) != 0)
2531 deltrap(ttmp);
2532
2533 /* clear boulders; leave some rocks for non-{moat|trap} locations */
2534 make_rocks = (dist != 1 && dist != 4 && dist != 5) ? TRUE : FALSE;
2535 while ((otmp = sobj_at(BOULDER, x, y)) != 0) {
2536 if (make_rocks) {
2537 fracture_rock(otmp);
2538 make_rocks = FALSE; /* don't bother with more rocks */
2539 } else {
2540 obj_extract_self(otmp);
2541 obfree(otmp, (struct obj *) 0);
2542 }
2543 }
2544
2545 /* fake out saved state */
2546 lev->seenv = 0;
2547 lev->doormask = 0;
2548 if (dist < 6)
2549 lev->lit = TRUE;
2550 lev->waslit = TRUE;
2551 lev->horizontal = FALSE;
2552 /* short-circuit vision recalc */
2553 gv.viz_array[y][x] = (dist < 6) ? (IN_SIGHT | COULD_SEE) : COULD_SEE;
2554
2555 switch (dist) {
2556 case 1: /* fire traps */
2557 if (is_pool(x, y))
2558 break;
2559 lev->typ = ROOM;

Callers 1

mkinvokeareaFunction · 0.85

Calls 15

isokFunction · 0.85
t_atFunction · 0.85
deltrapFunction · 0.85
sobj_atFunction · 0.85
fracture_rockFunction · 0.85
obj_extract_selfFunction · 0.85
obfreeFunction · 0.85
is_poolFunction · 0.85
maketrapFunction · 0.85
seemimicFunction · 0.85
mintrapFunction · 0.85
minliquidFunction · 0.85

Tested by

no test coverage detected