fix #H7707 - terrain change leaving stale flags

struct rm.flags in overloaded for a bunch of rm.typ -dependent things
(doormask, altarmask, throne/fountain/sink looted, a few others) and
wasn't being reset for various cases where rm.typ gets changed.

I've changed a lot, some no doubt unnecessarily, and probably missed
plenty.  This compiles but has not been thoroughly tested.
This commit is contained in:
PatR
2018-12-10 03:52:00 -08:00
parent d680066343
commit 9c422f2c1f
9 changed files with 71 additions and 65 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 apply.c $NHDT-Date: 1542765339 2018/11/21 01:55:39 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.254 $ */
/* NetHack 3.6 apply.c $NHDT-Date: 1544442708 2018/12/10 11:51:48 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.269 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -418,7 +418,7 @@ register struct obj *obj;
return res;
case SCORR:
You_hear(hollow_str, "passage");
lev->typ = CORR;
lev->typ = CORR, lev->flags = 0;
unblock_point(rx, ry);
feel_newsym(rx, ry);
return res;
@@ -3394,7 +3394,7 @@ struct obj *obj;
*/
typ = fillholetyp(x, y, FALSE);
if (typ != ROOM) {
levl[x][y].typ = typ;
levl[x][y].typ = typ, levl[x][y].flags = 0;
liquid_flow(x, y, typ, t_at(x, y),
fillmsg
? (char *) 0

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 dig.c $NHDT-Date: 1542765354 2018/11/21 01:55:54 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.115 $ */
/* NetHack 3.6 dig.c $NHDT-Date: 1544442710 2018/12/10 11:51:50 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.116 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -81,7 +81,7 @@ boolean waslit, rockit;
lev->horizontal = FALSE;
/* short-circuit vision recalc */
viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) : COULD_SEE;
lev->typ = (rockit ? STONE : ROOM);
lev->typ = (rockit ? STONE : ROOM); /* flags set via doormask above */
if (dist >= 3)
impossible("mkcavepos called with dist %d", dist);
feel_newsym(x, y);
@@ -129,7 +129,7 @@ register boolean rockit;
}
if (!rockit && levl[u.ux][u.uy].typ == CORR) {
levl[u.ux][u.uy].typ = ROOM;
levl[u.ux][u.uy].typ = ROOM; /* flags for CORR already 0 */
if (waslit)
levl[u.ux][u.uy].waslit = TRUE;
newsym(u.ux, u.uy); /* in case player is invisible */
@@ -361,9 +361,9 @@ dig(VOID_ARGS)
}
if (context.digging.effort > 100) {
register const char *digtxt, *dmgtxt = (const char *) 0;
register struct obj *obj;
register boolean shopedge = *in_rooms(dpx, dpy, SHOPBASE);
const char *digtxt, *dmgtxt = (const char *) 0;
struct obj *obj;
boolean shopedge = *in_rooms(dpx, dpy, SHOPBASE);
if ((obj = sobj_at(STATUE, dpx, dpy)) != 0) {
if (break_statue(obj))
@@ -397,12 +397,12 @@ dig(VOID_ARGS)
}
if (IS_TREE(lev->typ)) {
digtxt = "You cut down the tree.";
lev->typ = ROOM;
lev->typ = ROOM, lev->flags = 0;
if (!rn2(5))
(void) rnd_treefruit_at(dpx, dpy);
} else {
digtxt = "You succeed in cutting away some rock.";
lev->typ = CORR;
lev->typ = CORR, lev->flags = 0;
}
} else if (IS_WALL(lev->typ)) {
if (shopedge) {
@@ -410,12 +410,11 @@ dig(VOID_ARGS)
dmgtxt = "damage";
}
if (level.flags.is_maze_lev) {
lev->typ = ROOM;
lev->typ = ROOM, lev->flags = 0;
} else if (level.flags.is_cavernous_lev && !in_town(dpx, dpy)) {
lev->typ = CORR;
lev->typ = CORR, lev->flags = 0;
} else {
lev->typ = DOOR;
lev->doormask = D_NODOOR;
lev->typ = DOOR, lev->doormask = D_NODOOR;
}
digtxt = "You make an opening in the wall.";
} else if (lev->typ == SDOOR) {
@@ -573,6 +572,7 @@ int ttyp;
} else if (lev->typ == DRAWBRIDGE_DOWN
|| (is_drawbridge_wall(x, y) >= 0)) {
int bx = x, by = y;
/* if under the portcullis, the bridge is adjacent */
(void) find_drawbridge(&bx, &by);
destroy_drawbridge(bx, by);
@@ -853,6 +853,7 @@ coord *cc;
} else {
typ = fillholetyp(dig_x, dig_y, FALSE);
lev->flags = 0;
if (typ != ROOM) {
lev->typ = typ;
liquid_flow(dig_x, dig_y, typ, ttmp,
@@ -935,7 +936,7 @@ coord *cc;
pline_The("grave seems unused. Strange....");
break;
}
levl[dig_x][dig_y].typ = ROOM;
levl[dig_x][dig_y].typ = ROOM, levl[dig_x][dig_y].flags = 0;
del_engr_at(dig_x, dig_y);
newsym(dig_x, dig_y);
return;
@@ -1272,7 +1273,7 @@ register struct monst *mtmp;
newsym(mtmp->mx, mtmp->my);
return FALSE;
} else if (here->typ == SCORR) {
here->typ = CORR;
here->typ = CORR, here->flags = 0;
unblock_point(mtmp->mx, mtmp->my);
newsym(mtmp->mx, mtmp->my);
draft_message(FALSE); /* "You feel a draft." */
@@ -1297,20 +1298,19 @@ register struct monst *mtmp;
if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
add_damage(mtmp->mx, mtmp->my, 0L);
if (level.flags.is_maze_lev) {
here->typ = ROOM;
here->typ = ROOM, here->flags = 0;
} else if (level.flags.is_cavernous_lev
&& !in_town(mtmp->mx, mtmp->my)) {
here->typ = CORR;
here->typ = CORR, here->flags = 0;
} else {
here->typ = DOOR;
here->doormask = D_NODOOR;
here->typ = DOOR, here->doormask = D_NODOOR;
}
} else if (IS_TREE(here->typ)) {
here->typ = ROOM;
here->typ = ROOM, here->flags = 0;
if (pile && pile < 5)
(void) rnd_treefruit_at(mtmp->mx, mtmp->my);
} else {
here->typ = CORR;
here->typ = CORR, here->flags = 0;
if (pile && pile < 5)
(void) mksobj_at((pile == 1) ? BOULDER : ROCK, mtmp->mx, mtmp->my,
TRUE, FALSE);
@@ -1495,7 +1495,7 @@ zap_dig()
shopdoor = TRUE;
}
if (room->typ == SDOOR)
room->typ = DOOR;
room->typ = DOOR; /* doormask set below */
else if (cansee(zx, zy))
pline_The("door is razed!");
watch_dig((struct monst *) 0, zx, zy, TRUE);
@@ -1511,21 +1511,21 @@ zap_dig()
add_damage(zx, zy, SHOP_WALL_COST);
shopwall = TRUE;
}
room->typ = ROOM;
room->typ = ROOM, room->flags = 0;
unblock_point(zx, zy); /* vision */
} else if (!Blind)
pline_The("wall glows then fades.");
break;
} else if (IS_TREE(room->typ)) { /* check trees before stone */
if (!(room->wall_info & W_NONDIGGABLE)) {
room->typ = ROOM;
room->typ = ROOM, room->flags = 0;
unblock_point(zx, zy); /* vision */
} else if (!Blind)
pline_The("tree shudders but is unharmed.");
break;
} else if (room->typ == STONE || room->typ == SCORR) {
if (!(room->wall_info & W_NONDIGGABLE)) {
room->typ = CORR;
room->typ = CORR, room->flags = 0;
unblock_point(zx, zy); /* vision */
} else if (!Blind)
pline_The("rock glows then fades.");
@@ -1541,17 +1541,16 @@ zap_dig()
}
watch_dig((struct monst *) 0, zx, zy, TRUE);
if (level.flags.is_cavernous_lev && !in_town(zx, zy)) {
room->typ = CORR;
room->typ = CORR, room->flags = 0;
} else {
room->typ = DOOR;
room->doormask = D_NODOOR;
room->typ = DOOR, room->doormask = D_NODOOR;
}
digdepth -= 2;
} else if (IS_TREE(room->typ)) {
room->typ = ROOM;
room->typ = ROOM, room->flags = 0;
digdepth -= 2;
} else { /* IS_ROCK but not IS_WALL or SDOOR */
room->typ = CORR;
room->typ = CORR, room->flags = 0;
digdepth--;
}
unblock_point(zx, zy); /* vision */
@@ -1563,8 +1562,10 @@ zap_dig()
if (pitflow && isok(flow_x, flow_y)) {
struct trap *ttmp = t_at(flow_x, flow_y);
if (ttmp && is_pit(ttmp->ttyp)) {
schar filltyp = fillholetyp(ttmp->tx, ttmp->ty, TRUE);
if (filltyp != ROOM)
pit_flow(ttmp, filltyp);
}
@@ -1589,7 +1590,7 @@ char *msg;
int ltyp;
struct rm *room;
const char *foundation_msg =
"The foundation is too hard to dig through from this angle.";
"The foundation is too hard to dig through from this angle.";
if (!cc)
return FALSE;
@@ -1597,7 +1598,7 @@ char *msg;
return FALSE;
*msg = '\0';
room = &levl[cc->x][cc->y];
ltyp = room->typ;
ltyp = room->typ, room->flags = 0;
if (is_pool(cc->x, cc->y) || is_lava(cc->x, cc->y)) {
/* this is handled by the caller after we return FALSE */
@@ -1677,15 +1678,14 @@ pit_flow(trap, filltyp)
struct trap *trap;
schar filltyp;
{
if (trap && (filltyp != ROOM)
&& is_pit(trap->ttyp)) {
if (trap && filltyp != ROOM && is_pit(trap->ttyp)) {
struct trap t;
int idx;
t = *trap;
levl[trap->tx][trap->ty].typ = filltyp;
liquid_flow(trap->tx, trap->ty, filltyp, trap,
(trap->tx == u.ux && trap->ty == u.uy)
levl[t.tx][t.ty].typ = filltyp, levl[t.tx][t.ty].flags = 0;
liquid_flow(t.tx, t.ty, filltyp, trap,
(t.tx == u.ux && t.ty == u.uy)
? "Suddenly %s flows in from the adjacent pit!"
: (char *) 0);
for (idx = 0; idx < 8; ++idx) {

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do.c $NHDT-Date: 1543972190 2018/12/05 01:09:50 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.176 $ */
/* NetHack 3.6 do.c $NHDT-Date: 1544442710 2018/12/10 11:51:50 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.177 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -67,7 +67,7 @@ boolean pushing;
levl[rx][ry].drawbridgemask &= ~DB_UNDER; /* clear lava */
levl[rx][ry].drawbridgemask |= DB_FLOOR;
} else
levl[rx][ry].typ = ROOM;
levl[rx][ry].typ = ROOM, levl[rx][ry].flags = 0;
if (ttmp)
(void) delfloortrap(ttmp);
@@ -276,22 +276,29 @@ STATIC_DCL void
polymorph_sink()
{
uchar sym = S_sink;
boolean sinklooted;
if (levl[u.ux][u.uy].typ != SINK)
return;
sinklooted = levl[u.ux][u.uy].looted != 0;
level.flags.nsinks--;
levl[u.ux][u.uy].doormask = 0;
levl[u.ux][u.uy].doormask = 0; /* levl[][].flags */
switch (rn2(4)) {
default:
case 0:
sym = S_fountain;
levl[u.ux][u.uy].typ = FOUNTAIN;
levl[u.ux][u.uy].blessedftn = 0;
if (sinklooted)
SET_FOUNTAIN_LOOTED(u.ux, u.uy);
level.flags.nfountains++;
break;
case 1:
sym = S_throne;
levl[u.ux][u.uy].typ = THRONE;
if (sinklooted)
levl[u.ux][u.uy].looted = T_LOOTED;
break;
case 2:
sym = S_altar;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 fountain.c $NHDT-Date: 1455402364 2016/02/13 22:26:04 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.56 $ */
/* NetHack 3.6 fountain.c $NHDT-Date: 1544442711 2018/12/10 11:51:51 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.60 $ */
/* Copyright Scott R. Turner, srt@ucla, 10/27/86 */
/* NetHack may be freely redistributed. See license for details. */
@@ -137,7 +137,7 @@ genericptr_t poolcnt;
pline("Water gushes forth from the overflowing fountain!");
/* Put a pool at x, y */
levl[x][y].typ = POOL;
levl[x][y].typ = POOL, levl[x][y].flags = 0;
/* No kelp! */
del_engr_at(x, y);
water_damage_chain(level.objects[x][y], TRUE);
@@ -205,8 +205,7 @@ boolean isyou;
return;
}
/* replace the fountain with ordinary floor */
levl[x][y].typ = ROOM;
levl[x][y].looted = 0;
levl[x][y].typ = ROOM, levl[x][y].flags = 0;
levl[x][y].blessedftn = 0;
if (cansee(x, y))
pline_The("fountain dries up!");
@@ -397,8 +396,7 @@ register struct obj *obj;
exercise(A_WIS, TRUE);
}
update_inventory();
levl[u.ux][u.uy].typ = ROOM;
levl[u.ux][u.uy].looted = 0;
levl[u.ux][u.uy].typ = ROOM, levl[u.ux][u.uy].flags = 0;
newsym(u.ux, u.uy);
level.flags.nfountains--;
if (in_town(u.ux, u.uy))
@@ -511,8 +509,9 @@ int x, y;
if (cansee(x, y) || (x == u.ux && y == u.uy))
pline_The("pipes break! Water spurts out!");
level.flags.nsinks--;
levl[x][y].doormask = 0;
levl[x][y].typ = FOUNTAIN;
levl[x][y].typ = FOUNTAIN, levl[x][y].looted = 0;
levl[x][y].blessedftn = 0;
SET_FOUNTAIN_LOOTED(x, y);
level.flags.nfountains++;
newsym(x, y);
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 lock.c $NHDT-Date: 1521499715 2018/03/19 22:48:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.80 $ */
/* NetHack 3.6 lock.c $NHDT-Date: 1544442712 2018/12/10 11:51:52 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.82 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -950,7 +950,7 @@ int x, y;
return FALSE;
}
block_point(x, y);
door->typ = SDOOR;
door->typ = SDOOR, door->doormask = D_NODOOR;
if (vis)
pline_The("doorway vanishes!");
newsym(x, y);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 monmove.c $NHDT-Date: 1517877380 2018/02/06 00:36:20 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.96 $ */
/* NetHack 3.6 monmove.c $NHDT-Date: 1544442712 2018/12/10 11:51:52 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.109 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1474,6 +1474,7 @@ dissolve_bars(x, y)
register int x, y;
{
levl[x][y].typ = (Is_special(&u.uz) || *in_rooms(x, y, 0)) ? ROOM : CORR;
levl[x][y].flags = 0;
newsym(x, y);
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 music.c $NHDT-Date: 1542765361 2018/11/21 01:56:01 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.56 $ */
/* NetHack 3.6 music.c $NHDT-Date: 1544442713 2018/12/10 11:51:53 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.57 $ */
/* Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */
@@ -320,7 +320,7 @@ int force;
*/
filltype = fillholetyp(x, y, FALSE);
if (filltype != ROOM) {
levl[x][y].typ = filltype;
levl[x][y].typ = filltype; /* flags set via doormask */
liquid_flow(x, y, filltype, chasm, (char *) 0);
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 sit.c $NHDT-Date: 1458341129 2016/03/18 22:45:29 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.53 $ */
/* NetHack 3.6 sit.c $NHDT-Date: 1544442714 2018/12/10 11:51:54 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.59 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -281,7 +281,7 @@ dosit()
if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ)) {
/* may have teleported */
levl[u.ux][u.uy].typ = ROOM;
levl[u.ux][u.uy].typ = ROOM, levl[u.ux][u.uy].flags = 0;
pline_The("throne vanishes in a puff of logic.");
newsym(u.ux, u.uy);
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 zap.c $NHDT-Date: 1544230271 2018/12/08 00:51:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.301 $ */
/* NetHack 3.6 zap.c $NHDT-Date: 1544442714 2018/12/10 11:51:54 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.302 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -4374,7 +4374,7 @@ short exploding_wand_typ;
msgtxt = "Some water evaporates.";
} else {
rangemod -= 3;
lev->typ = ROOM;
lev->typ = ROOM, lev->flags = 0;
t = maketrap(x, y, PIT);
if (t)
t->tseen = 1;
@@ -4413,9 +4413,9 @@ short exploding_wand_typ;
lev->drawbridgemask &= ~DB_UNDER; /* clear lava */
lev->drawbridgemask |= (lava ? DB_FLOOR : DB_ICE);
} else {
if (!lava)
lev->icedpool = (lev->typ == POOL) ? ICED_POOL
: ICED_MOAT;
lev->icedpool = lava ? 0
: (lev->typ == POOL) ? ICED_POOL
: ICED_MOAT;
lev->typ = lava ? ROOM : ICE;
}
bury_objs(x, y);
@@ -4490,15 +4490,14 @@ short exploding_wand_typ;
Norep("The %s melt.", defsyms[S_bars].explanation);
if (*in_rooms(x, y, SHOPBASE)) {
/* in case we ever have a shop bounded by bars */
lev->typ = ROOM;
lev->typ = ROOM, lev->flags = 0;
if (see_it)
newsym(x, y);
add_damage(x, y, (type >= 0) ? SHOP_BARS_COST : 0L);
if (type >= 0)
*shopdamage = TRUE;
} else {
lev->typ = DOOR;
lev->doormask = D_NODOOR;
lev->typ = DOOR, lev->doormask = D_NODOOR;
if (see_it)
newsym(x, y);
}