recalc_mapseen() followup
Update several places where lazy lastseentyp[] might be an issue. I think it isn't updated in a timely fashion when newsym() shows a spot covered by an object or trap, but didn't manage to find any cases where that caused a problem. This is more in the nature of a precaution.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 cmd.c $NHDT-Date: 1702123758 2023/12/09 12:09:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.694 $ */
|
||||
/* NetHack 3.7 cmd.c $NHDT-Date: 1703070187 2023/12/20 11:03:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.695 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -2159,6 +2159,10 @@ doterrain(void)
|
||||
int which;
|
||||
int clr = NO_COLOR;
|
||||
|
||||
/* this used to be done each time vision was recalculated, so would
|
||||
always be up to date (hopefully); now we do it on demand instead */
|
||||
recalc_mapseen();
|
||||
|
||||
/*
|
||||
* normal play: choose between known map without mons, obj, and traps
|
||||
* (to see underlying terrain only), or
|
||||
|
||||
90
src/detect.c
90
src/detect.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 detect.c $NHDT-Date: 1613721262 2021/02/19 07:54:22 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.131 $ */
|
||||
/* NetHack 3.7 detect.c $NHDT-Date: 1703070189 2023/12/20 11:03:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.171 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2018. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -930,10 +930,11 @@ display_trap_map(int cursed_src)
|
||||
cls();
|
||||
|
||||
(void) unconstrain_map();
|
||||
/* show chest traps first, so that subsequent floor trap display
|
||||
will override if both types are present at the same location */
|
||||
(void) detect_obj_traps(fobj, TRUE, cursed_src);
|
||||
/* show chest traps first, first buried chests then floor chests, so
|
||||
that subsequent floor trap display will override if both types are
|
||||
present at the same location */
|
||||
(void) detect_obj_traps(gl.level.buriedobjlist, TRUE, cursed_src);
|
||||
(void) detect_obj_traps(fobj, TRUE, cursed_src);
|
||||
for (mon = fmon; mon; mon = mon->nmon) {
|
||||
if (DEADMONSTER(mon) || (mon->isgd && !mon->mx))
|
||||
continue;
|
||||
@@ -974,8 +975,8 @@ display_trap_map(int cursed_src)
|
||||
* returns 0 if something was detected
|
||||
*/
|
||||
int
|
||||
trap_detect(struct obj *sobj) /* null if crystal ball,
|
||||
*scroll if gold detection scroll */
|
||||
trap_detect(
|
||||
struct obj *sobj) /* Null if crystal ball, scroll if gold detection */
|
||||
{
|
||||
register struct trap *ttmp;
|
||||
struct monst *mon;
|
||||
@@ -992,24 +993,24 @@ trap_detect(struct obj *sobj) /* null if crystal ball,
|
||||
if (ttmp->tx != u.ux || ttmp->ty != u.uy) {
|
||||
display_trap_map(cursed_src);
|
||||
return 0;
|
||||
} else
|
||||
found = TRUE;
|
||||
}
|
||||
found = TRUE;
|
||||
}
|
||||
/* chest traps (might be buried or carried) */
|
||||
if ((tr = detect_obj_traps(fobj, FALSE, 0)) != OTRAP_NONE) {
|
||||
if (tr & OTRAP_THERE) {
|
||||
display_trap_map(cursed_src);
|
||||
return 0;
|
||||
} else
|
||||
found = TRUE;
|
||||
}
|
||||
found = TRUE;
|
||||
}
|
||||
if ((tr = detect_obj_traps(gl.level.buriedobjlist, FALSE, 0))
|
||||
!= OTRAP_NONE) {
|
||||
if (tr & OTRAP_THERE) {
|
||||
display_trap_map(cursed_src);
|
||||
return 0;
|
||||
} else
|
||||
found = TRUE;
|
||||
}
|
||||
found = TRUE;
|
||||
}
|
||||
for (mon = fmon; mon; mon = mon->nmon) {
|
||||
if (DEADMONSTER(mon) || (mon->isgd && !mon->mx))
|
||||
@@ -1018,8 +1019,8 @@ trap_detect(struct obj *sobj) /* null if crystal ball,
|
||||
if (tr & OTRAP_THERE) {
|
||||
display_trap_map(cursed_src);
|
||||
return 0;
|
||||
} else
|
||||
found = TRUE;
|
||||
}
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
if (detect_obj_traps(gi.invent, FALSE, 0) != OTRAP_NONE)
|
||||
@@ -1036,8 +1037,8 @@ trap_detect(struct obj *sobj) /* null if crystal ball,
|
||||
if (cc.x != u.ux || cc.y != u.uy) {
|
||||
display_trap_map(cursed_src);
|
||||
return 0;
|
||||
} else
|
||||
found = TRUE;
|
||||
}
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
@@ -1098,46 +1099,55 @@ furniture_detect(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* way back in 3.0plN and/or 2.x, you could use a crystal ball to find out
|
||||
where the wizard was relative to your current location; that was when the
|
||||
Wizard guarded the Amulet and was located on a random maze level, and you
|
||||
were expected to level teleport deep into Hell and hunt for him while
|
||||
working your way up; this isn't of much use anymore */
|
||||
const char *
|
||||
level_distance(d_level *where)
|
||||
{
|
||||
register schar ll = depth(&u.uz) - depth(where);
|
||||
register boolean indun = (u.uz.dnum == where->dnum);
|
||||
schar ll = depth(&u.uz) - depth(where);
|
||||
boolean indun = (u.uz.dnum == where->dnum);
|
||||
const char *res = ""; /* always replaced by some other non-Null value */
|
||||
|
||||
if (ll < 0) {
|
||||
if (ll < (-8 - rn2(3)))
|
||||
if (!indun)
|
||||
return "far away";
|
||||
res = "far away";
|
||||
else
|
||||
return "far below";
|
||||
res = "far below";
|
||||
else if (ll < -1)
|
||||
if (!indun)
|
||||
return "away below you";
|
||||
res = "away below you";
|
||||
else
|
||||
return "below you";
|
||||
res = "below you";
|
||||
else if (!indun)
|
||||
return "in the distance";
|
||||
res = "in the distance";
|
||||
else
|
||||
return "just below";
|
||||
res = "just below";
|
||||
} else if (ll > 0) {
|
||||
if (ll > (8 + rn2(3)))
|
||||
if (!indun)
|
||||
return "far away";
|
||||
res = "far away";
|
||||
else
|
||||
return "far above";
|
||||
res = "far above";
|
||||
else if (ll > 1)
|
||||
if (!indun)
|
||||
return "away above you";
|
||||
res = "away above you";
|
||||
else
|
||||
return "above you";
|
||||
res = "above you";
|
||||
else if (!indun)
|
||||
return "in the distance";
|
||||
res = "in the distance";
|
||||
else
|
||||
return "just above";
|
||||
} else if (!indun)
|
||||
return "in the distance";
|
||||
else
|
||||
return "near you";
|
||||
res = "just above";
|
||||
} else { /* l1 == 0 */
|
||||
if (!indun)
|
||||
res = "in the distance";
|
||||
else
|
||||
res = "near you";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1360,7 +1370,7 @@ show_map_spot(coordxy x, coordxy y, boolean cnf)
|
||||
if (!IS_FURNITURE(lev->typ)) {
|
||||
if ((t = t_at(x, y)) != 0 && t->tseen) {
|
||||
map_trap(t, 1);
|
||||
} else if ((ep = engr_at(x,y)) != 0) {
|
||||
} else if ((ep = engr_at(x, y)) != 0) {
|
||||
map_engraving(ep, 1);
|
||||
} else if (glyph_is_trap(oldglyph) || glyph_is_object(oldglyph)) {
|
||||
show_glyph(x, y, oldglyph);
|
||||
@@ -1442,7 +1452,7 @@ do_vicinity_map(struct obj *sobj) /* scroll--actually fake spellbook--object */
|
||||
/* if hero is engulfed, show engulfer at <u.ux,u.uy> */
|
||||
save_viz_uyux = gv.viz_array[u.uy][u.ux];
|
||||
if (u.uswallow)
|
||||
gv.viz_array[u.uy][u.ux] |= IN_SIGHT; /* <x,y> are reversed to [y][x] */
|
||||
gv.viz_array[u.uy][u.ux] |= IN_SIGHT; /* <x,y> are reversed, [y][x] */
|
||||
save_EDetect_mons = EDetect_monsters;
|
||||
/* for skilled spell, getpos() scanning of the map will display all
|
||||
monsters within range; otherwise, "unseen creature" will be shown */
|
||||
@@ -2027,9 +2037,9 @@ reveal_terrain_getglyph(
|
||||
glyph = back_to_glyph(x, y);
|
||||
levl[x][y].seenv = seenv;
|
||||
} else {
|
||||
levl_glyph = gl.level.flags.hero_memory
|
||||
? levl[x][y].glyph
|
||||
: seenv ? back_to_glyph(x, y): default_glyph;
|
||||
levl_glyph = gl.level.flags.hero_memory ? levl[x][y].glyph
|
||||
: seenv ? back_to_glyph(x, y)
|
||||
: default_glyph;
|
||||
/* glyph_at() returns the displayed glyph, which might
|
||||
be a monster. levl[][].glyph contains the remembered
|
||||
glyph, which will never be a monster (unless it is
|
||||
@@ -2181,7 +2191,7 @@ reveal_terrain(
|
||||
|
||||
for (x = 1; x < COLNO; x++)
|
||||
for (y = 0; y < ROWNO; y++) {
|
||||
glyph = reveal_terrain_getglyph(x,y, swallowed,
|
||||
glyph = reveal_terrain_getglyph(x, y, swallowed,
|
||||
default_glyph, which_subset);
|
||||
show_glyph(x, y, glyph);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 dungeon.c $NHDT-Date: 1700012885 2023/11/15 01:48:05 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.197 $ */
|
||||
/* NetHack 3.7 dungeon.c $NHDT-Date: 1703070190 2023/12/20 11:03:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.205 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1687,13 +1687,13 @@ u_on_dnstairs(void)
|
||||
boolean
|
||||
On_stairs(coordxy x, coordxy y)
|
||||
{
|
||||
return (stairway_at(x,y) != NULL);
|
||||
return (stairway_at(x, y) != NULL);
|
||||
}
|
||||
|
||||
boolean
|
||||
On_ladder(coordxy x, coordxy y)
|
||||
{
|
||||
stairway *stway = stairway_at(x,y);
|
||||
stairway *stway = stairway_at(x, y);
|
||||
|
||||
return (boolean) (stway && stway->isladder);
|
||||
}
|
||||
@@ -1701,7 +1701,7 @@ On_ladder(coordxy x, coordxy y)
|
||||
boolean
|
||||
On_stairs_up(coordxy x, coordxy y)
|
||||
{
|
||||
stairway *stway = stairway_at(x,y);
|
||||
stairway *stway = stairway_at(x, y);
|
||||
|
||||
return (boolean) (stway && stway->up);
|
||||
}
|
||||
@@ -1709,7 +1709,7 @@ On_stairs_up(coordxy x, coordxy y)
|
||||
boolean
|
||||
On_stairs_dn(coordxy x, coordxy y)
|
||||
{
|
||||
stairway *stway = stairway_at(x,y);
|
||||
stairway *stway = stairway_at(x, y);
|
||||
|
||||
return (boolean) (stway && !stway->up);
|
||||
}
|
||||
@@ -3075,16 +3075,31 @@ update_lastseentyp(coordxy x, coordxy y)
|
||||
gl.lastseentyp[x][y] = ltyp;
|
||||
}
|
||||
|
||||
/* for some cases where deferred update needs to be done immediately;
|
||||
hide details from caller */
|
||||
int
|
||||
update_mapseen_for(coordxy x, coordxy y)
|
||||
{
|
||||
recalc_mapseen(); /* whole level */
|
||||
return gl.lastseentyp[x][y];
|
||||
}
|
||||
|
||||
/* count mapseen feature from lastseentyp at x,y */
|
||||
static void
|
||||
count_feat_lastseentyp(mapseen *mptr,
|
||||
coordxy x, coordxy y)
|
||||
count_feat_lastseentyp(
|
||||
mapseen *mptr, /* remembered data for a level; update feat.X counts */
|
||||
coordxy x, coordxy y)
|
||||
{
|
||||
int count;
|
||||
unsigned atmp;
|
||||
|
||||
switch (gl.lastseentyp[x][y]) {
|
||||
#if 0
|
||||
#if 0 /* levels that have these tend of have a lot of them */
|
||||
/*
|
||||
* FIXME? due to theme rooms, lots of levels have an incresed
|
||||
* chance of having these so automatic annotations for them may
|
||||
* have become more worthwhile now.
|
||||
*/
|
||||
case ICE:
|
||||
count = mptr->feat.ice + 1;
|
||||
if (count <= 3)
|
||||
@@ -3133,10 +3148,9 @@ count_feat_lastseentyp(mapseen *mptr,
|
||||
/* get the altarmask for this location; might be a mimic */
|
||||
atmp = altarmask_at(x, y);
|
||||
/* convert to index: 0..3 */
|
||||
atmp = (Is_astralevel(&u.uz)
|
||||
&& (levl[x][y].seenv & SVALL) != SVALL)
|
||||
? MSA_NONE
|
||||
: Amask2msa(atmp);
|
||||
atmp = (Is_astralevel(&u.uz) && (levl[x][y].seenv & SVALL) != SVALL)
|
||||
? MSA_NONE
|
||||
: Amask2msa(atmp);
|
||||
if (!mptr->feat.naltar)
|
||||
mptr->feat.msalign = atmp;
|
||||
else if (mptr->feat.msalign != atmp)
|
||||
@@ -3163,7 +3177,7 @@ count_feat_lastseentyp(mapseen *mptr,
|
||||
if (Is_knox(&u.uz)) {
|
||||
int ty, tx = x - 4;
|
||||
|
||||
/* Throne is four columns left, either directly in
|
||||
/* Throne is four columns to left, either directly in
|
||||
* line or one row higher or lower, and doesn't have
|
||||
* to have been seen yet.
|
||||
* ......|}}}.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 lock.c $NHDT-Date: 1654464994 2022/06/05 21:36:34 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.114 $ */
|
||||
/* NetHack 3.7 lock.c $NHDT-Date: 1703070191 2023/12/20 11:03:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.131 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -569,7 +569,7 @@ pick_lock(
|
||||
}
|
||||
if (!IS_DOOR(door->typ)) {
|
||||
int res = PICKLOCK_DID_NOTHING, oldglyph = door->glyph;
|
||||
schar oldlastseentyp = gl.lastseentyp[cc.x][cc.y];
|
||||
schar oldlastseentyp = update_mapseen_for(cc.x, cc.y);
|
||||
|
||||
/* this is probably only relevant when blind */
|
||||
feel_location(cc.x, cc.y);
|
||||
@@ -819,7 +819,7 @@ doopen_indir(coordxy x, coordxy y)
|
||||
/* this used to be 'if (Blind)' but using a key skips that so we do too */
|
||||
{
|
||||
int oldglyph = door->glyph;
|
||||
schar oldlastseentyp = gl.lastseentyp[cc.x][cc.y];
|
||||
schar oldlastseentyp = update_mapseen_for(cc.x, cc.y);
|
||||
|
||||
newsym(cc.x, cc.y);
|
||||
if (door->glyph != oldglyph
|
||||
@@ -979,7 +979,7 @@ doclose(void)
|
||||
portcullis = (is_drawbridge_wall(x, y) >= 0);
|
||||
if (Blind) {
|
||||
int oldglyph = door->glyph;
|
||||
schar oldlastseentyp = gl.lastseentyp[x][y];
|
||||
schar oldlastseentyp = update_mapseen_for(x, y);
|
||||
|
||||
feel_location(x, y);
|
||||
if (door->glyph != oldglyph || gl.lastseentyp[x][y] != oldlastseentyp)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 trap.c $NHDT-Date: 1702274034 2023/12/11 05:53:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.559 $ */
|
||||
/* NetHack 3.7 trap.c $NHDT-Date: 1703070192 2023/12/20 11:03:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.562 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -4774,7 +4774,8 @@ rescued_from_terrain(int how)
|
||||
|
||||
iflags.last_msg = PLNMSG_BACK_ON_GROUND; /* for describe_decor() */
|
||||
/* feedback just disclosed this */
|
||||
iflags.prev_decor = gl.lastseentyp[u.ux][u.uy] = lev->typ;
|
||||
update_lastseentyp(u.ux, u.uy);
|
||||
iflags.prev_decor = gl.lastseentyp[u.ux][u.uy];
|
||||
}
|
||||
|
||||
/* return TRUE iff player relocated */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 zap.c $NHDT-Date: 1702023277 2023/12/08 08:14:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.498 $ */
|
||||
/* NetHack 3.7 zap.c $NHDT-Date: 1703070194 2023/12/20 11:03:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.501 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -3113,7 +3113,7 @@ zap_updown(struct obj *obj) /* wand or spell */
|
||||
You("probe towards the %s.", ceiling(x, y));
|
||||
} else { /* down */
|
||||
const char *surf;
|
||||
schar ltyp, rememberedltyp = gl.lastseentyp[x][y];
|
||||
schar ltyp, rememberedltyp = update_mapseen_for(x, y);
|
||||
|
||||
ptmp += bhitpile(obj, bhito, x, y, u.dz);
|
||||
/* sequencing: zap_map() calls force_decor() for ice or furniture;
|
||||
|
||||
Reference in New Issue
Block a user