]> granicus.if.org Git - nethack/commitdiff
plug luckstone identification hole (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 12 Nov 2005 05:30:11 +0000 (05:30 +0000)
committernethack.rankin <nethack.rankin>
Sat, 12 Nov 2005 05:30:11 +0000 (05:30 +0000)
      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
src/artifact.c

index ea0d5510604884510694ad9719d18a5d8bf08029..9212446bcf544902eb87848280d15552bccd0362 100644 (file)
@@ -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
index 41aa90b5cbde6f7d286ea6970d61dd05694ef5ae..ee1b660f817785b4ee9e8fea7bf70c08c78e0783 100644 (file)
@@ -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))