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