accessible()

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).
This commit is contained in:
nethack.rankin
2006-12-15 02:36:58 +00:00
parent 6c00f126da
commit 175e5b67f5
5 changed files with 24 additions and 15 deletions

View 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;

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

View 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:

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

View 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;