From c0a1ed9c41895136b3195f10486773b201c17c1b Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 16 Jan 2025 12:51:40 -0800 Subject: [PATCH] another stab at stumble_onto_mimic The unreliable sanity check is removed. --- src/pager.c | 6 +++++- src/uhitm.c | 18 +++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pager.c b/src/pager.c index eb5956061..e964554f2 100644 --- a/src/pager.c +++ b/src/pager.c @@ -289,7 +289,11 @@ object_from_map( boolean fakeobj = FALSE, mimic_obj = FALSE; struct monst *mtmp; struct obj *otmp; - int glyphotyp = glyph_to_obj(glyph); + int glyphotyp = glyph_is_object(glyph) ? glyph_to_obj(glyph) + /* if not an object, probably a detected chest trap */ + : glyph_is_cmap(glyph) /* assume trapped chest|door */ + ? (sobj_at(CHEST, x, y) ? CHEST : LARGE_BOX) + : STRANGE_OBJECT; *obj_p = (struct obj *) 0; /* TODO: check inside containers in case glyph came from detection */ diff --git a/src/uhitm.c b/src/uhitm.c index b3b470c00..dc7264af1 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -6068,26 +6068,22 @@ that_is_a_mimic( else if (M_AP_TYPE(mtmp) == M_AP_MONSTER) what = a_monnam(mtmp); /* differs from what was sensed */ } else { - int glyph = glyph_at(u.ux + u.dx, u.uy + u.dy); + coordxy x = u.ux + u.dx, y = u.uy + u.dy; + int glyph = glyph_at(x, y); if (glyph_is_cmap(glyph)) { int sym = glyph_to_cmap(glyph); -#ifdef EXTRA_SANITY_CHECKS - if (iflags.sanity_check && (int) mtmp->mappearance != sym) - impossible("mimic appearance %u does not match" - " map feature %d (glyph=%d)", - mtmp->mappearance, sym, glyph); -#endif - /* note: defsyms[stairs] yields singular "staircase {up|down}" */ - Snprintf(fmtbuf, sizeof fmtbuf, "That %s actually is %%s!", - defsyms[sym].explanation); + if (M_AP_TYPE(mtmp) == M_AP_FURNITURE + || (M_AP_TYPE(mtmp) == M_AP_OBJECT && sym == S_trapped_chest)) + Snprintf(fmtbuf, sizeof fmtbuf, "That %s actually is %%s!", + defsyms[sym].explanation); } else if (glyph_is_object(glyph)) { boolean fakeobj; const char *otmp_name; struct obj *otmp = NULL; - fakeobj = object_from_map(glyph, mtmp->mx, mtmp->my, &otmp); + fakeobj = object_from_map(glyph, x, y, &otmp); otmp_name = (otmp && otmp->otyp != STRANGE_OBJECT) ? simpleonames(otmp) : "strange object"; Snprintf(fmtbuf, sizeof fmtbuf, "%s %s %s %%s!",