]> granicus.if.org Git - nethack/commitdiff
fix #H8579 - mimics mimicking shop objects
authorPatR <rankin@nethack.org>
Thu, 18 Apr 2019 22:41:54 +0000 (15:41 -0700)
committerPatR <rankin@nethack.org>
Thu, 18 Apr 2019 22:41:54 +0000 (15:41 -0700)
Showing the price of a shop object when examining it with '/' or ';'
didn't include a price if it was actually a mimic.  This makes fake
objects have prices when appropriate, but it is only a partial fix
because moving away from a mimic causes nethack to forget the fake
object's dknown flag for most types of objects.

That could be solved by adding an mobj field to mon->mextra, which
will break save compatibility, or by adding a whole extra set of
object glyphs for object-with-dknown-set.  The latter could probably
be done without breaking backwards save compatibility (new program
using old files) but it seems like more effort that it'd be worth and
it would break forwards save compatibility (old program attempting to
use new files--something we've never claimed to support).

doc/fixes36.2
src/do_name.c
src/pager.c

index cb3862e5a44383cbe17ba55adce583f234537617..67d11f66505d65910e316a4611aabf9b44f613fd 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.304 $ $NHDT-Date: 1555552900 2019/04/18 02:01:40 $
+$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.305 $ $NHDT-Date: 1555627306 2019/04/18 22:41:46 $
 
 This fixes36.2 file is here to capture information about updates in the 3.6.x
 lineage following the release of 3.6.1 in April 2018. Please note, however,
@@ -484,6 +484,7 @@ using 'O' to set status hilites for any status condition (Blind, &c) and
        retain one of the chosen attributes
 when u.uhp==-1 became a flag to suppress status updating, if game ended when
        hero died with exactly -1 HP, status would be blank during disclosure
+mimic mimicking a shop item didn't show any shop price for whatis and glance
 tty: turn off an optimization that is the suspected cause of Windows reported
        partial status lines following level changes
 tty: ensure that current status fields are always copied to prior status
index b0d113fd85417fe2e48d94d59e177d872b6de400..4f6bdbebd865a1be76e9e4f1e82a45ed0e5cb2f6 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 do_name.c       $NHDT-Date: 1549321230 2019/02/04 23:00:30 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.143 $ */
+/* NetHack 3.6 do_name.c       $NHDT-Date: 1555627306 2019/04/18 22:41:46 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.145 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Pasi Kallinen, 2018. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1564,8 +1564,10 @@ namefloorobj()
     } else {
         docall(obj);
     }
-    if (fakeobj)
+    if (fakeobj) {
+        obj->where = OBJ_FREE; /* object_from_map() sets it to OBJ_FLOOR */
         dealloc_obj(obj);
+    }
 }
 
 static const char *const ghostnames[] = {
index 872c1ac5a96a5ebc752e6a1f337a654432a9a99a..8833a21bbd42c134f94ac3a80732c3fc08771f62 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 pager.c $NHDT-Date: 1549334449 2019/02/05 02:40:49 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.150 $ */
+/* NetHack 3.6 pager.c $NHDT-Date: 1555627307 2019/04/18 22:41:47 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.151 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2018. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -123,8 +123,10 @@ char *outbuf;
             Strcat(outbuf, (otmp && otmp->otyp != STRANGE_OBJECT)
                               ? ansimpleoname(otmp)
                               : an(obj_descr[STRANGE_OBJECT].oc_name));
-            if (fakeobj)
+            if (fakeobj) {
+                otmp->where = OBJ_FREE; /* object_from_map set to OBJ_FLOOR */
                 dealloc_obj(otmp);
+            }
         } else {
             Strcat(outbuf, something);
         }
@@ -195,6 +197,10 @@ struct obj **obj_p;
             otmp->corpsenm = glyph - GLYPH_STATUE_OFF;
         if (otmp->otyp == LEASH)
             otmp->leashmon = 0;
+        /* extra fields needed for shop price with doname() formatting */
+        otmp->where = OBJ_FLOOR;
+        otmp->ox = x, otmp->oy = y;
+        otmp->no_charge = (otmp->otyp == STRANGE_OBJECT && costly_spot(x, y));
     }
     /* if located at adjacent spot, mark it as having been seen up close
        (corpse type will be known even if dknown is 0, so we don't need a
@@ -226,8 +232,10 @@ int x, y, glyph;
                      ? distant_name(otmp, otmp->dknown ? doname_with_price
                                                        : doname_vague_quan)
                      : obj_descr[STRANGE_OBJECT].oc_name);
-        if (fakeobj)
+        if (fakeobj) {
+            otmp->where = OBJ_FREE; /* object_from_map set it to OBJ_FLOOR */
             dealloc_obj(otmp), otmp = 0;
+        }
     } else
         Strcpy(buf, something); /* sanity precaution */