diff --git a/doc/fixes37.0 b/doc/fixes37.0 index c08a0bd11..7165222b4 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -691,6 +691,10 @@ fix up some "the" handling for monsters whose type name is upper case to avoid controlled polymorph would turn hero into new man or woman if player asked to become a unique monster of the same race (so usually human) instead of being told that polymorphing into the specified form wasn't allowed +assigning a fruit name that matches the name of an artifact which doesn't use + any "the" prefix could yield messages showing "the Artifact" when + dealing with the artifact rather than fruit: "You are blasted by _the_ + Excalibur's power!"; didn't impact basic inventory formatting Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/artifact.c b/src/artifact.c index 58b08ecc6..832162a1d 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -219,7 +219,8 @@ artifact_name(const char *name, short *otyp) if (!strncmpi(aname, "the ", 4)) aname += 4; if (!strcmpi(name, aname)) { - *otyp = a->otyp; + if (otyp) + *otyp = a->otyp; return a->name; } } diff --git a/src/objnam.c b/src/objnam.c index 759c6fd82..86617bcf2 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1016,18 +1016,23 @@ erosion_matters(struct obj* obj) #define DONAME_WITH_PRICE 1 #define DONAME_VAGUE_QUAN 2 +/* core of doname() */ static char * -doname_base(struct obj* obj, unsigned int doname_flags) +doname_base( + struct obj* obj, /* object to format */ + unsigned doname_flags) /* special case requests */ { boolean ispoisoned = FALSE, with_price = (doname_flags & DONAME_WITH_PRICE) != 0, vague_quan = (doname_flags & DONAME_VAGUE_QUAN) != 0; - boolean known, dknown, cknown, bknown, lknown; - int omndx = obj->corpsenm; + boolean known, dknown, cknown, bknown, lknown, + fake_arti, force_the; char prefix[PREFIX]; char tmpbuf[PREFIX + 1]; /* for when we have to add something at - the start of prefix instead of the - end (Strcat is used on the end) */ + * the start of prefix instead of the + * end (Strcat is used on the end) */ + const char *aname; + int omndx = obj->corpsenm; register char *bp = xname(obj); if (iflags.override_ID) { @@ -1051,6 +1056,14 @@ doname_base(struct obj* obj, unsigned int doname_flags) ispoisoned = TRUE; } + /* fruits are allowed to be given artifact names; when that happens, + format the name like the corresponding artifact, which may or may not + want "the" prefix and when it doesn't, avoid "a"/"an" prefix too */ + fake_arti = (obj->otyp == SLIME_MOLD + && (aname = artifact_name(bp, (short *) 0)) != 0); + force_the = (fake_arti && aname && !strncmpi(aname, "the ", 4)); + + prefix[0] = '\0'; if (obj->quan != 1L) { if (dknown || !vague_quan) Sprintf(prefix, "%ld ", obj->quan); @@ -1059,12 +1072,13 @@ doname_base(struct obj* obj, unsigned int doname_flags) } else if (obj->otyp == CORPSE) { /* skip article prefix for corpses [else corpse_xname() would have to be taught how to strip it off again] */ - *prefix = '\0'; - } else if (obj_is_pname(obj) || the_unique_obj(obj)) { + ; + } else if (force_the || obj_is_pname(obj) || the_unique_obj(obj)) { if (!strncmpi(bp, "the ", 4)) bp += 4; Strcpy(prefix, "the "); - } else { + } else if (!fake_arti) { + /* default prefix */ Strcpy(prefix, "a "); } @@ -1813,6 +1827,7 @@ An(const char* str) char * the(const char* str) { + const char *aname; char *buf = nextobuf(); boolean insert_the = FALSE; @@ -1828,8 +1843,11 @@ the(const char* str) /* some capitalized monster names want "the", others don't */ || CapitalMon(str) /* treat named fruit as not a proper name, even if player - has assigned a capitalized proper name as his/her fruit */ - || fruit_from_name(str, TRUE, (int *) 0)) { + has assigned a capitalized proper name as his/her fruit, + unless it matches an artifact name */ + || (fruit_from_name(str, TRUE, (int *) 0) + && ((aname = artifact_name(str, (short *) 0)) == 0 + || strncmpi(aname, "the ", 4) == 0))) { /* not a proper name, needs an article */ insert_the = TRUE; } else {