From cba032d187837708d03ccc9e4a222c0c8d2b93c3 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 11 Jan 2025 02:22:23 -0800 Subject: [PATCH] another mimic fix The report (sent directly to devteam) stated that the bump-into-mimic code might crash when bumping into a mimic that is masqueraing as some other monster. Mimics don't actually do that, but the Wizard of Yendor mimics another monster via Double Trouble. All I got from it though is |Wait! That's ! which won't crash but is a fairly useless message. This changes it to be |Wait! That is ! which seems a bit bland but provides useful information. --- src/uhitm.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/uhitm.c b/src/uhitm.c index 006dfc46b..bd4ce823d 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -6099,12 +6099,27 @@ that_is_a_mimic( otmp->where = OBJ_FREE; /* object_from_map set to OBJ_FLOOR */ dealloc_obj(otmp); } + } else if (glyph_is_monster(glyph)) { + const char *mtmp_name; + int sym = glyph_to_mon(glyph); + +#ifdef EXTRA_SANITY_CHECKS + if (iflags.sanity_check && (int) mtmp->mappearance != sym) + impossible("mimic appearance %u does not match" + " monster #%d (glyph=%d)", + mtmp->mappearance, sym, glyph); +#endif + mtmp_name = pmname(&mons[sym], Mgender(mtmp)); + Snprintf(fmtbuf, sizeof fmtbuf, + "Wait! That %s is %%s!", mtmp_name); } /* cloned Wiz starts out mimicking some other monster and might make himself invisible before being revealed */ if (mtmp->minvis && !See_invisible) what = generic; + else if (M_AP_TYPE(mtmp) == M_AP_MONSTER) + what = x_monnam(mtmp, ARTICLE_A, (char *) NULL, EXACT_NAME, TRUE); else if (mtmp->data->mlet == S_MIMIC && (M_AP_TYPE(mtmp) == M_AP_OBJECT || M_AP_TYPE(mtmp) == M_AP_FURNITURE)