From d5be1ff3f1d7e95f6f9c58d837795af62dcceb1c Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sat, 12 Nov 2005 05:30:11 +0000 Subject: [PATCH] plug luckstone identification hole (trunk only) From the newsgroup: when you pick up a gray stone, you can determine whether it is a luckstone by attempting to name it "the Heart of Ahriman". Your "fingers slip" if it is, they don't if it isn't. That's way too cheesy for my tastes. This patch will make the finger slipping occur for any item that has the same description rather than just for the exact type. Now you won't be able to name any type of gray stone "the Heart of Ahriman" (nor an elven broadsword "Stormbringer"; however, assuming that you manage to acquire a non-artifact runesword, you can still uselessly name it "Orcrist" if you want). --- doc/fixes35.0 | 2 ++ src/artifact.c | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index ea0d55106..9212446bc 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -95,6 +95,8 @@ 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") handle pluralization of man-at-arms and singularization of men-at-arms +assigning an artifact name is rejected on objects with similar description to + corresponding artifact's type rather than just those of the same type Platform- and/or Interface-Specific Fixes diff --git a/src/artifact.c b/src/artifact.c index 41aa90b5c..ee1b660f8 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)artifact.c 3.5 2005/10/01 */ +/* SCCS Id: @(#)artifact.c 3.5 2005/11/11 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -279,17 +279,27 @@ register struct obj *otmp; register const char *name; { register const struct artifact *a; - register const char *aname; + const char *aname, *odesc, *other; + boolean sametype[NUM_OBJECTS]; + int i, otyp = otmp->otyp, ocls = objects[otyp].oc_class; if (!*name) return FALSE; if (!strncmpi(name, "the ", 4)) name += 4; + /* find any alternate types which have the same description as otyp */ + odesc = OBJ_DESCR(objects[otyp]); + for (i = 0; i < NUM_OBJECTS; i++) + sametype[i] = (i == otyp || + (objects[i].oc_class == ocls && + odesc && (other = OBJ_DESCR(objects[i])) != 0 && + !strcmp(odesc, other))); + /* Since almost every artifact is SPFX_RESTR, it doesn't cost us much to do the string comparison before the spfx check. Bug fix: don't name multiple elven daggers "Sting". */ for (a = artilist+1; a->otyp; a++) { - if (a->otyp != otmp->otyp) continue; + if (!sametype[a->otyp]) continue; aname = a->name; if (!strncmpi(aname, "the ", 4)) aname += 4; if (!strcmp(aname, name)) -- 2.40.0