From: PatR Date: Sun, 4 Jun 2017 23:32:17 +0000 (-0700) Subject: m_monnam() usage X-Git-Tag: NetHack-3.6.1_RC01~480 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c377b584fcb28113234f513b097e0998bbf27bd2;p=nethack m_monnam() usage m_monnam() overrides hallucination, which is appropriate in some situations but not others. This fixes one instance where it was being misused: discovering a hidden monster when another monster attacks it was calling either m_monnam() or a_monnam(); one ignores hallucination and the other doesn't, so accurate or inaccurate monster type depended on the condition tested. Figurine activation and egg hatching are using m_monnam(), which seems suspect, but I left them as is. --- diff --git a/src/apply.c b/src/apply.c index e74160b9e..546d2cefd 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 apply.c $NHDT-Date: 1457397477 2016/03/08 00:37:57 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.224 $ */ +/* NetHack 3.6 apply.c $NHDT-Date: 1496619131 2017/06/04 23:32:11 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.232 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2060,6 +2060,7 @@ long timeout; char and_vanish[BUFSZ]; struct obj *mshelter = level.objects[mtmp->mx][mtmp->my]; + /* [m_monnam() yields accurate mon type, overriding hallucination] */ Sprintf(monnambuf, "%s", an(m_monnam(mtmp))); and_vanish[0] = '\0'; if ((mtmp->minvis && !See_invisible) diff --git a/src/hack.c b/src/hack.c index a250d86de..8683fda77 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 hack.c $NHDT-Date: 1494107206 2017/05/06 21:46:46 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.174 $ */ +/* NetHack 3.6 hack.c $NHDT-Date: 1496619131 2017/06/04 23:32:11 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.175 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1526,6 +1526,7 @@ domove() && !sensemon(mtmp)) stumble_onto_mimic(mtmp); else if (mtmp->mpeaceful && !Hallucination) + /* m_monnam(): "dog" or "Fido", no "invisible dog" or "it" */ pline("Pardon me, %s.", m_monnam(mtmp)); else You("move right into %s.", mon_nam(mtmp)); diff --git a/src/mhitm.c b/src/mhitm.c index 39407c3a8..38a56404b 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mhitm.c $NHDT-Date: 1470819842 2016/08/10 09:04:02 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.92 $ */ +/* NetHack 3.6 mhitm.c $NHDT-Date: 1496619132 2017/06/04 23:32:12 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.96 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -324,11 +324,16 @@ register struct monst *magr, *mdef; mdef->mundetected = 0; newsym(mdef->mx, mdef->my); if (canseemon(mdef) && !sensemon(mdef)) { - if (Unaware) - You("dream of %s.", (mdef->data->geno & G_UNIQ) - ? a_monnam(mdef) - : makeplural(m_monnam(mdef))); - else + if (Unaware) { + boolean justone = (mdef->data->geno & G_UNIQ) != 0L; + const char *montype; + + montype = noname_monnam(mdef, justone ? ARTICLE_THE + : ARTICLE_NONE); + if (!justone) + montype = makeplural(montype); + You("dream of %s.", montype); + } else pline("Suddenly, you notice %s.", a_monnam(mdef)); } } diff --git a/src/mhitu.c b/src/mhitu.c index 86a064f84..df5541e19 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mhitu.c $NHDT-Date: 1470819843 2016/08/10 09:04:03 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.144 $ */ +/* NetHack 3.6 mhitu.c $NHDT-Date: 1496619132 2017/06/04 23:32:12 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.146 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -486,6 +486,8 @@ register struct monst *mtmp; if (obj->otyp == EGG) obj->spe = 0; } + /* note that m_monnam() overrides hallucination, which is + what we want when message is from mtmp's perspective */ if (youmonst.data->mlet == S_EEL || u.umonnum == PM_TRAPPER) pline( @@ -515,7 +517,7 @@ register struct monst *mtmp; map_invisible(mtmp->mx, mtmp->my); if (sticky && !youseeit) pline("It gets stuck on you."); - else + else /* see note about m_monnam() above */ pline("Wait, %s! That's a %s named %s!", m_monnam(mtmp), youmonst.data->mname, plname); if (sticky) @@ -536,7 +538,7 @@ register struct monst *mtmp; && youmonst.mappearance == GOLD_PIECE) ? "tries to pick you up" : "disturbs you"); - else + else /* see note about m_monnam() above */ pline("Wait, %s! That %s is really %s named %s!", m_monnam(mtmp), mimic_obj_name(&youmonst), an(mons[u.umonnum].mname), plname); diff --git a/src/timeout.c b/src/timeout.c index e5187e93b..508fe9609 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 timeout.c $NHDT-Date: 1493510119 2017/04/29 23:55:19 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.70 $ */ +/* NetHack 3.6 timeout.c $NHDT-Date: 1496619133 2017/06/04 23:32:13 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.71 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -613,6 +613,8 @@ long timeout; boolean siblings = (hatchcount > 1), redraw = FALSE; if (cansee_hatchspot) { + /* [bug? m_monnam() yields accurate monster type + regardless of hallucination] */ Sprintf(monnambuf, "%s%s", siblings ? "some " : "", siblings ? makeplural(m_monnam(mon)) : an(m_monnam(mon))); /* we don't learn the egg type here because learning