]> granicus.if.org Git - nethack/commitdiff
accessible()
authornethack.rankin <nethack.rankin>
Fri, 15 Dec 2006 02:36:58 +0000 (02:36 +0000)
committernethack.rankin <nethack.rankin>
Fri, 15 Dec 2006 02:36:58 +0000 (02:36 +0000)
     There's some discussion in the newsgroup about an engraving bug, and
while verifying that it's reproducible I've come across an unintentional
change between the current code and 3.4.3.  A recent change made engraving
use accessible(), and that routine wasn't yielding an appropriate value
when applied to a raised drawbridge if the terrain in front of it was ice
or floor (ie, moat or lava had been filled in).  Several places which used
the ACCESSIBLE() macro instead of the function suffer from same problem.

     This doesn't attempt to address the newsgroup bug (which is that an
engraving written on a lowered bridge transfers to the underlying terrain
if the bridge is raised, even when that terrain is water or lava; the
converse case applies too, an engraving on the ground gets transfered to
the bridge when it lowers).

src/engrave.c
src/mail.c
src/monmove.c
src/steed.c
src/teleport.c

index 39405ffaf66b9dcc68297fbc407bb88d69fa0ccb..c8b9190274a17842a4f5feba3ed3ec6cb69b8cb9 100644 (file)
@@ -499,7 +499,7 @@ doengrave()
        if(Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)/* in bubble */) {
                You_cant("write in thin air!");
                return(0);
-       } else if (closed_door(u.ux, u.uy) || !accessible(u.ux, u.uy)) {
+       } else if (!accessible(u.ux, u.uy)) {
                /* stone, tree, wall, secret corridor, pool, lava, bars */
                You_cant("write here.");
                return 0;
index 50f4c89e951e88862cba9aa533bafd29e0aea818..34999b7b9443713bbdfea45af1d94c11d599bf0a 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mail.c     3.5     2006/04/14      */
+/*     SCCS Id: @(#)mail.c     3.5     2006/12/13      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -228,7 +228,7 @@ md_stop(stopp, startp)
        for (y = u.uy-1; y <= u.uy+1; y++) {
            if (!isok(x, y) || (x == u.ux && y == u.uy)) continue;
 
-           if (ACCESSIBLE(levl[x][y].typ) && !MON_AT(x,y)) {
+           if (accessible(x, y) && !MON_AT(x,y)) {
                distance = dist2(x,y,startp->x,startp->y);
                if (min_distance < 0 || distance < min_distance ||
                        (distance == min_distance && rn2(2))) {
index 2deb551044e786836487e1734b0519c29885d77e..d2c4a5c4afe91ff085b1c31eed5006dabf58ac74 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)monmove.c  3.5     2006/08/16      */
+/*     SCCS Id: @(#)monmove.c  3.5     2006/12/13      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1324,7 +1324,18 @@ boolean
 accessible(x, y)
 register int x, y;
 {
-       return((boolean)(ACCESSIBLE(levl[x][y].typ) && !closed_door(x, y)));
+       int levtyp = levl[x][y].typ;
+
+       if (levtyp == DRAWBRIDGE_UP) {
+           /* use underlying terrain in front of closed drawbridge */
+           switch (levl[x][y].drawbridgemask & DB_UNDER) {
+           case DB_MOAT:  levtyp = MOAT; break;
+           case DB_LAVA:  levtyp = LAVAPOOL; break;
+           case DB_ICE:   levtyp = ICE; break;
+           case DB_FLOOR: levtyp = ROOM; break;
+           }
+       }
+       return (boolean)(ACCESSIBLE(levtyp) && !closed_door(x, y));
 }
 
 /* decide where the monster thinks you are standing */
@@ -1388,9 +1399,9 @@ register struct monst *mtmp;
                  || (disp != 2 && mx == mtmp->mx && my == mtmp->my)
                  || ((mx != u.ux || my != u.uy) &&
                      !passes_walls(mtmp->data) &&
-                     (!ACCESSIBLE(levl[mx][my].typ) ||
-                      (closed_door(mx, my) &&
-                       !(can_ooze(mtmp) || can_fog(mtmp)))))
+                     !(accessible(mx, my) ||
+                       (closed_door(mx, my) &&
+                        (can_ooze(mtmp) || can_fog(mtmp)))))
                  || !couldsee(mx, my));
        } else {
 found_you:
index 091c708f2f94987818d6a78ccb1de6dd470c5fd5..6bd27b4cba95cf2a8df004cb6f914772d6eff2f9 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)steed.c    3.5     2006/10/11      */
+/*     SCCS Id: @(#)steed.c    3.5     2006/12/13      */
 /* Copyright (c) Kevin Hugo, 1998-1999. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -437,8 +437,7 @@ int forceit;
            for (y = u.uy-1; y <= u.uy+1; y++) {
                if (!isok(x, y) || (x == u.ux && y == u.uy)) continue;
 
-               if (ACCESSIBLE(levl[x][y].typ) &&
-                           !MON_AT(x,y) && !closed_door(x,y)) {
+               if (accessible(x, y) && !MON_AT(x,y)) {
                    distance = distu(x,y);
                    if (min_distance < 0 || distance < min_distance ||
                            (distance == min_distance && rn2(2))) {
index 7d3f581897a6185e331cfd2d59d86522e470cc5d..5101c0f84a250a3e57a8e4c4e58a0fb8bce72593 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)teleport.c 3.5     2006/08/05      */
+/*     SCCS Id: @(#)teleport.c 3.5     2006/12/13      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -73,13 +73,12 @@ unsigned gpflags;
                    return (is_flyer(mdat) || likes_lava(mdat));
            }
            if (passes_walls(mdat) && may_passwall(x,y)) return TRUE;
+           if (amorphous(mdat) && closed_door(x,y)) return TRUE;
        }
-       if (!ACCESSIBLE(levl[x][y].typ)) {
+       if (!accessible(x, y)) {
                if (!(is_pool(x,y) && ignorewater)) return FALSE;
        }
 
-       if (closed_door(x, y) && (!mdat || !amorphous(mdat)))
-               return FALSE;
        if (sobj_at(BOULDER, x, y) && (!mdat || !throws_rocks(mdat)))
                return FALSE;
        return TRUE;