fix #H3013 - grammar bug with named fruit

Reported nearly four years ago for 3.4.3, original subject was
\#H3013: NetHack grammar bug when taking unpaid fruit from chest

Player used OPTIONS=fruit:Quorn and the capitalized value confuses
the() into thinking it's a proper name which shouldn't be preceded
by an article, resulting in "Quorn will cost you N zorkmids" when
removing it from a chest in a shop, followed by "X - a Quorn (unpaid)"
as it went into inventory.  It is a product name, but when used as a
fruit it shouldn't be treated as a proper name.  (Quorn is a meat
substitute rather than anything related to fruit.)  Teach the() about
named-fruits, so that we'll get "The Quorn will cost you N zorkmids."

Unfortunately, it means that someone who names their fruit after a
proper name used by the program, for example Mjollnir, can probably
induce other poorly worded messages (about the item rather than the
named-fruit).  the() is used all over the place and all it has to work
with is text, not the object whose formatted name produced that text.

I looked through a bunch of old cvs log messages last night, and
spotted one I wrote (in objnam.c) a dozen years ago where I suggested
forcing named-fruit values into lower case as they're being set up.
I don't remember that, but if we'd done it, this bug would have been
avoided.
This commit is contained in:
PatR
2017-07-04 18:44:03 -07:00
parent 7a8559a34d
commit a573134d7e

View File

@@ -1623,7 +1623,10 @@ const char *str;
buf[0] = lowc(*str);
Strcpy(&buf[1], str + 1);
return buf;
} else if (*str < 'A' || *str > 'Z') {
} else if (*str < 'A' || *str > 'Z'
/* 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)) {
/* not a proper name, needs an article */
insert_the = TRUE;
} else {