From c2e8fb61b83b0534e04d669926f0f26c33eeb5b0 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sun, 13 Nov 2005 04:43:50 +0000 Subject: [PATCH] more luck stone ID (trunk only) 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 | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/artifact.c b/src/artifact.c index ee1b660f8..f24537b4c 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -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. -- 2.40.0