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

Function prev_level

src/dungeon.c:1517–1543  ·  view source on GitHub ↗

goto the previous level (or appropriate dungeon) */

Source from the content-addressed store, hash-verified

1515
1516/* goto the previous level (or appropriate dungeon) */
1517void
1518prev_level(boolean at_stairs)
1519{
1520 stairway *stway = stairway_at(u.ux, u.uy);
1521 d_level newlevel;
1522
1523 if (at_stairs && stway)
1524 stway->u_traversed = TRUE;
1525
1526 if (at_stairs && stway && stway->tolev.dnum != u.uz.dnum) {
1527 /* Taking an up dungeon branch. */
1528 /* KMH -- Upwards branches are okay if not level 1 */
1529 /* (Just make sure it doesn't go above depth 1) */
1530 if (!u.uz.dnum && u.uz.dlevel == 1 && !u.uhave.amulet)
1531 done(ESCAPED);
1532 else {
1533 newlevel.dnum = stway->tolev.dnum;
1534 newlevel.dlevel = stway->tolev.dlevel;
1535 goto_level(&newlevel, at_stairs, FALSE, FALSE);
1536 }
1537 } else {
1538 /* Going up a stairs or rising through the ceiling. */
1539 newlevel.dnum = u.uz.dnum;
1540 newlevel.dlevel = u.uz.dlevel - 1;
1541 goto_level(&newlevel, at_stairs, FALSE, FALSE);
1542 }
1543}
1544
1545/* Dwarves have "earth sense",
1546 able to sense if something is buried under their feet */

Callers 1

doupFunction · 0.85

Calls 3

stairway_atFunction · 0.85
doneFunction · 0.85
goto_levelFunction · 0.85

Tested by

no test coverage detected