]> granicus.if.org Git - nethack/commitdiff
found_artifact() groundwork
authorPatR <rankin@nethack.org>
Mon, 7 Mar 2022 10:06:55 +0000 (02:06 -0800)
committerPatR <rankin@nethack.org>
Mon, 7 Mar 2022 10:06:55 +0000 (02:06 -0800)
Lay groundwork for generating a log event when finding an artifact
on the floor or carried by a monster.  This part should not produce
any change in behavior.

Move g.artidisco[] and g.artiexist[] out of the instance_globals
struct back to local within artifact.c.  They are both initialized
at the start of a game (and only used in that file) so don't need
to be part of any bulk reinitialization if restart-instead-of-exit
ever gets implemented.

Convert artiexist[] from an array of booleans to an array of structs
containing a pair of bitfields.  artiexist[].exists is a direct
replacement for the boolean; artiexist[].found is new but not put to
any significant use yet.  If will be used to suppress the future
found-an-artifact event for cases where a more specific event (like
crowning or divine gift as #offer reward) is already produced.

Remove g.via_naming altogether and add an extra argument to oname()
calls to replace it.

Add an extra argument to artifact_exists() calls.

20 files changed:
include/decl.h
include/extern.h
include/hack.h
src/artifact.c
src/bones.c
src/decl.c
src/do_name.c
src/fountain.c
src/insight.c
src/invent.c
src/mail.c
src/makemon.c
src/mkobj.c
src/mon.c
src/objnam.c
src/pickup.c
src/pray.c
src/sp_lev.c
src/steal.c
src/topten.c

index e065d0aa6840cbf8497b98ea80753a4345ca0fa3..387ebb83e65615d0d41b6df26efe88e6ba5aacb1 100644 (file)
@@ -421,7 +421,6 @@ struct plinemsg_type {
 /* bitmask for callers of hide_unhide_msgtypes() */
 #define MSGTYP_MASK_REP_SHOW ((1 << MSGTYP_NOREP) | (1 << MSGTYP_NOSHOW))
 
-
 enum bcargs {override_restriction = -1};
 struct breadcrumbs {
     const char *funcnm;
@@ -701,10 +700,6 @@ struct instance_globals {
     /* artifcat.c */
     int spec_dbon_applies; /* coordinate effects from spec_dbon() with
                               messages in artifact_hit() */
-    /* flags including which artifacts have already been created */
-    boolean artiexist[1 + NROFARTIFACTS + 1];
-    /* and a discovery list for them (no dummy first entry here) */
-    xchar artidisco[NROFARTIFACTS];
     int mkot_trap_warn_count;
 
     /* botl.c */
@@ -864,7 +859,6 @@ struct instance_globals {
     /* do_name.c */
     struct selectionvar *gloc_filter_map;
     int gloc_filter_floodfill_match_glyph;
-    int via_naming;
 
     /* do_wear.c */
     /* starting equipment gets auto-worn at beginning of new game,
index d18f5b1000429fbb028c6d174b6a48ff46a4fc7f..8a4535b7dbf2de69160bc404072da574d57e9788 100644 (file)
@@ -69,7 +69,9 @@ extern const char *artiname(int);
 extern struct obj *mk_artifact(struct obj *, aligntyp);
 extern const char *artifact_name(const char *, short *);
 extern boolean exist_artifact(int, const char *);
-extern void artifact_exists(struct obj *, const char *, boolean);
+extern void artifact_exists(struct obj *, const char *, boolean, boolean);
+extern void found_artifact(int);
+extern void find_artifact(struct obj *);
 extern int nartifact_exist(void);
 extern boolean arti_immune(struct obj *, int);
 extern boolean spec_ability(struct obj *, unsigned long);
@@ -470,7 +472,7 @@ extern void new_oname(struct obj *, int);
 extern void free_oname(struct obj *);
 extern const char *safe_oname(struct obj *);
 extern struct monst *christen_monst(struct monst *, const char *);
-extern struct obj *oname(struct obj *, const char *);
+extern struct obj *oname(struct obj *, const char *, unsigned);
 extern boolean objtyp_is_callable(int);
 extern int docallcmd(void);
 extern void docall(struct obj *);
index 34752e603992e89fce9940fc537b9f9289efc1d7..eb2acebcf84846bea1b997b2d79bbdd6f3e40abd 100644 (file)
@@ -371,6 +371,11 @@ typedef struct sortloot_item Loot;
 #define BUCX_TYPES (BUC_ALLBKNOWN | BUC_UNKNOWN)
 #define ALL_TYPES_SELECTED -2
 
+/* Flags for oname() */
+#define ONAME_NO_FLAGS   0U /* none of the below */
+#define ONAME_VIA_NAMING 1U /* oname() is being called by do_oname() */
+#define ONAME_FOUND_ARTI 2U /* if an artifact, hero becomes aware of it */
+
 /* Flags to control find_mid() */
 #define FM_FMON 0x01    /* search the fmon chain */
 #define FM_MIGRATE 0x02 /* search the migrating monster chain */
index 2132d620456171822f102ab75ede61988c520759..3006059185ee1e2736a0965c53cb4fe26aa605ee 100644 (file)
@@ -39,6 +39,23 @@ static int count_surround_traps(int, int);
    of hit points that will fit in a 15 bit integer. */
 #define FATAL_DAMAGE_MODIFIER 200
 
+/* artifact tracking */
+struct arti_info {
+    Bitfield(exists, 1); /* True if corresponding artifact has been created */
+    Bitfield(found, 1);  /* True if artifact is known by hero to exist */
+};
+/* array of flags tracking which artifacts exist, indexed by ART_xx;
+   ART_xx values are 1..N, element [0] isn't used */
+static struct arti_info artiexist[1 + NROFARTIFACTS];
+/* discovery list; for N discovered artifacts, the first N entries are ART_xx
+   values in discovery order, the remaining (NROFARTIFACTS-N) slots are 0 */
+static xchar artidisco[NROFARTIFACTS];
+/* note: artiexist[] and artidisco[] don't need to be in struct g; they
+ * get explicitly initialized at game start so don't need to be part of
+ * bulk re-init if game restart ever gets implemented.  They are saved
+ * and restored but that is done through this file so they can be local.
+ */
+
 static void hack_artifacts(void);
 static boolean attacks(int, struct obj *);
 
@@ -70,8 +87,8 @@ hack_artifacts(void)
 void
 init_artifacts(void)
 {
-    (void) memset((genericptr_t) g.artiexist, 0, sizeof g.artiexist);
-    (void) memset((genericptr_t) g.artidisco, 0, sizeof g.artidisco);
+    (void) memset((genericptr_t) artiexist, 0, sizeof artiexist);
+    (void) memset((genericptr_t) artidisco, 0, sizeof artidisco);
     hack_artifacts();
 }
 
@@ -79,8 +96,8 @@ void
 save_artifacts(NHFILE *nhfp)
 {
     if (nhfp->structlevel) {
-        bwrite(nhfp->fd, (genericptr_t) g.artiexist, sizeof g.artiexist);
-        bwrite(nhfp->fd, (genericptr_t) g.artidisco, sizeof g.artidisco);
+        bwrite(nhfp->fd, (genericptr_t) artiexist, sizeof artiexist);
+        bwrite(nhfp->fd, (genericptr_t) artidisco, sizeof artidisco);
     }
 }
 
@@ -88,8 +105,8 @@ void
 restore_artifacts(NHFILE *nhfp)
 {
     if (nhfp->structlevel) {
-        mread(nhfp->fd, (genericptr_t) g.artiexist, sizeof g.artiexist);
-        mread(nhfp->fd, (genericptr_t) g.artidisco, sizeof g.artidisco);
+        mread(nhfp->fd, (genericptr_t) artiexist, sizeof artiexist);
+        mread(nhfp->fd, (genericptr_t) artidisco, sizeof artidisco);
     }
     hack_artifacts();  /* redo non-saved special cases */
 }
@@ -114,8 +131,9 @@ artiname(int artinum)
    for the 1st, ``obj = mk_artifact((struct obj *)0, some_alignment);''.
  */
 struct obj *
-mk_artifact(struct obj *otmp,   /* existing object; ignored if alignment specified */
-            aligntyp alignment) /* target alignment, or A_NONE */
+mk_artifact(
+    struct obj *otmp,   /* existing object; ignored if alignment specified */
+    aligntyp alignment) /* target alignment, or A_NONE */
 {
     const struct artifact *a;
     int m, n, altn;
@@ -128,7 +146,7 @@ mk_artifact(struct obj *otmp,   /* existing object; ignored if alignment specifi
     eligible[0] = 0; /* lint suppression */
     /* gather eligible artifacts */
     for (m = 1, a = &artilist[m]; a->otyp; a++, m++) {
-        if (g.artiexist[m])
+        if (artiexist[m].exists)
             continue;
         if ((a->spfx & SPFX_NOGEN) || unique)
             continue;
@@ -186,9 +204,10 @@ mk_artifact(struct obj *otmp,   /* existing object; ignored if alignment specifi
             otmp = mksobj((int) a->otyp, TRUE, FALSE);
 
         if (otmp) {
-            otmp = oname(otmp, a->name);
+            otmp = oname(otmp, a->name, ONAME_NO_FLAGS);
             otmp->oartifact = m;
-            g.artiexist[m] = TRUE;
+            artiexist[m].exists = 1;
+            artiexist[m].found = 0;
         }
     } else {
         /* nothing appropriate could be found; return original object */
@@ -232,43 +251,66 @@ boolean
 exist_artifact(int otyp, const char *name)
 {
     register const struct artifact *a;
-    boolean *arex;
+    struct arti_info *arex;
 
     if (otyp && *name)
-        for (a = artilist + 1, arex = g.artiexist + 1; a->otyp; a++, arex++)
+        for (a = artilist + 1, arex = artiexist + 1; a->otyp; a++, arex++)
             if ((int) a->otyp == otyp && !strcmp(a->name, name))
-                return *arex;
+                return arex->exists ? TRUE : FALSE;
     return FALSE;
 }
 
 void
-artifact_exists(struct obj *otmp, const char *name, boolean mod)
+artifact_exists(
+    struct obj *otmp,
+    const char *name,
+    boolean mod,      /* True: exists, False: being uncreated */
+    boolean knwn)     /* True: hero knows it exists */
 {
     register const struct artifact *a;
 
     if (otmp && *name)
         for (a = artilist + 1; a->otyp; a++)
             if (a->otyp == otmp->otyp && !strcmp(a->name, name)) {
-                register int m = (int) (a - artilist);
+                int m = (int) (a - artilist);
+
                 otmp->oartifact = (char) (mod ? m : 0);
                 otmp->age = 0;
                 if (otmp->otyp == RIN_INCREASE_DAMAGE)
                     otmp->spe = 0;
-                g.artiexist[m] = mod;
+                artiexist[m].exists = mod ? 1 : 0;
+                artiexist[m].found = (mod && knwn) ? 1 : 0;
                 break;
             }
     return;
 }
 
+/* make an artifact as 'found' */
+void
+found_artifact(int a)
+{
+    artiexist[a].found = 1;
+}
+
+/* if an artifact hasn't already been designated 'found', do that now */
+void
+find_artifact(struct obj *otmp)
+{
+    int a = otmp->oartifact;
+
+    if (a && !artiexist[a].found) {
+        found_artifact(a); /* artiexist[a].found = 1 */
+    }
+}
+
 int
 nartifact_exist(void)
 {
-    int a = 0;
-    int n = SIZE(g.artiexist);
+    int i, a = 0;
 
-    while (n > 1)
-        if (g.artiexist[--n])
-            a++;
+    for (i = 1; i <= NROFARTIFACTS; ++i)
+        if (artiexist[i].exists)
+            ++a;
 
     return a;
 }
@@ -861,8 +903,9 @@ discover_artifact(xchar m)
     /* look for this artifact in the discoveries list;
        if we hit an empty slot then it's not present, so add it */
     for (i = 0; i < NROFARTIFACTS; i++)
-        if (g.artidisco[i] == 0 || g.artidisco[i] == m) {
-            g.artidisco[i] = m;
+        if (artidisco[i] == 0 || artidisco[i] == m) {
+            artidisco[i] = m;
+            artiexist[i].found = 1; /* (we expect this to already be set) */
             return;
         }
     /* there is one slot per artifact, so we should never reach the
@@ -879,9 +922,9 @@ undiscovered_artifact(xchar m)
     /* look for this artifact in the discoveries list;
        if we hit an empty slot then it's undiscovered */
     for (i = 0; i < NROFARTIFACTS; i++)
-        if (g.artidisco[i] == m)
+        if (artidisco[i] == m)
             return FALSE;
-        else if (g.artidisco[i] == 0)
+        else if (artidisco[i] == 0)
             break;
     return TRUE;
 }
@@ -894,14 +937,14 @@ disp_artifact_discoveries(winid tmpwin) /* supplied by dodiscover() */
     char buf[BUFSZ];
 
     for (i = 0; i < NROFARTIFACTS; i++) {
-        if (g.artidisco[i] == 0)
+        if (artidisco[i] == 0)
             break; /* empty slot implies end of list */
         if (tmpwin == WIN_ERR)
             continue; /* for WIN_ERR, we just count */
 
         if (i == 0)
             putstr(tmpwin, iflags.menu_headings, "Artifacts");
-        m = g.artidisco[i];
+        m = artidisco[i];
         otyp = artilist[m].otyp;
         Sprintf(buf, "  %s [%s %s]", artiname(m),
                 align_str(artilist[m].alignment), simple_typename(otyp));
index 6fa2dac4e49e67c4cb13bc5083d14c6d24b6215d..f9c56f489e0ae75090a86bd1b577e5d688652f92 100644 (file)
@@ -70,7 +70,7 @@ resetobjs(struct obj *ochain, boolean restore)
                     if (has_oname(otmp))
                         free_oname(otmp);
                 } else {
-                    artifact_exists(otmp, safe_oname(otmp), TRUE);
+                    artifact_exists(otmp, safe_oname(otmp), TRUE, FALSE);
                 }
             } else if (has_oname(otmp)) {
                 sanitize_name(ONAME(otmp));
index c35085c6223fe90b699344e402b8e2c00fcfe255..8a17770840fc7692c1a1d4878d790bda07141b1b 100644 (file)
@@ -202,8 +202,6 @@ const struct instance_globals g_init = {
 
     /* artifact.c */
     0,  /* spec_dbon_applies */
-    UNDEFINED_VALUES, /* artiexist */
-    UNDEFINED_VALUES, /* artdisco */
     0, /* mkot_trap_warn_count */
 
     /* botl.c */
@@ -352,7 +350,6 @@ const struct instance_globals g_init = {
     /* do_name.c */
     NULL, /* gloc_filter_map */
     UNDEFINED_VALUE, /* gloc_filter_floodfill_match_glyph */
-    0, /* via_naming */
 
     /* do_wear.c */
     FALSE, /* initial_don */
index 9e25089518faeb00326d7d9f22ec99df20c6941a..843ecf3b152f00490fedf2a770f24a37b42d2641 100644 (file)
@@ -1300,16 +1300,16 @@ do_oname(register struct obj *obj)
            a valid artifact name */
         u.uconduct.literate++;
     }
-    ++g.via_naming; /* This ought to be an argument rather than a static... */
-    obj = oname(obj, buf);
-    --g.via_naming; /* ...but oname() is used in a lot of places, so defer. */
+    obj = oname(obj, buf, ONAME_VIA_NAMING);
 }
 
 struct obj *
-oname(struct obj *obj, const char *name)
+oname(struct obj *obj, const char *name, unsigned oflgs)
 {
     int lth;
     char buf[PL_PSIZ];
+    boolean via_naming = (oflgs & ONAME_VIA_NAMING) != 0,
+            found_arti = (oflgs & ONAME_FOUND_ARTI) != 0;
 
     lth = *name ? (int) (strlen(name) + 1) : 0;
     if (lth > PL_PSIZ) {
@@ -1318,9 +1318,9 @@ oname(struct obj *obj, const char *name)
         buf[PL_PSIZ - 1] = '\0';
     }
     /* If named artifact exists in the game, do not create another.
-     * Also trying to create an artifact shouldn't de-artifact
-     * it (e.g. Excalibur from prayer). In this case the object
-     * will retain its current name. */
+       Also trying to create an artifact shouldn't de-artifact
+       it (e.g. Excalibur from prayer). In this case the object
+       will retain its current name. */
     if (obj->oartifact || (lth && exist_artifact(obj->otyp, name)))
         return obj;
 
@@ -1329,7 +1329,7 @@ oname(struct obj *obj, const char *name)
         Strcpy(ONAME(obj), name);
 
     if (lth)
-        artifact_exists(obj, name, TRUE);
+        artifact_exists(obj, name, TRUE, via_naming || found_arti);
     if (obj->oartifact) {
         /* can't dual-wield with artifact as secondary weapon */
         if (obj == uswapwep)
@@ -1340,7 +1340,7 @@ oname(struct obj *obj, const char *name)
         /* if obj is owned by a shop, increase your bill */
         if (obj->unpaid)
             alter_cost(obj, 0L);
-        if (g.via_naming) {
+        if (via_naming) {
             /* violate illiteracy conduct since successfully wrote arti-name */
             if (!u.uconduct.literate++)
                 livelog_printf(LL_CONDUCT | LL_ARTIFACT,
index ea81dd7db7f546dca2f6689d0814da75156244bc..b9292ed495bd4a685b8d463cf7cfbb6ba73b889b 100644 (file)
@@ -377,11 +377,12 @@ dipfountain(register struct obj *obj)
         return;
     }
 
-    /* Don't grant Excalibur when there's more than one object.  */
-    /* (quantity could be > 1 if merged daggers got polymorphed) */
-    if (obj->otyp == LONG_SWORD && obj->quan == 1L && u.ulevel >= 5 && !rn2(6)
-        && !obj->oartifact
+    if (obj->otyp == LONG_SWORD && u.ulevel >= 5 && !rn2(6)
+        /* once upon a time it was possible to poly N daggers into N swords */
+        && obj->quan == 1L && !obj->oartifact
         && !exist_artifact(LONG_SWORD, artiname(ART_EXCALIBUR))) {
+        static const char lady[] = "Lady of the Lake";
+
         if (u.ualign.type != A_LAWFUL) {
             /* Ha!  Trying to cheat her. */
             pline("A freezing mist rises from the %s and envelopes the sword.",
@@ -392,20 +393,23 @@ dipfountain(register struct obj *obj)
                 obj->spe--;
             obj->oerodeproof = FALSE;
             exercise(A_WIS, FALSE);
-            livelog_printf(LL_ARTIFACT, "was denied Excalibur! The Lady of the Lake has deemed %s unworthy", uhim());
+            livelog_printf(LL_ARTIFACT,
+                           "was denied %s!  The %s has deemed %s unworthy",
+                           artiname(ART_EXCALIBUR), lady, uhim());
         } else {
             /* The lady of the lake acts! - Eric Backus */
             /* Be *REAL* nice */
             pline(
               "From the murky depths, a hand reaches up to bless the sword.");
             pline("As the hand retreats, the fountain disappears!");
-            obj = oname(obj, artiname(ART_EXCALIBUR));
+            obj = oname(obj, artiname(ART_EXCALIBUR), ONAME_FOUND_ARTI);
             discover_artifact(ART_EXCALIBUR);
             bless(obj);
             obj->oeroded = obj->oeroded2 = 0;
             obj->oerodeproof = TRUE;
             exercise(A_WIS, TRUE);
-            livelog_printf(LL_ARTIFACT, "was given Excalibur");
+            livelog_printf(LL_ARTIFACT, "was given %s by the %s",
+                           artiname(ART_EXCALIBUR), lady);
         }
         update_inventory();
         levl[u.ux][u.uy].typ = ROOM, levl[u.ux][u.uy].flags = 0;
index f41d77d24924841c47ee1571236c91f5456baf17..7ca9bfcb748b9b536a905a20b09e443e048dd93b 100644 (file)
@@ -2311,6 +2311,9 @@ record_achievement(schar achidx)
                       ? g.context.achieveo.soko_prize_otyp
                       : g.context.achieveo.mines_prize_otyp);
 
+        /* note: OBJ_NAME() works here because both "bag of holding" and
+           "amulet of reflection" are fully named in their objects[] entry
+           but that's not true in the general case */
         livelog_printf(achieve_msg[achidx].llflag, "%s %s",
                        achieve_msg[achidx].msg, OBJ_NAME(objects[otyp]));
     } else {
index 1142ae9bf3a1de13b5977f80faaff579fde606b7..569bb6eaf38061176ba22eeb90d137ae2504c281 100644 (file)
@@ -715,7 +715,7 @@ merged(struct obj **potmp, struct obj **pobj)
         else if (!Is_pudding(otmp))
             otmp->owt += obj->owt;
         if (!has_oname(otmp) && has_oname(obj))
-            otmp = *potmp = oname(otmp, ONAME(obj));
+            otmp = *potmp = oname(otmp, ONAME(obj), ONAME_NO_FLAGS);
         obj_extract_self(obj);
 
         if (obj->pickup_prev && otmp->where == OBJ_INVENT)
index 7274ac0e144c3bedede89d4c83289bf609d1e11c..d407f395c229e6ce8bab1b4fbed94c5ef1dbb8d4 100644 (file)
@@ -409,7 +409,7 @@ newmail(struct mail_info *info)
         struct obj *obj = mksobj(SCR_MAIL, FALSE, FALSE);
 
         if (info->object_nam)
-            obj = oname(obj, info->object_nam);
+            obj = oname(obj, info->object_nam, ONAME_NO_FLAGS);
         if (info->response_cmd)
             new_omailcmd(obj, info->response_cmd);
 
index a4cae89f73fc8d8d80e9a315e6573da6d351e24e..0c4346c3488fefe24b340e2ffeab1803be12bf30 100644 (file)
@@ -326,7 +326,8 @@ m_initweap(register struct monst *mtmp)
             /* maybe make it special */
             if (!rn2(20) || is_lord(ptr))
                 otmp = oname(otmp,
-                             artiname(rn2(2) ? ART_DEMONBANE : ART_SUNSWORD));
+                             artiname(rn2(2) ? ART_DEMONBANE : ART_SUNSWORD),
+                             ONAME_NO_FLAGS);
             bless(otmp);
             otmp->oerodeproof = TRUE;
             otmp->spe = rn2(4);
index 2980ded72f9086f964d16450a1bb1218e2479137..b602262216f8371f19b3a35040299053da294786 100644 (file)
@@ -352,7 +352,7 @@ copy_oextra(struct obj *obj2, struct obj *obj1)
     if (!obj2->oextra)
         obj2->oextra = newoextra();
     if (has_oname(obj1))
-        oname(obj2, ONAME(obj1));
+        oname(obj2, ONAME(obj1), ONAME_NO_FLAGS);
     if (has_omonst(obj1)) {
         if (!OMONST(obj2))
             newomonst(obj2);
@@ -1127,7 +1127,7 @@ mksobj(int otyp, boolean init, boolean artif)
         break;
     case SPE_NOVEL:
         otmp->novelidx = -1; /* "none of the above"; will be changed */
-        otmp = oname(otmp, noveltitle(&otmp->novelidx));
+        otmp = oname(otmp, noveltitle(&otmp->novelidx), ONAME_NO_FLAGS);
         break;
     }
 
@@ -2044,7 +2044,7 @@ mk_named_object(
 
     otmp = mkcorpstat(objtype, (struct monst *) 0, ptr, x, y, corpstatflags);
     if (nm)
-        otmp = oname(otmp, nm);
+        otmp = oname(otmp, nm, ONAME_NO_FLAGS);
     return otmp;
 }
 
@@ -2280,7 +2280,7 @@ discard_minvent(struct monst *mtmp, boolean uncreate_artifacts)
         /* this has now become very similar to m_useupall()... */
         extract_from_minvent(mtmp, otmp, TRUE, TRUE);
         if (uncreate_artifacts && otmp->oartifact)
-            artifact_exists(otmp, safe_oname(otmp), FALSE);
+            artifact_exists(otmp, safe_oname(otmp), FALSE, FALSE);
         obfree(otmp, (struct obj *) 0); /* dealloc_obj() isn't sufficient */
     }
 }
index 12d2a9b8e03eb52b9ea386db300c1e053a2893fb..99d669ba505228228e11034a8e495ccffdfd9459 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -678,7 +678,7 @@ make_corpse(struct monst *mtmp, unsigned int corpseflags)
         bypass_obj(obj);
 
     if (has_mgivenname(mtmp))
-        obj = oname(obj, MGIVENNAME(mtmp));
+        obj = oname(obj, MGIVENNAME(mtmp), ONAME_NO_FLAGS);
 
     /*  Avoid "It was hidden under a green mold corpse!"
      *  during Blind combat. An unseen monster referred to as "it"
@@ -1514,7 +1514,7 @@ mpickgold(register struct monst* mtmp)
 }
 
 boolean
-mpickstuff(register struct monst* mtmp, register const char* str)
+mpickstuff(struct monst *mtmp, const char *str)
 {
     register struct obj *otmp, *otmp2, *otmp3;
     int carryamt = 0;
@@ -1552,11 +1552,14 @@ mpickstuff(register struct monst* mtmp, register const char* str)
             if (carryamt != otmp->quan) {
                 otmp3 = splitobj(otmp, carryamt);
             }
-            if (cansee(mtmp->mx, mtmp->my) && flags.verbose)
-                pline("%s picks up %s.", Monnam(mtmp),
-                      (distu(mtmp->mx, mtmp->my) <= 5)
-                          ? doname(otmp3)
-                          : distant_name(otmp3, doname));
+            if (cansee(mtmp->mx, mtmp->my)) {
+                if (flags.verbose)
+                    /* see 'otmp3' "up close" if within a knight's jump */
+                    pline("%s picks up %s.", Monnam(mtmp),
+                          ((distu(mtmp->mx, mtmp->my) <= 5)
+                           ? doname(otmp3)
+                           : distant_name(otmp3, doname)));
+            }
             obj_extract_self(otmp3);      /* remove from floor */
             (void) mpickobj(mtmp, otmp3); /* may merge and free otmp3 */
             m_dowear(mtmp, FALSE);
@@ -2793,7 +2796,7 @@ monstone(struct monst* mdef)
             corpstatflags |= CORPSTAT_HISTORIC;
         otmp = mkcorpstat(STATUE, mdef, mdef->data, x, y, corpstatflags);
         if (has_mgivenname(mdef))
-            otmp = oname(otmp, MGIVENNAME(mdef));
+            otmp = oname(otmp, MGIVENNAME(mdef), ONAME_NO_FLAGS);
         while ((obj = oldminvent) != 0) {
             oldminvent = obj->nobj;
             obj->nobj = 0; /* avoid merged-> obfree-> dealloc_obj-> panic */
@@ -3038,7 +3041,7 @@ xkilled(
                 /* oc_big is also oc_bimanual and oc_bulky */
                 && (otmp->owt > 30 || objects[otyp].oc_big)) {
                 if (otmp->oartifact)
-                    artifact_exists(otmp, safe_oname(otmp), FALSE);
+                    artifact_exists(otmp, safe_oname(otmp), FALSE, FALSE);
                 delobj(otmp);
             } else if (!flooreffects(otmp, x, y, nomsg ? "" : "fall")) {
                 place_object(otmp, x, y);
index c7a6519376b577d675d0ce232aa589f3dfa17d3e..59ae1c197fb81f6bee1c7507e407e91cec60c79e 100644 (file)
@@ -4787,7 +4787,7 @@ readobjnam(char *bp, struct obj *no_wish)
                 d.name = novelname;
         }
 
-        d.otmp = oname(d.otmp, d.name);
+        d.otmp = oname(d.otmp, d.name, ONAME_NO_FLAGS);
         /* name==aname => wished for artifact (otmp->oartifact => got it) */
         if (d.otmp->oartifact || d.name == aname) {
             d.otmp->quan = 1L;
@@ -4799,7 +4799,7 @@ readobjnam(char *bp, struct obj *no_wish)
     /* and make them pay; charge them for the wish anyway! */
     if ((is_quest_artifact(d.otmp)
          || (d.otmp->oartifact && rn2(nartifact_exist()) > 1)) && !wizard) {
-        artifact_exists(d.otmp, safe_oname(d.otmp), FALSE);
+        artifact_exists(d.otmp, safe_oname(d.otmp), FALSE, FALSE);
         obfree(d.otmp, (struct obj *) 0);
         d.otmp = (struct obj *) &cg.zeroobj;
         pline("For a moment, you feel %s in your %s, but it disappears!",
index 397d4728394dee435c4910a07bd874b0e9d351fd..5b162a2d3ceb6443ac204ba6e3e0322385a0b934 100644 (file)
@@ -2609,7 +2609,7 @@ observe_quantum_cat(struct obj *box, boolean makecat, boolean givemsg)
                now rather than from when this special corpse got created */
             deadcat->age = g.moves;
             set_corpsenm(deadcat, PM_HOUSECAT);
-            deadcat = oname(deadcat, sc);
+            deadcat = oname(deadcat, sc, ONAME_NO_FLAGS);
         }
         if (givemsg)
             pline_The("%s inside the box is dead!",
index 85247bb0f1c147317f2eacc0d768d75152175097..65d45eaecba4ddc8f62474c0a81f3be074e6b310 100644 (file)
@@ -852,7 +852,7 @@ gcrownu(void)
             Strcpy(lbuf, simpleonames(obj)); /* before transformation */
             if (!Blind)
                 Your("sword shines brightly for a moment.");
-            obj = oname(obj, artiname(ART_EXCALIBUR));
+            obj = oname(obj, artiname(ART_EXCALIBUR), ONAME_FOUND_ARTI);
             if (obj && obj->oartifact == ART_EXCALIBUR) {
                 u.ugifts++;
                 livelog_printf(LL_DIVINEGIFT | LL_ARTIFACT,
@@ -870,10 +870,10 @@ gcrownu(void)
             ; /* already got bonus above */
         } else if (obj && in_hand) {
             Your("%s goes snicker-snack!", xname(obj));
-            obj->dknown = TRUE;
+            obj->dknown = 1;
         } else if (!already_exists) {
             obj = mksobj(LONG_SWORD, FALSE, FALSE);
-            obj = oname(obj, artiname(ART_VORPAL_BLADE));
+            obj = oname(obj, artiname(ART_VORPAL_BLADE), ONAME_FOUND_ARTI);
             obj->spe = 1;
             at_your_feet("A sword");
             dropy(obj);
@@ -894,10 +894,10 @@ gcrownu(void)
             ; /* already got bonus above */
         } else if (obj && in_hand) {
             Your("%s hums ominously!", swordbuf);
-            obj->dknown = TRUE;
+            obj->dknown = 1;
         } else if (!already_exists) {
             obj = mksobj(RUNESWORD, FALSE, FALSE);
-            obj = oname(obj, artiname(ART_STORMBRINGER));
+            obj = oname(obj, artiname(ART_STORMBRINGER), ONAME_FOUND_ARTI);
             obj->spe = 1;
             at_your_feet(An(swordbuf));
             dropy(obj);
index da5cc44a8dd2365645f8cbf40cfa0ba661fce4ca..b7dbfd9ccd2684a61d7b7982e6333a25ce221887 100644 (file)
@@ -2152,7 +2152,7 @@ create_object(object* o, struct mkroom* croom)
     /* set_corpsenm() took care of egg hatch and corpse timers */
 
     if (named) {
-        otmp = oname(otmp, o->name.str);
+        otmp = oname(otmp, o->name.str, ONAME_NO_FLAGS);
         if (otmp->otyp == SPE_NOVEL) {
             /* needs to be an existing title */
             (void) lookup_novel(o->name.str, &otmp->novelidx);
@@ -2215,7 +2215,7 @@ create_object(object* o, struct mkroom* croom)
             } else {
                 obj_extract_self(otmp);
                 if (otmp->oartifact)
-                    artifact_exists(otmp, safe_oname(otmp), FALSE);
+                    artifact_exists(otmp, safe_oname(otmp), FALSE, FALSE);
                 obfree(otmp, NULL);
                 return;
             }
index a9b3b3591af529dc9016134a017ac6c8cbb5b404..eccf3dae3da37469443a21aea7c50b71dc662a74 100644 (file)
@@ -492,7 +492,7 @@ steal(struct monst* mtmp, char* objnambuf)
 
 /* Returns 1 if otmp is free'd, 0 otherwise. */
 int
-mpickobj(register struct monst* mtmp, register struct obj* otmp)
+mpickobj(struct monst *mtmp, struct obj *otmp)
 {
     int freed_otmp;
     boolean snuff_otmp = FALSE;
@@ -706,7 +706,7 @@ mdrop_obj(
    even leaving the game entirely; when that happens, prevent them from
    taking the Amulet, invocation items, or quest artifact with them */
 void
-mdrop_special_objs(struct monstmon)
+mdrop_special_objs(struct monst *mon)
 {
     struct obj *obj, *otmp;
 
index f15aeb34989b78c56a9c62e9d760ae29eebe8874..3847317823f1ce929d8f0c42c371c3843b5e0d87 100644 (file)
@@ -1364,7 +1364,7 @@ tt_oname(struct obj* otmp)
         otmp->spe = CORPSTAT_FEMALE;
     else if (tt->plgend[0] == 'M')
         otmp->spe = CORPSTAT_MALE;
-    otmp = oname(otmp, tt->name);
+    otmp = oname(otmp, tt->name, ONAME_NO_FLAGS);
 
     return otmp;
 }