Skip to content

Commit 9c422f2

Browse files
author
PatR
committed
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.
1 parent d680066 commit 9c422f2

File tree

9 files changed

+71
-65
lines changed

9 files changed

+71
-65
lines changed

src/apply.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* 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 $ */
1+
/* 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 $ */
22
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
33
/*-Copyright (c) Robert Patrick Rankin, 2012. */
44
/* NetHack may be freely redistributed. See license for details. */
@@ -418,7 +418,7 @@ register struct obj *obj;
418418
return res;
419419
case SCORR:
420420
You_hear(hollow_str, "passage");
421-
lev->typ = CORR;
421+
lev->typ = CORR, lev->flags = 0;
422422
unblock_point(rx, ry);
423423
feel_newsym(rx, ry);
424424
return res;
@@ -3394,7 +3394,7 @@ struct obj *obj;
33943394
*/
33953395
typ = fillholetyp(x, y, FALSE);
33963396
if (typ != ROOM) {
3397-
levl[x][y].typ = typ;
3397+
levl[x][y].typ = typ, levl[x][y].flags = 0;
33983398
liquid_flow(x, y, typ, t_at(x, y),
33993399
fillmsg
34003400
? (char *) 0

src/dig.c

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* 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 $ */
1+
/* 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 $ */
22
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
33
/*-Copyright (c) Michael Allison, 2012. */
44
/* NetHack may be freely redistributed. See license for details. */
@@ -81,7 +81,7 @@ boolean waslit, rockit;
8181
lev->horizontal = FALSE;
8282
/* short-circuit vision recalc */
8383
viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) : COULD_SEE;
84-
lev->typ = (rockit ? STONE : ROOM);
84+
lev->typ = (rockit ? STONE : ROOM); /* flags set via doormask above */
8585
if (dist >= 3)
8686
impossible("mkcavepos called with dist %d", dist);
8787
feel_newsym(x, y);
@@ -129,7 +129,7 @@ register boolean rockit;
129129
}
130130

131131
if (!rockit && levl[u.ux][u.uy].typ == CORR) {
132-
levl[u.ux][u.uy].typ = ROOM;
132+
levl[u.ux][u.uy].typ = ROOM; /* flags for CORR already 0 */
133133
if (waslit)
134134
levl[u.ux][u.uy].waslit = TRUE;
135135
newsym(u.ux, u.uy); /* in case player is invisible */
@@ -361,9 +361,9 @@ dig(VOID_ARGS)
361361
}
362362

