Reveal branch stairs only after traversing them

This commit is contained in:
Pasi Kallinen
2021-07-30 19:40:54 +03:00
parent 4f594659dc
commit d463a9e258
5 changed files with 20 additions and 8 deletions
+1
View File
@@ -36,6 +36,7 @@ typedef struct stairway { /* basic stairway identifier */
d_level tolev; /* where does it go */ d_level tolev; /* where does it go */
boolean up; /* up or down? */ boolean up; /* up or down? */
boolean isladder; /* ladder or stairway? */ boolean isladder; /* ladder or stairway? */
boolean u_traversed; /* hero has traversed this stair */
struct stairway *next; struct stairway *next;
} stairway; } stairway;
+1 -1
View File
@@ -17,7 +17,7 @@
* Incrementing EDITLEVEL can be used to force invalidation of old bones * Incrementing EDITLEVEL can be used to force invalidation of old bones
* and save files. * and save files.
*/ */
#define EDITLEVEL 37 #define EDITLEVEL 38
/* /*
* Development status possibilities. * Development status possibilities.
+6 -4
View File
@@ -1525,9 +1525,10 @@ goto_level(
} else if (at_stairs && !In_endgame(&u.uz)) { } else if (at_stairs && !In_endgame(&u.uz)) {
if (up) { if (up) {
stairway *stway = stairway_find_from(&u.uz0, g.at_ladder); stairway *stway = stairway_find_from(&u.uz0, g.at_ladder);
if (stway) if (stway) {
u_on_newpos(stway->sx, stway->sy); u_on_newpos(stway->sx, stway->sy);
else if (newdungeon) stway->u_traversed = TRUE;
} else if (newdungeon)
u_on_sstairs(1); u_on_sstairs(1);
else else
u_on_dnstairs(); u_on_dnstairs();
@@ -1542,9 +1543,10 @@ goto_level(
g.at_ladder ? "ladder" : "stairs"); g.at_ladder ? "ladder" : "stairs");
} else { /* down */ } else { /* down */
stairway *stway = stairway_find_from(&u.uz0, g.at_ladder); stairway *stway = stairway_find_from(&u.uz0, g.at_ladder);
if (stway) if (stway) {
u_on_newpos(stway->sx, stway->sy); u_on_newpos(stway->sx, stway->sy);
else if (newdungeon) stway->u_traversed = TRUE;
} else if (newdungeon)
u_on_sstairs(0); u_on_sstairs(0);
else else
u_on_upstairs(); u_on_upstairs();
+8 -3
View File
@@ -1361,6 +1361,9 @@ next_level(boolean at_stairs)
stairway *stway = stairway_at(u.ux, u.uy); stairway *stway = stairway_at(u.ux, u.uy);
d_level newlevel; d_level newlevel;
if (at_stairs && stway)
stway->u_traversed = TRUE;
if (at_stairs && stway) { if (at_stairs && stway) {
newlevel.dnum = stway->tolev.dnum; newlevel.dnum = stway->tolev.dnum;
newlevel.dlevel = stway->tolev.dlevel; newlevel.dlevel = stway->tolev.dlevel;
@@ -1379,6 +1382,9 @@ prev_level(boolean at_stairs)
stairway *stway = stairway_at(u.ux, u.uy); stairway *stway = stairway_at(u.ux, u.uy);
d_level newlevel; d_level newlevel;
if (at_stairs && stway)
stway->u_traversed = TRUE;
if (at_stairs && stway && stway->tolev.dnum != u.uz.dnum) { if (at_stairs && stway && stway->tolev.dnum != u.uz.dnum) {
/* Taking an up dungeon branch. */ /* Taking an up dungeon branch. */
/* KMH -- Upwards branches are okay if not level 1 */ /* 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->sy = y;
tmp->up = up; tmp->up = up;
tmp->isladder = isladder; tmp->isladder = isladder;
tmp->u_traversed = FALSE;
assign_level(&(tmp->tolev), dest); assign_level(&(tmp->tolev), dest);
tmp->next = g.stairs; tmp->next = g.stairs;
g.stairs = tmp; g.stairs = tmp;
@@ -2106,8 +2113,6 @@ tport_menu(winid win, char *entry, struct lchoice *lchoices,
return; return;
} }
/* this is only an approximation; to make it accurate, the stair list
should track which stairs have been traversed */
boolean boolean
known_branch_stairs(stairway *sway, char *outbuf, boolean stcase) 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); ledgr = ledger_no(&tolev);
dest_visited = (g.level_info[ledgr].flags & VISITED) != 0; 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) { if (outbuf) {
Sprintf(outbuf, "%s %s", stairs, updown); Sprintf(outbuf, "%s %s", stairs, updown);
if (dest_visited) { if (dest_visited) {
+4
View File
@@ -894,6 +894,7 @@ rest_stairs(NHFILE* nhfp)
int buflen = 0; int buflen = 0;
stairway stway = UNDEFINED_VALUES; stairway stway = UNDEFINED_VALUES;
int len = 0; int len = 0;
stairway *newst;
stairway_free_all(); stairway_free_all();
while (1) { while (1) {
@@ -915,6 +916,9 @@ rest_stairs(NHFILE* nhfp)
} }
stairway_add(stway.sx, stway.sy, stway.up, stway.isladder, stairway_add(stway.sx, stway.sy, stway.up, stway.isladder,
&(stway.tolev)); &(stway.tolev));
newst = stairway_at(stway.sx, stway.sy);
if (newst)
newst->u_traversed = stway.u_traversed;
} }
} }