From: Pasi Kallinen Date: Fri, 30 Jul 2021 16:32:26 +0000 (+0300) Subject: Reveal branch stairs only after traversing them X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d463a9e2588a97f6d2ae7b49ba559423677d8b76;p=nethack Reveal branch stairs only after traversing them --- diff --git a/include/dungeon.h b/include/dungeon.h index 7a07e58f4..e072b935a 100644 --- a/include/dungeon.h +++ b/include/dungeon.h @@ -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; diff --git a/include/patchlevel.h b/include/patchlevel.h index a8eeb0764..8dd7a21fb 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -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. diff --git a/src/do.c b/src/do.c index 6fe8bfcdb..55ed926bf 100644 --- 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(); diff --git a/src/dungeon.c b/src/dungeon.c index ccd92335e..4ab6c62de 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -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) { diff --git a/src/restore.c b/src/restore.c index 0e62ac05b..54a9cdf20 100644 --- a/src/restore.c +++ b/src/restore.c @@ -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; } }