363363
if (context.digging.effort > 100) {
364-
register const char *digtxt, *dmgtxt = (const char *) 0;
365-
register struct obj *obj;
366-
register boolean shopedge = *in_rooms(dpx, dpy, SHOPBASE);
364+
const char *digtxt, *dmgtxt = (const char *) 0;
365+
struct obj *obj;
366+
boolean shopedge = *in_rooms(dpx, dpy, SHOPBASE);
367367

368368
if ((obj = sobj_at(STATUE, dpx, dpy)) != 0) {
369369
if (break_statue(obj))
@@ -397,25 +397,24 @@ dig(VOID_ARGS)
397397
}
398398
if (IS_TREE(lev->typ)) {
399399
digtxt = "You cut down the tree.";
400-
lev->typ = ROOM;
400+
lev->typ = ROOM, lev->flags = 0;
401401
if (!rn2(5))
402402
(void) rnd_treefruit_at(dpx, dpy);
403403
} else {
404404
digtxt = "You succeed in cutting away some rock.";
405-
lev->typ = CORR;
405+
lev->typ = CORR, lev->flags = 0;
406406
}
407407
} else if (IS_WALL(lev->typ)) {
408408
if (shopedge) {
409409
add_damage(dpx, dpy, SHOP_WALL_DMG);
410410
dmgtxt = "damage";
411411
}
412412
if (level.flags.is_maze_lev) {
413-
lev->typ = ROOM;
413+
lev->typ = ROOM, lev->flags = 0;
414414
} else if (level.flags.is_cavernous_lev && !in_town(dpx, dpy)) {
415-
lev->typ = CORR;
415+
lev->typ = CORR, lev->flags = 0;
416416
} else {
417-
lev->typ = DOOR;
418-
lev->doormask = D_NODOOR;
417+
lev->typ = DOOR, lev->doormask = D_NODOOR;
419418
}
420419
digtxt = "You make an opening in the wall.";
421420
} else if (lev->typ == SDOOR) {
@@ -573,6 +572,7 @@ int ttyp;
573572
} else if (lev->typ == DRAWBRIDGE_DOWN
574573
|| (is_drawbridge_wall(x, y) >= 0)) {
575574
int bx = x, by = y;
575+
576576
/* if under the portcullis, the bridge is adjacent */
577577
(void) find_drawbridge(&bx, &by);
578578
destroy_drawbridge(bx, by);
@@ -853,6 +853,7 @@ coord *cc;
853853
} else {
854854
typ = fillholetyp(dig_x, dig_y, FALSE);
855855

856+
lev->flags = 0;
856857
if (typ != ROOM) {
857858
lev->typ = typ;
858859
liquid_flow(dig_x, dig_y, typ, ttmp,
@@ -935,7 +936,7 @@ coord *cc;
935936
pline_The("grave seems unused. Strange....");
936937
break;
937938
}
938-
levl[dig_x][dig_y].typ = ROOM;
939+
levl[dig_x][dig_y].typ = ROOM, levl[dig_x][dig_y].flags = 0;
939940
del_engr_at(dig_x, dig_y);
940941
newsym(dig_x, dig_y);
941942
return;
@@ -1272,7 +1273,7 @@ register struct monst *mtmp;
12721273
newsym(mtmp->mx, mtmp->my);
12731274
return FALSE;
12741275
} else if (here->typ == SCORR) {
1275-
here->typ = CORR;
1276+
here->typ = CORR, here->flags = 0;
12761277
unblock_point(mtmp->mx, mtmp->my);
12771278
newsym(mtmp->mx, mtmp->my);
12781279
draft_message(FALSE); /* "You feel a draft." */
@@ -1297,20 +1298,19 @@ register struct monst *mtmp;
12971298
if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
12981299
add_damage(mtmp->mx, mtmp->my, 0L);
12991300
if (level.flags.is_maze_lev) {
1300-
here->typ = ROOM;
1301+
here->typ = ROOM, here->flags = 0;
13011302
} else if (level.flags.is_cavernous_lev
13021303
&& !in_town(mtmp->mx, mtmp->my)) {
1303-
here->typ = CORR;
1304+
here->typ = CORR, here->flags = 0;
13041305
} else {
1305-
here->typ = DOOR;
1306-
here->doormask = D_NODOOR;
1306+
here->typ = DOOR, here->doormask = D_NODOOR;
13071307
}
13081308
} else if (IS_TREE(here->typ)) {
1309-
here->typ = ROOM;
1309+
here->typ = ROOM, here->flags = 0;
13101310
if (pile && pile < 5)
13111311
(void) rnd_treefruit_at(mtmp->mx, mtmp->my);
13121312
} else {
1313-
here->typ = CORR;
1313+
here->typ = CORR, here->flags = 0;
13141314
if (pile && pile < 5)
13151315
(void) mksobj_at((pile == 1) ? BOULDER : ROCK, mtmp->mx, mtmp->my,
13161316
TRUE, FALSE);
@@ -1495,7 +1495,7 @@ zap_dig()
14951495
shopdoor = TRUE;
14961496
}
14971497
if (room->typ == SDOOR)
1498-
room->typ = DOOR;
1498+
room->typ = DOOR; /* doormask set below */
14991499
else if (cansee(zx, zy))
15001500
pline_The("door is razed!");
15011501
watch_dig((struct monst *) 0, zx, zy, TRUE);
@@ -1511,21 +1511,21 @@ zap_dig()
15111511
add_damage(zx, zy, SHOP_WALL_COST);
15121512
shopwall = TRUE;
15131513
}
1514-
room->typ = ROOM;
1514+
room->typ = ROOM, room->flags = 0;
15151515
unblock_point(zx, zy); /* vision */
15161516
} else if (!Blind)
15171517
pline_The("wall glows then fades.");
15181518
break;
15191519
} else if (IS_TREE(room->typ)) { /* check trees before stone */
15201520
if (!(room->wall_info & W_NONDIGGABLE)) {
1521-
room->typ = ROOM;
1521+
room->typ = ROOM, room->flags = 0;
15221522
unblock_point(zx, zy); /* vision */
15231523
} else if (!Blind)
15241524
pline_The("tree shudders but is unharmed.");
15251525
break;
15261526
} else if (room->typ == STONE || room->typ == SCORR) {
15271527
if (!(room->wall_info & W_NONDIGGABLE)) {
1528-
room->typ = CORR;
1528+
room->typ = CORR, room->flags = 0;
15291529
unblock_point(zx, zy); /* vision */
15301530
} else if (!Blind)
15311531
pline_The("rock glows then fades.");
@@ -1541,17 +1541,16 @@ zap_dig()
15411541
}
15421542
watch_dig((struct monst *) 0, zx, zy, TRUE);
15431543
if (level.flags.is_cavernous_lev && !in_town(zx, zy)) {
1544-
room->typ = CORR;
1544+
room->typ = CORR, room->flags = 0;
15451545
} else {
1546-
room->typ = DOOR;
1547-
room->doormask = D_NODOOR;
1546+
room->typ = DOOR, room->doormask = D_NODOOR;
15481547
}
15491548
digdepth -= 2;
15501549
} else if (IS_TREE(room->typ)) {
1551-
room->typ = ROOM;
1550+
room->typ = ROOM, room->flags = 0;
15521551
digdepth -= 2;
15531552
} else { /* IS_ROCK but not IS_WALL or SDOOR */
1554-
room->typ = CORR;
1553+
room->typ = CORR, room->flags = 0;
15551554
digdepth--;
15561555
}
15571556
unblock_point(zx, zy); /* vision */
@@ -1563,8 +1562,10 @@ zap_dig()
15631562

