]> granicus.if.org Git - nethack/commitdiff
fix B14011: vault wall repair
authornethack.rankin <nethack.rankin>
Thu, 7 Nov 2002 02:56:19 +0000 (02:56 +0000)
committernethack.rankin <nethack.rankin>
Thu, 7 Nov 2002 02:56:19 +0000 (02:56 +0000)
     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.

doc/fixes34.1
src/vault.c

index 05fd7a42032d0256ba480ff234aa318177629a3d..902ed8b5e309b77f709a28bdbe2250c4661b581b 100644 (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
        in the usual confusion effects
 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
index 89da12273626c3d35ba7b94e972784ba005de716..eb7f3d23c2cd92d1824bd0b6f373afbaf1279357 100644 (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. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -367,20 +367,24 @@ STATIC_OVL void
 wallify_vault(grd)
 struct monst *grd;
 {
-       int x, y;
+       int x, y, typ;
        int vlt = EGD(grd)->vroom;
        char tmp_viz;
-       xchar lowx = rooms[vlt].lx, hix = rooms[vlt].hx;
-       xchar lowy = rooms[vlt].ly, hiy = rooms[vlt].hy;
-       register struct obj *gold;
-       register boolean fixed = FALSE;
-       register boolean movedgold = FALSE;
-
-       for(x = lowx-1; x <= hix+1; x++)
-           for(y = lowy-1; y <= hiy+1; y += (hiy-lowy+2)) {
-               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);
+       xchar lox = rooms[vlt].lx - 1, hix = rooms[vlt].hx + 1,
+             loy = rooms[vlt].ly - 1, hiy = rooms[vlt].hy + 1;
+       struct monst *mon;
+       struct obj *gold;
+       struct trap *trap;
+       boolean fixed = FALSE;
+       boolean movedgold = FALSE;
+
+       for (x = lox; x <= hix; x++)
+           for (y = loy; y <= hiy; y++) {
+               /* if not on the room boundary, skip ahead */
+               if (x != lox && x != hix && y != loy && y != hiy) continue;
+
+               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);
                        rloc(mon);
                    }
@@ -388,16 +392,17 @@ struct monst *grd;
                        move_gold(gold, EGD(grd)->vroom);
                        movedgold = TRUE;
                    }
-                   if(x == lowx-1 && y == lowy-1)
-                       levl[x][y].typ = TLCORNER;
-                   else if(x == hix+1 && y == lowy-1)
-                       levl[x][y].typ = TRCORNER;
-                   else if(x == lowx-1 && y == hiy+1)
-                       levl[x][y].typ = BLCORNER;
-                   else if(x == hix+1 && y == hiy+1)
-                       levl[x][y].typ = BRCORNER;
-                   else levl[x][y].typ = HWALL;
-
+                   if ((trap = t_at(x, y)) != 0)
+                       deltrap(trap);
+                   if (x == lox)
+                       typ = (y == loy) ? TLCORNER :
+                             (y == hiy) ? BLCORNER : VWALL;
+                   else if (x == hix)
+                       typ = (y == loy) ? TRCORNER :
+                             (y == hiy) ? BRCORNER : VWALL;
+                   else  /* not left or right side, must be top or bottom */
+                       typ = HWALL;
+                   levl[x][y].typ = typ;
                    levl[x][y].doormask = 0;
                    /*
                     * hack: player knows walls are restored because of the
@@ -411,28 +416,6 @@ struct monst *grd;
                    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(in_fcorridor(grd, grd->mx, grd->my) || cansee(grd->mx, grd->my))