]> granicus.if.org Git - nethack/commitdiff
fix #H4038 - distant name vs Eyes of the Overworld
authorPatR <rankin@nethack.org>
Thu, 10 Dec 2015 09:34:09 +0000 (01:34 -0800)
committerPatR <rankin@nethack.org>
Thu, 10 Dec 2015 09:34:09 +0000 (01:34 -0800)
distant_name() temporarily blinded the hero before calling xname() or
doname() in order to prevent the object being formatted from having
its dknown flag set.  The Eyes of the Overworld override blindness, so
that bit got set for heros wearing them regardless of intention.  This
switches to a file-scope global instead of blindness as the way that
distant_name() tells xname() not to set dknown.

This bug has been present ever since the Eyes were added (3.3.0?).

doc/fixes36.1
src/objnam.c

index e84ba28173f618721ffb2dba8aac411df8212456..aad10e4c3a93ec0c4dc619740512f022675025b6 100644 (file)
@@ -7,6 +7,8 @@ data.base entry for "lava" had wrong first name for Don Woods' attribution
 cursed genocide of "none" sent in monsters, but "that's enough tries" didn't
 update MAXPLAYERS documentation in sysconf file and allow 0 for it
 wizard mode: don't include feedback about named fruit for ^X and enlightenment
+looking at distant objects while wearing the Eyes of the Overworld made their
+       up-close descriptions known when not intended
 
 
 Platform- and/or Interface-Specific Fixes
index 18d78fee141b5de49dfc366543c25c88e6c0585a..bf68842e74d660d0e59455791f1e16df392269bd 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 objnam.c        $NHDT-Date: 1447490776 2015/11/14 08:46:16 $  $NHDT-Branch: master $:$NHDT-Revision: 1.154 $ */
+/* NetHack 3.6 objnam.c        $NHDT-Date: 1449740045 2015/12/10 09:34:05 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.155 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -197,12 +197,13 @@ struct obj *obj;
     return TRUE;
 }
 
+/* used by distant_name() to pass extra information to xname_flags();
+   it would be much cleaner if this were a parameter, but that would
+   require all of the xname() and doname() calls to be modified */
+static int distantname = 0;
+
 /* Give the name of an object seen at a distance.  Unlike xname/doname,
- * we don't want to set dknown if it's not set already.  The kludge used is
- * to temporarily set Blind so that xname() skips the dknown setting.  This
- * assumes that we don't want to do this too often; if this function becomes
- * frequently used, it'd probably be better to pass a parameter to xname()
- * or doname() instead.
+ * we don't want to set dknown if it's not set already.
  */
 char *
 distant_name(obj, func)
@@ -211,10 +212,17 @@ char *FDECL((*func), (OBJ_P));
 {
     char *str;
 
-    long save_Blinded = Blinded;
-    Blinded = 1;
+    /* 3.6.1: this used to save Blind, set it, make the call, then restore
+     * the saved value; but the Eyes of the Overworld override blindness
+     * and let characters wearing them get dknown set for distant items.
+     *
+     * TODO? if the hero is wearing those Eyes, figure out whether the
+     * object is within X-ray radius and only treat it as distant when
+     * beyond that radius.  Logic is iffy but result might be interesting.
+     */
+    ++distantname;
     str = (*func)(obj);
-    Blinded = save_Blinded;
+    --distantname;
     return str;
 }
 
@@ -271,7 +279,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
      */
     if (!nn && ocl->oc_uses_known && ocl->oc_unique)
         obj->known = 0;
-    if (!Blind)
+    if (!Blind && !distantname)
         obj->dknown = TRUE;
     if (Role_if(PM_PRIEST))
         obj->bknown = TRUE;