From eebe30b037ab59826c940ced4f7b0654a784004c Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 28 Oct 2022 23:28:29 -0400 Subject: [PATCH] Message for giving unnameable monster blank name The message for trying to (re)name an unnameable monster was weird when the player entered a blank name (a name consisting of only spaces), in an attempt to delete the monster's existing name rather than give it a new one. Several of the normal messages looked incomplete due to using the blank string as the "new name" (e.g., "I'm Feyfer, not ."), and the one which didn't include the name still seemed a little off ("calling names" is almost the opposite of what the player is doing). Add a new message for attempting to erase the name of one of the special unnameable monsters, e.g. "Juiblex would rather keep his existing name" or "The Oracle would rather keep her existing title". I also noticed that the message for trying to give an unrenameable monster the name it already has (e.g. trying to name Death "Death") was revealing the genders of the Riders with personal pronouns. This is avoided elsewhere (e.g. using "the way" in mdisplacem, "its" baked into the message in mhitm_ad_deth), so I also added a slightly rephrased alternate message for Riders which avoids any pronouns. For the unnaming message, on the other hand, I just used "its" for the Riders, since I couldn't think of a way to phrase it that avoided pronouns entirely. --- src/do_name.c | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/do_name.c b/src/do_name.c index 784273148..6bd3d71e4 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1162,24 +1162,38 @@ christen_monst(struct monst *mtmp, const char *name) } /* check whether user-supplied name matches or nearly matches an unnameable - monster's name; if so, give alternate reject message for do_mgivenname() */ + monster's name, or is an attempt to delete the monster's name; if so, give + alternate reject message for do_mgivenname() */ static boolean alreadynamed(struct monst *mtmp, char *monnambuf, char *usrbuf) { char pronounbuf[10], *p; - if (fuzzymatch(usrbuf, monnambuf, " -_", TRUE) - /* catch trying to name "the Oracle" as "Oracle" */ - || (!strncmpi(monnambuf, "the ", 4) - && fuzzymatch(usrbuf, monnambuf + 4, " -_", TRUE)) - /* catch trying to name "invisible Orcus" as "Orcus" */ - || ((p = strstri(monnambuf, "invisible ")) != 0 - && fuzzymatch(usrbuf, p + 10, " -_", TRUE)) - /* catch trying to name "the {priest,Angel} of Crom" as "Crom" */ - || ((p = strstri(monnambuf, " of ")) != 0 - && fuzzymatch(usrbuf, p + 4, " -_", TRUE))) { - pline("%s is already called %s.", - upstart(strcpy(pronounbuf, mhe(mtmp))), monnambuf); + if (!*usrbuf) { /* attempt to erase existing name */ + boolean name_not_title = (has_mgivenname(mtmp) + || type_is_pname(mtmp->data) + || mtmp->isshk); + pline("%s would rather keep %s existing %s.", upstart(monnambuf), + is_rider(mtmp->data) ? "its" : mhis(mtmp), + name_not_title ? "name" : "title"); + return TRUE; + } else if (fuzzymatch(usrbuf, monnambuf, " -_", TRUE) + /* catch trying to name "the Oracle" as "Oracle" */ + || (!strncmpi(monnambuf, "the ", 4) + && fuzzymatch(usrbuf, monnambuf + 4, " -_", TRUE)) + /* catch trying to name "invisible Orcus" as "Orcus" */ + || ((p = strstri(monnambuf, "invisible ")) != 0 + && fuzzymatch(usrbuf, p + 10, " -_", TRUE)) + /* catch trying to name "the priest of Crom" as "Crom" */ + || ((p = strstri(monnambuf, " of ")) != 0 + && fuzzymatch(usrbuf, p + 4, " -_", TRUE))) { + if (is_rider(mtmp->data)) { + /* avoid gendered pronoun for riders */ + pline("%s is already called that.", upstart(monnambuf)); + } else { + pline("%s is already called %s.", + upstart(strcpy(pronounbuf, mhe(mtmp))), monnambuf); + } return TRUE; } else if (mtmp->data == &mons[PM_JUIBLEX] && strstri(monnambuf, "Juiblex") @@ -1249,11 +1263,9 @@ do_mgivenname(void) * Shopkeepers, temple priests and other minions use alternate * name formatting routines which ignore any user-supplied name. * - * Don't say the name is being rejected if it happens to match - * the existing name. - * - * TODO: should have an alternate message when the attempt is to - * remove existing name without assigning a new one. + * Don't say a new name is being rejected if it happens to match + * the existing name, or if the player is trying to remove the + * monster's existing name without assigning a new one. */ if ((mtmp->data->geno & G_UNIQ) && !mtmp->ispriest) { if (!alreadynamed(mtmp, monnambuf, buf)) @@ -1267,8 +1279,9 @@ do_mgivenname(void) || mtmp->data == &mons[PM_GHOST]) { if (!alreadynamed(mtmp, monnambuf, buf)) pline("%s will not accept the name %s.", upstart(monnambuf), buf); - } else + } else { (void) christen_monst(mtmp, buf); + } } /*