]> granicus.if.org Git - nethack/commitdiff
Reveal branch stairs only after traversing them
authorPasi Kallinen <paxed@alt.org>
Fri, 30 Jul 2021 16:32:26 +0000 (19:32 +0300)
committerPasi Kallinen <paxed@alt.org>
Fri, 30 Jul 2021 16:40:54 +0000 (19:40 +0300)
include/dungeon.h
include/patchlevel.h
src/do.c
src/dungeon.c
src/restore.c

index 7a07e58f449e8319e11991fb1a5f3985df97a90a..e072b935a7b3f97028b6c44f15dde2689db50eb9 100644 (file)
@@ -36,6 +36,7 @@ typedef struct stairway { /* basic stairway identifier */
     d_level tolev;        /* where does it go */
     boolean up;           /* up or down? */
     boolean isladder;     /* ladder or stairway? */
+    boolean u_traversed;  /* hero has traversed this stair */
     struct stairway *next;
 } stairway;
 
index a8eeb0764a303a9106117d7aaa197f8713d5cece..8dd7a21fbf9a4aef2493c3c4d1762084d12a0526 100644 (file)
@@ -17,7 +17,7 @@
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL 37
+#define EDITLEVEL 38
 
 /*
  * Development status possibilities.
index 6fe8bfcdbb630d5343735178359fd32aabb417f7..55ed926bf78f54583368db0d557bca0a6a209c73 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -1525,9 +1525,10 @@ goto_level(
     } else if (at_stairs && !In_endgame(&u.uz)) {
         if (up) {
             stairway *stway = stairway_find_from(&u.uz0, g.at_ladder);
-            if (stway)
+            if (stway) {
                 u_on_newpos(stway->sx, stway->sy);
-            else if (newdungeon)
+                stway->u_traversed = TRUE;
+            } else if (newdungeon)
                 u_on_sstairs(1);
             else
                 u_on_dnstairs();
@@ -1542,9 +1543,10 @@ goto_level(
                       g.at_ladder ? "ladder" : "stairs");
         } else { /* down */
             stairway *stway = stairway_find_from(&u.uz0, g.at_ladder);
-            if (stway)
+            if (stway) {
                 u_on_newpos(stway->sx, stway->sy);
-            else if (newdungeon)
+                stway->u_traversed = TRUE;
+            } else if (newdungeon)
                 u_on_sstairs(0);
             else
                 u_on_upstairs();
index ccd92335e8df53b2fe13ebd173fd3dcb2f6c8bfd..4ab6c62de5bc307dc4a55d5f42cd395df0386a03 100644 (file)
@@ -1361,6 +1361,9 @@ next_level(boolean at_stairs)
     stairway *stway = stairway_at(u.ux, u.uy);
     d_level newlevel;
 
+    if (at_stairs && stway)
+        stway->u_traversed = TRUE;
+
     if (at_stairs && stway) {
         newlevel.dnum = stway->tolev.dnum;
         newlevel.dlevel = stway->tolev.dlevel;
@@ -1379,6 +1382,9 @@ prev_level(boolean at_stairs)
     stairway *stway = stairway_at(u.ux, u.uy);
     d_level newlevel;
 
+    if (at_stairs && stway)
+        stway->u_traversed = TRUE;
+
     if (at_stairs && stway && stway->tolev.dnum != u.uz.dnum) {
         /* Taking an up dungeon branch. */
         /* KMH -- Upwards branches are okay if not level 1 */
@@ -1464,6 +1470,7 @@ stairway_add(int x, int y, boolean up, boolean isladder, d_level *dest)
     tmp->sy = y;
     tmp->up = up;
     tmp->isladder = isladder;
+    tmp->u_traversed = FALSE;
     assign_level(&(tmp->tolev), dest);
     tmp->next = g.stairs;
     g.stairs = tmp;
@@ -2106,8 +2113,6 @@ tport_menu(winid win, char *entry, struct lchoice *lchoices,
     return;
 }
 
-/* this is only an approximation; to make it accurate, the stair list
-   should track which stairs have been traversed */
 boolean
 known_branch_stairs(stairway *sway, char *outbuf, boolean stcase)
 {
@@ -2126,7 +2131,7 @@ known_branch_stairs(stairway *sway, char *outbuf, boolean stcase)
     ledgr = ledger_no(&tolev);
     dest_visited = (g.level_info[ledgr].flags & VISITED) != 0;
 
-    if (tolev.dnum == u.uz.dnum || !dest_visited) {
+    if (tolev.dnum == u.uz.dnum || !sway->u_traversed) {
         if (outbuf) {
             Sprintf(outbuf, "%s %s", stairs, updown);
             if (dest_visited) {
index 0e62ac05b027b2b6cf08263d2bb6efdd8d70f295..54a9cdf20454d466fd9f34b2db36fa6e206014ca 100644 (file)
@@ -894,6 +894,7 @@ rest_stairs(NHFILE* nhfp)
     int buflen = 0;
     stairway stway = UNDEFINED_VALUES;
     int len = 0;
+    stairway *newst;
 
     stairway_free_all();
     while (1) {
@@ -915,6 +916,9 @@ rest_stairs(NHFILE* nhfp)
         }
         stairway_add(stway.sx, stway.sy, stway.up, stway.isladder,
                      &(stway.tolev));
+        newst = stairway_at(stway.sx, stway.sy);
+        if (newst)
+            newst->u_traversed = stway.u_traversed;
     }
 }