fix github issue #1289 - odd "unexplored area"

Issue reported by ars3niy:  an arrow trap covered by more than
one stack of arrows was described by farlook as "unexplored area".
Later simplified to any object pile with plain arrows on top; the
trap turned out to be irrelevant aside from producing a pile of
arrow stacks.

This problem turns out to be due to an off by 1 error introduced
into the xxx_is_piletop() macros when generic objects were added in
mid-January of last year, and plain arrow is the first real object
so suffered from the bug.  Misclassifying the glyph at a specific
location also confused the #terrain command but it's the same bug.

Knowing what was wrong (map glyph was UNEXPLORED when it should
have been ARROW) wasn't sufficient to figure out the problem.
Without the simplified way of reproducing the problem, I would
never have managed to use 'git bisect' to find the offending commit
because that would have been too time consuming.

Fixes #1289
This commit is contained in:
PatR
2024-09-28 19:28:37 -07:00
parent d746060d6e
commit 0128fcdf6c
2 changed files with 6 additions and 4 deletions

View File

@@ -2043,6 +2043,8 @@ non-fireproof water walking boots wouldn't be burnt up if fire resistant hero
walked on molten lava
1x1 poison gas clouds for green dragon and iron golem breath could be placed
at wall locations
if a pile of objects had arrow(s) on top, map location classification got
confused and reported 'unexplore area'
Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository

View File

@@ -837,20 +837,20 @@ enum glyph_offsets {
/* generic objects are after strange object (GLYPH_OBJ_OFF) and before
other objects (GLYPH_OBJ_OFF + FIRST_OBJECT) */
#define glyph_is_normal_generic_obj(glyph) \
((glyph) > GLYPH_OBJ_OFF && (glyph) < GLYPH_OBJ_OFF + FIRST_OBJECT)
((glyph) > GLYPH_OBJ_OFF && (glyph) < GLYPH_OBJ_OFF + FIRST_OBJECT - 1)
#define glyph_is_piletop_generic_obj(glyph) \
((glyph) > GLYPH_OBJ_PILETOP_OFF \
&& (glyph) < GLYPH_OBJ_PILETOP_OFF + FIRST_OBJECT)
&& (glyph) < GLYPH_OBJ_PILETOP_OFF + FIRST_OBJECT - 1)
#define glyph_is_generic_object(glyph) \
(glyph_is_normal_generic_obj(glyph) \
|| glyph_is_piletop_generic_obj(glyph))
#define glyph_is_normal_piletop_obj(glyph) \
((glyph) == GLYPH_OBJ_PILETOP_OFF \
|| ((glyph) > GLYPH_OBJ_PILETOP_OFF + FIRST_OBJECT \
|| ((glyph) > GLYPH_OBJ_PILETOP_OFF + FIRST_OBJECT - 1 \
&& (glyph) < (GLYPH_OBJ_PILETOP_OFF + NUM_OBJECTS)))
#define glyph_is_normal_object(glyph) \
((glyph) == GLYPH_OBJ_OFF \
|| ((glyph) >= GLYPH_OBJ_OFF + FIRST_OBJECT \
|| ((glyph) >= GLYPH_OBJ_OFF + FIRST_OBJECT - 1 \
&& (glyph) < (GLYPH_OBJ_OFF + NUM_OBJECTS)) \
|| glyph_is_normal_piletop_obj(glyph))