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.
This commit is contained in:
PatR
2017-06-04 16:32:17 -07:00
parent 3046b1d7ec
commit c377b584fc
5 changed files with 23 additions and 12 deletions
+2 -1
View File
@@ -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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -2060,6 +2060,7 @@ long timeout;
char and_vanish[BUFSZ]; char and_vanish[BUFSZ];
struct obj *mshelter = level.objects[mtmp->mx][mtmp->my]; struct obj *mshelter = level.objects[mtmp->mx][mtmp->my];
/* [m_monnam() yields accurate mon type, overriding hallucination] */
Sprintf(monnambuf, "%s", an(m_monnam(mtmp))); Sprintf(monnambuf, "%s", an(m_monnam(mtmp)));
and_vanish[0] = '\0'; and_vanish[0] = '\0';
if ((mtmp->minvis && !See_invisible) if ((mtmp->minvis && !See_invisible)
+2 -1
View File
@@ -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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1526,6 +1526,7 @@ domove()
&& !sensemon(mtmp)) && !sensemon(mtmp))
stumble_onto_mimic(mtmp); stumble_onto_mimic(mtmp);
else if (mtmp->mpeaceful && !Hallucination) else if (mtmp->mpeaceful && !Hallucination)
/* m_monnam(): "dog" or "Fido", no "invisible dog" or "it" */
pline("Pardon me, %s.", m_monnam(mtmp)); pline("Pardon me, %s.", m_monnam(mtmp));
else else
You("move right into %s.", mon_nam(mtmp)); You("move right into %s.", mon_nam(mtmp));
+11 -6
View File
@@ -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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -324,11 +324,16 @@ register struct monst *magr, *mdef;
mdef->mundetected = 0; mdef->mundetected = 0;
newsym(mdef->mx, mdef->my); newsym(mdef->mx, mdef->my);
if (canseemon(mdef) && !sensemon(mdef)) { if (canseemon(mdef) && !sensemon(mdef)) {
if (Unaware) if (Unaware) {
You("dream of %s.", (mdef->data->geno & G_UNIQ) boolean justone = (mdef->data->geno & G_UNIQ) != 0L;
? a_monnam(mdef) const char *montype;
: makeplural(m_monnam(mdef)));
else 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)); pline("Suddenly, you notice %s.", a_monnam(mdef));
} }
} }
+5 -3
View File
@@ -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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -486,6 +486,8 @@ register struct monst *mtmp;
if (obj->otyp == EGG) if (obj->otyp == EGG)
obj->spe = 0; 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 if (youmonst.data->mlet == S_EEL
|| u.umonnum == PM_TRAPPER) || u.umonnum == PM_TRAPPER)
pline( pline(
@@ -515,7 +517,7 @@ register struct monst *mtmp;
map_invisible(mtmp->mx, mtmp->my); map_invisible(mtmp->mx, mtmp->my);
if (sticky && !youseeit) if (sticky && !youseeit)
pline("It gets stuck on you."); 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), pline("Wait, %s! That's a %s named %s!", m_monnam(mtmp),
youmonst.data->mname, plname); youmonst.data->mname, plname);
if (sticky) if (sticky)
@@ -536,7 +538,7 @@ register struct monst *mtmp;
&& youmonst.mappearance == GOLD_PIECE) && youmonst.mappearance == GOLD_PIECE)
? "tries to pick you up" ? "tries to pick you up"
: "disturbs you"); : "disturbs you");
else else /* see note about m_monnam() above */
pline("Wait, %s! That %s is really %s named %s!", m_monnam(mtmp), pline("Wait, %s! That %s is really %s named %s!", m_monnam(mtmp),
mimic_obj_name(&youmonst), an(mons[u.umonnum].mname), mimic_obj_name(&youmonst), an(mons[u.umonnum].mname),
plname); plname);
+3 -1
View File
@@ -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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -613,6 +613,8 @@ long timeout;
boolean siblings = (hatchcount > 1), redraw = FALSE; boolean siblings = (hatchcount > 1), redraw = FALSE;
if (cansee_hatchspot) { if (cansee_hatchspot) {
/* [bug? m_monnam() yields accurate monster type
regardless of hallucination] */
Sprintf(monnambuf, "%s%s", siblings ? "some " : "", Sprintf(monnambuf, "%s%s", siblings ? "some " : "",
siblings ? makeplural(m_monnam(mon)) : an(m_monnam(mon))); siblings ? makeplural(m_monnam(mon)) : an(m_monnam(mon)));
/* we don't learn the egg type here because learning /* we don't learn the egg type here because learning