15641563
if (pitflow && isok(flow_x, flow_y)) {
15651564
struct trap *ttmp = t_at(flow_x, flow_y);
1565+
15661566
if (ttmp && is_pit(ttmp->ttyp)) {
15671567
schar filltyp = fillholetyp(ttmp->tx, ttmp->ty, TRUE);
1568+
15681569
if (filltyp != ROOM)
15691570
pit_flow(ttmp, filltyp);
15701571
}
@@ -1589,15 +1590,15 @@ char *msg;
15891590
int ltyp;
15901591
struct rm *room;
15911592
const char *foundation_msg =
1592-
"The foundation is too hard to dig through from this angle.";
1593+
"The foundation is too hard to dig through from this angle.";
15931594

15941595
if (!cc)
15951596
return FALSE;
15961597
if (!isok(cc->x, cc->y))
15971598
return FALSE;
15981599
*msg = '\0';
15991600
room = &levl[cc->x][cc->y];
1600-
ltyp = room->typ;
1601+
ltyp = room->typ, room->flags = 0;
16011602

16021603
if (is_pool(cc->x, cc->y) || is_lava(cc->x, cc->y)) {
16031604
/* this is handled by the caller after we return FALSE */
@@ -1677,15 +1678,14 @@ pit_flow(trap, filltyp)
16771678
struct trap *trap;
16781679
schar filltyp;
16791680
{
1680-
if (trap && (filltyp != ROOM)
1681-
&& is_pit(trap->ttyp)) {
1681+
if (trap && filltyp != ROOM && is_pit(trap->ttyp)) {
16821682
struct trap t;
16831683
int idx;
16841684

16851685
t = *trap;
1686-
levl[trap->tx][trap->ty].typ = filltyp;
1687-
liquid_flow(trap->tx, trap->ty, filltyp, trap,
1688-
(trap->tx == u.ux && trap->ty == u.uy)
1686+
levl[t.tx][t.ty].typ = filltyp, levl[t.tx][t.ty].flags = 0;
1687+
liquid_flow(t.tx, t.ty, filltyp, trap,
1688+
(t.tx == u.ux && t.ty == u.uy)
16891689
? "Suddenly %s flows in from the adjacent pit!"
16901690
: (char *) 0);
16911691
for (idx = 0; idx < 8; ++idx) {

src/do.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* 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 $ */
1+
/* 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 $ */
22
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
33
/*-Copyright (c) Derek S. Ray, 2015. */
44
/* NetHack may be freely redistributed. See license for details. */
@@ -67,7 +67,7 @@ boolean pushing;
6767
levl[rx][ry].drawbridgemask &= ~DB_UNDER; /* clear lava */
6868
levl[rx][ry].drawbridgemask |= DB_FLOOR;
6969
} else
70-
levl[rx][ry].typ = ROOM;
70+
levl[rx][ry].typ = ROOM, levl[rx][ry].flags = 0;
7171

7272
if (ttmp)
7373
(void) delfloortrap(ttmp);
@@ -276,22 +276,29 @@ STATIC_DCL void
276276
polymorph_sink()
277277
{
278278
uchar sym = S_sink;
279+
boolean sinklooted;
279280

280281
if (levl[u.ux][u.uy].typ != SINK)
281282
return;
282283

284+
sinklooted = levl[u.ux][u.uy].looted != 0;
283285
level.flags.nsinks--;
284-
levl[u.ux][u.uy].doormask = 0;
286+
levl[u.ux][u.uy].doormask = 0; /* levl[][].flags */
285287
switch (rn2(4)) {
286288
default:
287289
case 0:
288290
sym = S_fountain;
289291
levl[u.ux][u.uy].typ = FOUNTAIN;
292+
levl[u.ux][u.uy].blessedftn = 0;
293+
if (sinklooted)
294+
SET_FOUNTAIN_LOOTED(u.ux, u.uy);
290295
level.flags.nfountains++;
291296
break;
292297
case 1:
293298
sym = S_throne;
294299
levl[u.ux][u.uy].typ = THRONE;
300+
if (sinklooted)
301+
levl[u.ux][u.uy].looted = T_LOOTED;
295302
break;
296303
case 2:
297304
sym = S_altar;

src/fountain.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* NetHack 3.6 fountain.c $NHDT-Date: 1455402364 2016/02/13 22:26:04 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.56 $ */
1+
/* 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 $ */
22
/* Copyright Scott R. Turner, srt@ucla, 10/27/86 */
33
/* NetHack may be freely redistributed. See license for details. */
44

@@ -137,7 +137,7 @@ genericptr_t poolcnt;
137137
pline("Water gushes forth from the overflowing fountain!");
138138

139139
/* Put a pool at x, y */
140-
levl[x][y].typ = POOL;
140+
levl[x][y].typ = POOL, levl[x][y].flags = 0;
141141
/* No kelp! */
142142
del_engr_at(x, y);
143143
water_damage_chain(level.objects[x][y], TRUE);
@@ -205,8 +205,7 @@ boolean isyou;
205205
return;
206206
}
207207
/* replace the fountain with ordinary floor */
208-
levl[x][y].typ = ROOM;
209-
levl[x][y].looted = 0;
208+
levl[x][y].typ = ROOM, levl[x][y].flags = 0;
210209
levl[x][y].blessedftn = 0;
211210
if (cansee(x, y))
212211
pline_The("fountain dries up!");
@@ -397,8 +396,7 @@ register struct obj *obj;
397396
exercise(A_WIS, TRUE);
398397
}
399398
update_inventory();
400-
levl[u.ux][u.uy].typ = ROOM;
401-
levl[u.ux][u.uy].looted = 0;
399+
levl[u.ux][u.uy].typ = ROOM, levl[u.ux][u.uy].flags = 0;
402400
newsym(u.ux, u.uy);
403401
level.flags.nfountains--;
404402
if (in_town(u.ux, u.uy))
@@ -511,8 +509,9 @@ int x, y;
511509
if (cansee(x, y) || (x == u.ux && y == u.uy))
512510
pline_The("pipes break! Water spurts out!");
513511
level.flags.nsinks--;
514-
levl[x][y].doormask = 0;
515-
levl[x][y].typ = FOUNTAIN;
512+
levl[x][y].typ = FOUNTAIN, levl[x][y].looted = 0;
513+
levl[x][y].blessedftn = 0;
514+
SET_FOUNTAIN_LOOTED(x, y);
516515
level.flags.nfountains++;
517516
newsym(x, y);
518517
}

src/lock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* NetHack 3.6 lock.c $NHDT-Date: 1521499715 2018/03/19 22:48:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.80 $ */
1+
/* 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 $ */
22
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
33
/*-Copyright (c) Robert Patrick Rankin, 2011. */
44
/* NetHack may be freely redistributed. See license for details. */
@@ -950,7 +950,7 @@ int x, y;
950950
return FALSE;
951951
}
952952
block_point(x, y);
953-
door->typ = SDOOR;
953+
door->typ = SDOOR, door->doormask = D_NODOOR;
954954
if (vis)
955955
pline_The("doorway vanishes!");
956956
newsym(x, y);

src/monmove.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* NetHack 3.6 monmove.c $NHDT-Date: 1517877380 2018/02/06 00:36:20 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.96 $ */
1+
/* 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 $ */
22
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
33
/*-Copyright (c) Michael Allison, 2006. */
44
/* NetHack may be freely redistributed. See license for details. */
@@ -1474,6 +1474,7 @@ dissolve_bars(x, y)
14741474
register int x, y;
14751475
{
14761476
levl[x][y].typ = (Is_special(&u.uz) || *in_rooms(x, y, 0)) ? ROOM : CORR;
1477+
levl[x][y].flags = 0;
14771478
newsym(x, y);
14781479
}
14791480

src/music.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* 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 $ */
1+
/* 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 $ */
22
/* Copyright (c) 1989 by Jean-Christophe Collet */
33
/* NetHack may be freely redistributed. See license for details. */
44

@@ -320,7 +320,7 @@ int force;
320320
*/
321321
filltype = fillholetyp(x, y, FALSE);
322322
if (filltype != ROOM) {
323-
levl[x][y].typ = filltype;
323+
levl[x][y].typ = filltype; /* flags set via doormask */
324324
liquid_flow(x, y, filltype, chasm, (char *) 0);
325325
}
326326

0 commit comments

Comments
 (0)