fix github issue #967 - nearby objects
Issue reported by entrez: distant_name() used different criteria for 'nearby' than map_object() and see_nearby_objects(), so it could mark objects as seen when they were being displayed as generic, without redisplaying them as a specific. Generic object with dknown set leads to confusion. Example was "a spellbook spellbook". I think this should fix things, but I've only done a small amount of testing so far. Fixes #967
This commit is contained in:
+35
-16
@@ -320,10 +320,18 @@ map_object(register struct obj *obj, int show)
|
|||||||
|
|
||||||
/* if this object is already displayed as a generic object, it might
|
/* if this object is already displayed as a generic object, it might
|
||||||
become a specific one now */
|
become a specific one now */
|
||||||
if (glyph_is_generic_object(glyph) && cansee(x, y) && next2u(x, y)
|
if (glyph_is_generic_object(glyph) && cansee(x, y) && !Hallucination) {
|
||||||
&& !Hallucination) {
|
/* these 'r' and 'neardist' calculations match distant_name(objnam.c)
|
||||||
obj->dknown = 1;
|
and see_nearby_objects(below); we assume that this is a lone
|
||||||
glyph = obj_to_glyph(obj, newsym_rn2);
|
object or a pile-top, not something below the top of a pile */
|
||||||
|
int r = (u.xray_range > 2) ? u.xray_range : 2,
|
||||||
|
/* neardist produces a small square with rounded corners */
|
||||||
|
neardist = (r * r) * 2 - r; /* same as r*r + r*(r-1) */
|
||||||
|
|
||||||
|
if (distu(x, y) <= neardist) {
|
||||||
|
obj->dknown = 1;
|
||||||
|
glyph = obj_to_glyph(obj, newsym_rn2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gl.level.flags.hero_memory) {
|
if (gl.level.flags.hero_memory) {
|
||||||
@@ -1435,26 +1443,37 @@ see_objects(void)
|
|||||||
update_inventory();
|
update_inventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mark the top object of each adjacent stack as having been seen, and
|
/* mark the top object of nearby stacks as having been seen, and if
|
||||||
if it was being displayed as generic, redisplay it as specific */
|
that object was being displayed as generic, redisplay it as specific */
|
||||||
void
|
void
|
||||||
see_nearby_objects(void)
|
see_nearby_objects(void)
|
||||||
{
|
{
|
||||||
struct obj *obj;
|
struct obj *obj;
|
||||||
int glyph;
|
int glyph;
|
||||||
coordxy ix, iy, x = u.ux, y = u.uy;
|
coordxy ix, iy, x = u.ux, y = u.uy;
|
||||||
|
/* these 'r' and 'neardist' calculations match distant_name(objnam.c) */
|
||||||
|
int r = (u.xray_range > 2) ? u.xray_range : 2,
|
||||||
|
/* neardist produces a small square with rounded corners */
|
||||||
|
neardist = (r * r) * 2 - r; /* same as r*r + r*(r-1) */
|
||||||
|
|
||||||
for (iy = y - 1; iy <= y + 1; ++iy)
|
/* [note: this could be optimized to avoid the distu() calculations] */
|
||||||
for (ix = x - 1; ix <= x + 1; ++ix) {
|
for (iy = y - r; iy <= y + r; ++iy)
|
||||||
if (!isok(ix, iy) || !cansee(ix, iy))
|
for (ix = x - r; ix <= x + r; ++ix) {
|
||||||
|
if (!isok(ix, iy))
|
||||||
continue;
|
continue;
|
||||||
if ((obj = vobj_at(ix, iy)) != 0) {
|
/* skip if no object or the object has already been marked as
|
||||||
obj->dknown = 1; /* adjacent, so close enough to see it */
|
having been seen up close */
|
||||||
/* operate on remembered glyph rather than current one */
|
if ((obj = vobj_at(ix, iy)) == 0 || obj->dknown)
|
||||||
glyph = levl[ix][iy].glyph;
|
continue;
|
||||||
if (glyph_is_generic_object(glyph))
|
/* skip if the spot can't be seen or is too far (diagonal) */
|
||||||
newsym_force(ix, iy);
|
if (!cansee(ix, iy) || distu(ix, iy) > neardist)
|
||||||
}
|
continue;
|
||||||
|
|
||||||
|
obj->dknown = 1; /* near enough to see it */
|
||||||
|
/* operate on remembered glyph rather than current one */
|
||||||
|
glyph = levl[ix][iy].glyph;
|
||||||
|
if (glyph_is_generic_object(glyph))
|
||||||
|
newsym_force(ix, iy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user