fix B14011: vault wall repair

From the newsgroup:  traps created on the location of dug out vault
walls would be left in place when/if the vault guard repaired the walls.
Since known traps get precedence over walls when drawing the map, this
produced a display oddity in addition to the topological one.

     It also appears that monsters in affected spots wouldn't be handled
correctly if they happened to be in a direct horizontal or vertical line
with the guard.  I don't know whether that matches any of the assorted
unresolved old vault bugs.

     This eliminates a chunk of redundant code by merging two loops.
This commit is contained in:
nethack.rankin
2002-11-07 02:56:19 +00:00
parent e3b9c00826
commit 4d145fac06
2 changed files with 28 additions and 44 deletions

View File

@@ -295,6 +295,7 @@ cancelled yellow lights should not explode against other monsters, as well as
becoming confused, eg from nausia, while reading a spellbook should result becoming confused, eg from nausia, while reading a spellbook should result
in the usual confusion effects in the usual confusion effects
level teleports should not be controlled if you're confused level teleports should not be controlled if you're confused
vault wall repair should remove traps subsequently created at affected spots
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)vault.c 3.4 2002/08/06 */ /* SCCS Id: @(#)vault.c 3.4 2002/11/06 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -367,20 +367,24 @@ STATIC_OVL void
wallify_vault(grd) wallify_vault(grd)
struct monst *grd; struct monst *grd;
{ {
int x, y; int x, y, typ;
int vlt = EGD(grd)->vroom; int vlt = EGD(grd)->vroom;
char tmp_viz; char tmp_viz;
xchar lowx = rooms[vlt].lx, hix = rooms[vlt].hx; xchar lox = rooms[vlt].lx - 1, hix = rooms[vlt].hx + 1,
xchar lowy = rooms[vlt].ly, hiy = rooms[vlt].hy; loy = rooms[vlt].ly - 1, hiy = rooms[vlt].hy + 1;
register struct obj *gold; struct monst *mon;
register boolean fixed = FALSE; struct obj *gold;
register boolean movedgold = FALSE; struct trap *trap;
boolean fixed = FALSE;
boolean movedgold = FALSE;
for(x = lowx-1; x <= hix+1; x++) for (x = lox; x <= hix; x++)
for(y = lowy-1; y <= hiy+1; y += (hiy-lowy+2)) { for (y = loy; y <= hiy; y++) {
if(!IS_WALL(levl[x][y].typ) && !in_fcorridor(grd, x, y)) { /* if not on the room boundary, skip ahead */
if(MON_AT(x, y) && grd->mx != x && grd->my != y) { if (x != lox && x != hix && y != loy && y != hiy) continue;
struct monst *mon = m_at(x,y);
if (!IS_WALL(levl[x][y].typ) && !in_fcorridor(grd, x, y)) {
if ((mon = m_at(x, y)) != 0 && mon != grd) {
if (mon->mtame) yelp(mon); if (mon->mtame) yelp(mon);
rloc(mon); rloc(mon);
} }
@@ -388,16 +392,17 @@ struct monst *grd;
move_gold(gold, EGD(grd)->vroom); move_gold(gold, EGD(grd)->vroom);
movedgold = TRUE; movedgold = TRUE;
} }
if(x == lowx-1 && y == lowy-1) if ((trap = t_at(x, y)) != 0)
levl[x][y].typ = TLCORNER; deltrap(trap);
else if(x == hix+1 && y == lowy-1) if (x == lox)
levl[x][y].typ = TRCORNER; typ = (y == loy) ? TLCORNER :
else if(x == lowx-1 && y == hiy+1) (y == hiy) ? BLCORNER : VWALL;
levl[x][y].typ = BLCORNER; else if (x == hix)
else if(x == hix+1 && y == hiy+1) typ = (y == loy) ? TRCORNER :
levl[x][y].typ = BRCORNER; (y == hiy) ? BRCORNER : VWALL;
else levl[x][y].typ = HWALL; else /* not left or right side, must be top or bottom */
typ = HWALL;
levl[x][y].typ = typ;
levl[x][y].doormask = 0; levl[x][y].doormask = 0;
/* /*
* hack: player knows walls are restored because of the * hack: player knows walls are restored because of the
@@ -411,28 +416,6 @@ struct monst *grd;
fixed = TRUE; fixed = TRUE;
} }
} }
for(x = lowx-1; x <= hix+1; x += (hix-lowx+2))
for(y = lowy; y <= hiy; y++) {
if(!IS_WALL(levl[x][y].typ) && !in_fcorridor(grd, x, y)) {
if(MON_AT(x, y) && grd->mx != x && grd->my != y) {
struct monst *mon = m_at(x,y);
if (mon->mtame) yelp(mon);
rloc(mon);
}
if ((gold = g_at(x, y)) != 0) {
move_gold(gold, EGD(grd)->vroom);
movedgold = TRUE;
}
levl[x][y].typ = VWALL;
levl[x][y].doormask = 0;
tmp_viz = viz_array[y][x];
viz_array[y][x] = IN_SIGHT|COULD_SEE;
newsym(x,y);
viz_array[y][x] = tmp_viz;
block_point(x,y);
fixed = TRUE;
}
}
if(movedgold || fixed) { if(movedgold || fixed) {
if(in_fcorridor(grd, grd->mx, grd->my) || cansee(grd->mx, grd->my)) if(in_fcorridor(grd, grd->mx, grd->my) || cansee(grd->mx, grd->my))