fix M203 - grammar for tin of hallucinated "mother-in-law" (trunk only)

From a bug report, (is that name just
a coincidence, or is it our Matt?), "this tin smells like mother-in-laws"
should be "this tin smells like mothers-in-law".  That led to a small can
of worms when I tried experimenting with mother-in-law as the named fruit.
Naming your fruit "pomegranates" would result in "pomegranateses" if you had
more than one.  These changes are mostly just band-aids for that; I think
the proper solution is to singularize the user's value when fruit name is
being assigned.  Force it into lower case at the same time, then some other
special casing could be eliminated.  There's no particular reason to keep
"grapes" and "grape" as separate entries, nor "matzot" and "MATZOT" either.

     One of the non foo-in-bar changes prevents "grapefruit" from getting
a false match against named fruit "grape".  (Are there any legitimate cases
where trailing text should be ignored?  I couldn't think of any.)  Another
results in a wish for "kumquats"--when fruit name "kumquat" exists--yielding
two instead of a random amount, the way that specifying plural works with
other sorts of objects.  And if you're strange enough to name your fruit
"kumquats" in the first place, asking for "kumquat" will produce exacly one.

     This patch applies cleanly to 3.4.4 but I don't think it's been tested
adequately enough to be included there.
This commit is contained in:
nethack.rankin
2005-10-22 06:38:41 +00:00
parent 74f08dcb22
commit 297eadd67d
2 changed files with 47 additions and 12 deletions

View File

@@ -90,6 +90,10 @@ losing a level while polymorphed affects hero's current monster HP as well as
underlying normal HP
mind flayer brain eating is subject to certain fatal targets and to cannibalism
corpses of unique monsters in bones behaved incorrectly if revived or eaten
fix pluralization for "this tin smells like mother-in-laws" when hallucinating
try harder to keep pluralization straight when user assigns an already plural
value for named fruit
avoid false matches when looking up fruit names ("grapefruit" isn't "grape")
Platform- and/or Interface-Specific Fixes

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)objnam.c 3.5 2005/01/31 */
/* SCCS Id: @(#)objnam.c 3.5 2005/10/21 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -223,6 +223,7 @@ register struct obj *obj;
register const char *actualn = OBJ_NAME(*ocl);
register const char *dn = OBJ_DESCR(*ocl);
register const char *un = ocl->oc_uname;
boolean pluralize = (obj->quan != 1L);
buf = nextobuf() + PREFIX; /* leave room for "17 -3 " */
if (Role_if(PM_SAMURAI) && Japanese_item_name(typ))
@@ -326,7 +327,16 @@ register struct obj *obj;
break;
}
}
if (!f) impossible("Bad fruit #%d?", obj->spe);
if (!f) {
impossible("Bad fruit #%d?", obj->spe);
Strcpy(buf, "fruit");
} else if (pluralize) {
/* ick; already pluralized fruit names
are allowed--we want to try to avoid
adding a redundant plural suffix */
Strcpy(buf, makeplural(makesingular(buf)));
pluralize = FALSE;
}
break;
}
@@ -451,7 +461,7 @@ register struct obj *obj;
default:
Sprintf(buf,"glorkum %d %d %d", obj->oclass, typ, obj->spe);
}
if (obj->quan != 1L) Strcpy(buf, makeplural(buf));
if (pluralize) Strcpy(buf, makeplural(buf));
if (obj->onamelth && obj->dknown) {
Strcat(buf, " named ");
@@ -1360,7 +1370,8 @@ const char *oldstr;
|| !strncmp(spot, " with", 5) /* " with "? */
|| !strncmp(spot, " de ", 4)
|| !strncmp(spot, " d'", 3)
|| !strncmp(spot, " du ", 4)) {
|| !strncmp(spot, " du ", 4)
|| !strncmp(spot, "-in-", 4)) {
excess = oldstr + (int) (spot - str);
*spot = 0;
break;
@@ -1596,8 +1607,14 @@ const char *oldstr;
bp = str;
while (*bp == ' ') bp++;
/* find "cloves of garlic", "worthless pieces of blue glass" */
if ((p = strstri(bp, "s of ")) != 0) {
/* find "cloves of garlic", "worthless pieces of blue glass",
"mothers-in-law"; note: this should probably be implemented
recursively since it can't recognize whether we should be
removing "es" rather than just "s" */
if ((p = strstri(bp, " of ")) != 0 ||
(p = strstri(bp, "-in-")) != 0) {
if (BSTRNCMP(bp, p-1, "s", 1)) return bp; /* wasn't plural */
--p; /* back up to the 's' */
/* but don't singularize "gauntlets", "boots", "Eyes of the.." */
if (BSTRNCMPI(bp, p-3, "Eye", 3) &&
BSTRNCMP(bp, p-4, "boot", 4) &&
@@ -1931,7 +1948,8 @@ struct obj *no_wish;
!strncmpi(bp, "rotted ", l=7)) {
eroded2 = 1 + very;
very = 0;
} else if (!strncmpi(bp, "partly eaten ", l=13)) {
} else if (!strncmpi(bp, "partly eaten ", l=13) ||
!strncmpi(bp, "partially eaten ", l=16)) {
halfeaten = 1;
} else if (!strncmpi(bp, "historic ", l=9)) {
ishistoric = 1;
@@ -2308,7 +2326,10 @@ srch:
typ = TIN;
goto typfnd;
}
/* Note: not strncmpi. 2 fruits, one capital, one not, are possible. */
/* Note: not strcmpi. 2 fruits, one capital, one not, are possible.
Also not strncmp. We used to ignore trailing text with it, but
that resulted in "grapefruit" matching "grape" if the latter came
earlier than the former in the fruit list. */
{
char *fp;
int l, cntf;
@@ -2334,22 +2355,32 @@ srch:
iscursedf = 1;
} else if (!strncmpi(fp, "uncursed ", l=9)) {
uncursedf = 1;
} else if (!strncmpi(fp, "partly eaten ", l=13)) {
} else if (!strncmpi(fp, "partly eaten ", l=13) ||
!strncmpi(fp, "partially eaten ", l=16)) {
halfeatenf = 1;
} else break;
fp += l;
}
for(f=ffruit; f; f = f->nextf) {
char *f1 = f->fname, *f2 = makeplural(f->fname);
/* match type: 0=none, 1=exact, 2=singular, 3=plural */
int ftyp = 0;
if(!strncmp(fp, f1, strlen(f1)) ||
!strncmp(fp, f2, strlen(f2))) {
if (!strcmp(fp, f->fname)) ftyp = 1;
else if (!strcmp(fp, makesingular(f->fname))) ftyp = 2;
else if (!strcmp(fp, makeplural(f->fname))) ftyp = 3;
if (ftyp) {
typ = SLIME_MOLD;
blessed = blessedf;
iscursed = iscursedf;
uncursed = uncursedf;
halfeaten = halfeatenf;
/* adjust count if user explicitly asked for
singular amount (can't happen unless fruit
has been given an already pluralized name)
or for plural amount */
if (ftyp == 2 && !cntf) cntf = 1;
else if (ftyp == 3 && !cntf) cntf = 2;
cnt = cntf;
ftype = f->fid;
goto typfnd;