From 4aa673c20ecc408c68b1909e7f322dc0ffd372c9 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 18 Apr 2019 15:41:54 -0700 Subject: [PATCH] fix #H8579 - mimics mimicking shop objects 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 | 3 ++- src/do_name.c | 6 ++++-- src/pager.c | 14 +++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index cb3862e5a..67d11f665 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -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 diff --git a/src/do_name.c b/src/do_name.c index b0d113fd8..4f6bdbebd 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -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[] = { diff --git a/src/pager.c b/src/pager.c index 872c1ac5a..8833a21bb 100644 --- a/src/pager.c +++ b/src/pager.c @@ -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 */ -- 2.40.0