From: PatR Date: Wed, 5 Jul 2017 01:44:03 +0000 (-0700) Subject: fix #H3013 - grammar bug with named fruit X-Git-Tag: NetHack-3.6.1_RC01~454 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a573134d7e037b6896fef574d5ef04e06c28856a;p=nethack 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. --- diff --git a/src/objnam.c b/src/objnam.c index 4648649e3..ec7c0e70e 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -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 {