fix #H5547 - named vampire shapeshifting message

Report was about "Pet vampire" but the relevant aspect was that the
vampire had been assigned a name, not that it was tame:
You observe a Hilda where a Hilda was.

Investigating this has uncovered two other bugs, one potentially
serious.  m_monnam() overrides hallucination but seems to be getting
used to some situations where hallucination should be honored (several
instances).  Dynamically constructed format strings are including
monster or object names in the format (rather than the usual use as
arguments), so player assigned names containing percent signs could
cause havoc (a few instances).  This fixes some of the former and one
of the latter, but doesn't deal with various other cases revealed by
grep.
This commit is contained in:
PatR
2017-06-03 16:05:23 -07:00
parent b604656077
commit 3512297f59
6 changed files with 38 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 monmove.c $NHDT-Date: 1463704424 2016/05/20 00:33:44 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.87 $ */
/* NetHack 3.6 monmove.c $NHDT-Date: 1496531115 2017/06/03 23:05:15 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.90 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1625,13 +1625,11 @@ struct permonst *ptr;
boolean domsg;
{
int reslt = 0;
char fmtstr[BUFSZ];
char oldmtype[BUFSZ];
/* remember current monster type before shapechange */
Strcpy(oldmtype, domsg ? noname_monnam(mon, ARTICLE_THE) : "");
if (domsg) {
Sprintf(fmtstr, "You %s %%s where %s was.",
sensemon(mon) ? "now detect" : "observe",
an(m_monnam(mon)));
}
if (mon->data == ptr) {
/* already right shape */
reslt = 1;
@@ -1639,9 +1637,13 @@ boolean domsg;
} else if (is_vampshifter(mon)) {
reslt = newcham(mon, ptr, FALSE, FALSE);
}
if (reslt && domsg) {
pline(fmtstr, an(m_monnam(mon)));
pline("You %s %s where %s was.",
!canseemon(mon) ? "now detect" : "observe",
noname_monnam(mon, ARTICLE_A), oldmtype);
}
return reslt;
}