]> granicus.if.org Git - nethack/commitdiff
more luck stone ID (trunk only)
authornethack.rankin <nethack.rankin>
Sun, 13 Nov 2005 04:43:50 +0000 (04:43 +0000)
committernethack.rankin <nethack.rankin>
Sun, 13 Nov 2005 04:43:50 +0000 (04:43 +0000)
     Refine yesterday's change in how attempting to assign an artifact's
name to some object works:  only check object descriptions for undiscovered
object types.  Once you know that a particular gray stone is a flint stone,
you could name it "the Heart of Ahriman" as before the previous change.
Conversely, once you learn luck stones, you could give that name to any
other unknown gray stone.  This restores the ability of a player to name
his elven broadsword such that some unsuspecting other player might find
"a runed broadsword named Stormbringer" in a bones file.

src/artifact.c

index ee1b660f817785b4ee9e8fea7bf70c08c78e0783..f24537b4c1d70ae817726c951b5dea5a0614f903 100644 (file)
@@ -286,13 +286,21 @@ register const char *name;
        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)));
+       /* decide what types of objects are the same as otyp;
+          if it's been discovered, then only itself matches;
+          otherwise, include all other undiscovered objects
+          of the same class which have the same description */
+       (void) memset((genericptr_t)sametype, 0, sizeof sametype); /* FALSE */
+       sametype[otyp] = TRUE;
+       if (!objects[otyp].oc_name_known &&
+               (odesc = OBJ_DESCR(objects[otyp])) != 0)
+           for (i = bases[ocls]; i < NUM_OBJECTS; i++) {
+               if (objects[i].oc_class != ocls) break;
+               if (!objects[i].oc_name_known &&
+                       (other = OBJ_DESCR(objects[i])) != 0 &&
+                       !strcmp(odesc, other))
+                   sametype[i] = TRUE;
+           }
 
                /* Since almost every artifact is SPFX_RESTR, it doesn't cost
                   us much to do the string comparison before the spfx check.