]> granicus.if.org Git - nethack/commitdiff
description of stair destination for level 1 up
authorPatR <rankin@nethack.org>
Thu, 5 Aug 2021 20:46:20 +0000 (13:46 -0700)
committerPatR <rankin@nethack.org>
Thu, 5 Aug 2021 20:46:20 +0000 (13:46 -0700)
Having the opposite side of the stairs up from level 1 be unknown is
weird because the hero conceptually just came down those stairs at
the start of the game.  But it's tricky because remote destination
varies depending on whether the Amulet is being carried.  This gives
an accurate description of where the stairs lead (if you step on
them with the 'mention_decor' option On, or use the ':' command when
already on them).

|"There is a staircase up out of the dungeon here."
or
|"There is a branch staircase up to the Elemental Planes here."

It gives away a little information when carrying the Amulet, but not
much and anyone who gets that far deserves a break.

src/dungeon.c
src/mklev.c

index 5bd33e25d141253bb1b28c1c857d25b39c13c35c..5738a36a56dc8899f11c8a8456deff47a80b342c 100644 (file)
@@ -1464,7 +1464,7 @@ u_on_rndspot(int upflag)
 void
 stairway_add(int x, int y, boolean up, boolean isladder, d_level *dest)
 {
-    stairway *tmp = (stairway *)alloc(sizeof(stairway));
+    stairway *tmp = (stairway *) alloc(sizeof (stairway));
 
     tmp->sx = x;
     tmp->sy = y;
@@ -1701,8 +1701,8 @@ get_level(d_level *newlevel, int levnum)
     if (levnum <= 0) {
         /* can only currently happen in endgame */
         levnum = u.uz.dlevel;
-    } else if (levnum
-               > g.dungeons[dgn].depth_start + g.dungeons[dgn].num_dunlevs - 1) {
+    } else if (levnum > (g.dungeons[dgn].depth_start
+                         + g.dungeons[dgn].num_dunlevs - 1)) {
         /* beyond end of dungeon, jump to last level */
         levnum = g.dungeons[dgn].num_dunlevs;
     } else {
@@ -2147,6 +2147,22 @@ stairs_description(
 
             Sprintf(eos(outbuf), " to level %d", to_dlev);
         }
+    } else if (u.uz.dnum == 0 && u.uz.dlevel == 1 && sway->up) {
+        /* stairs up from level one are a special case; they are marked
+           as having been traversed because the hero obviously started
+           the game by coming down them, but the remote side varies
+           depending on whether the Amulet is being carried */
+        Sprintf(outbuf, "%s%s %s %s",
+                !u.uhave.amulet ? "" : "branch ",
+                stairs, updown,
+                !u.uhave.amulet ? "out of the dungeon"
+                /* minimize our expectations about what comes next */
+                : (on_level(&tolev, &earth_level)
+                   || on_level(&tolev, &air_level)
+                   || on_level(&tolev, &fire_level)
+                   || on_level(&tolev, &water_level))
+                  ? "to the Elemental Planes"
+                  : "to the end game");
     } else {
         /* known branch stairs; tacking on destination level is too verbose */
         Sprintf(outbuf, "branch %s %s to %s",
index 6c639ded05f14de2e4e262c05e7771ddf326bd45..6b4aab52b6191e6ba15755a882fa59ade8197f3a 100644 (file)
@@ -836,6 +836,7 @@ makelevel(void)
 {
     register struct mkroom *croom;
     branch *branchp;
+    stairway *prevstairs;
     int room_threshold;
     register s_level *slev = Is_special(&u.uz);
     int i;
@@ -950,9 +951,17 @@ makelevel(void)
             do_mkroom(COCKNEST);
 
  skip0:
+        prevstairs = g.stairs; /* used to test for place_branch() success */
         /* Place multi-dungeon branch. */
         place_branch(branchp, 0, 0);
 
+        /* for main dungeon level 1, the stairs up where the hero starts
+           are branch stairs; treat them as if hero had just come down
+           them by marking them as having been traversed; most recently
+           created stairway is held in 'g.stairs' */
+        if (u.uz.dnum == 0 && u.uz.dlevel == 1 && g.stairs != prevstairs)
+            g.stairs->u_traversed = TRUE;
+
         /* for each room: put things inside */
         for (croom = g.rooms; croom->hx > 0; croom++) {
             fill_ordinary_room(croom);
@@ -1252,7 +1261,7 @@ place_branch(branch *br,       /* branch to place */
         boolean goes_up = on_level(&br->end1, &u.uz) ? br->end1_up
                                                      : !br->end1_up;
 
-        stairway_add(x,y, goes_up, FALSE, dest);
+        stairway_add(x, y, goes_up, FALSE, dest);
         levl[x][y].ladder = goes_up ? LA_UP : LA_DOWN;
         levl[x][y].typ = STAIRS;
     }