Reveal branch stairs only after traversing them

This commit is contained in:
Pasi Kallinen
2021-07-30 19:32:26 +03:00
parent 4f594659dc
commit d463a9e258
5 changed files with 20 additions and 8 deletions

View 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;

View 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.

View File

@@ -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();

View 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) {

View 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;
}
}