]> granicus.if.org Git - nethack/commitdiff
paper doll inventory display vs hallucination
authorPatR <rankin@nethack.org>
Mon, 17 Aug 2020 21:48:00 +0000 (14:48 -0700)
committerPatR <rankin@nethack.org>
Mon, 17 Aug 2020 21:48:00 +0000 (14:48 -0700)
During hallucination, actions which triggered update of persistent
inventory made Qt's display of map tiles for equipped objects have
those tiles switch randomly, but ordinary move-by-move fluctations
applied to floor objects left them alone.

Initially I took out hallucination of inventory items altogether,
but ended up putting that back and changing the floor hallucination
to affect Qt's paper doll too.  The display.h change isn't needed
but I've left it in.

doc/fixes37.0
include/display.h
src/display.c
win/Qt/qt_inv.cpp

index 123402de33fbb843690eed50e57e947dfbd5dd07..76f29dfe18e3a9af2bb4921120fdd56658243d83 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.285 $ $NHDT-Date: 1597546107 2020/08/16 02:48:27 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.286 $ $NHDT-Date: 1597700875 2020/08/17 21:47:55 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -381,6 +381,7 @@ Qt: "paper doll" subset of persistent inventory has undergone several changes:
        two-handed weapon in both the shield and primary weapon slots; show
        first active light source in a previously unused slot on lower right;
        show first leash-in-use in a previously unused slot on lower left
+Qt: paper doll inventory view was inconsistently updated during Hallucination
 Qt+QSX: fix control key
 Qt+OSX: rename menu entry "nethack->Preferences..." for invoking nethack's
        'O' command to "Game->Run-time options" and entry "Game->Qt settings"
index 272ed163d98655d02ee3d1ae36f2cb3c98a77583..721b7f10bedbc03e1957299d02c7a1b584a08fe9 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 display.h       $NHDT-Date: 1596498533 2020/08/03 23:48:53 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.46 $ */
+/* NetHack 3.7 display.h       $NHDT-Date: 1597700875 2020/08/17 21:47:55 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.47 $ */
 /* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
 /* and Dave Cohrs, 1990.                                          */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -328,18 +328,18 @@ enum explosion_types {
 
 /* This has the unfortunate side effect of needing a global variable    */
 /* to store a result. 'otg_temp' is defined and declared in decl.{ch}.  */
-#define random_obj_to_glyph(rng)                \
-    ((g.otg_temp = random_object(rng)) == CORPSE  \
-         ? random_monster(rng) + GLYPH_BODY_OFF \
+#define random_obj_to_glyph(rng) \
+    ((g.otg_temp = random_object(rng)) == CORPSE                \
+         ? random_monster(rng) + GLYPH_BODY_OFF                 \
          : g.otg_temp + GLYPH_OBJ_OFF)
 
-#define obj_to_glyph(obj, rng)                                          \
-    (((obj)->otyp == STATUE)                                            \
-         ? statue_to_glyph(obj, rng)                                    \
-         : Hallucination                                                \
-               ? random_obj_to_glyph(rng)                               \
-               : ((obj)->otyp == CORPSE)                                \
-                     ? (int) (obj)->corpsenm + GLYPH_BODY_OFF           \
+#define obj_to_glyph(obj, rng) \
+    (((obj)->otyp == STATUE)                                    \
+         ? statue_to_glyph(obj, rng)                            \
+         : Hallucination                                        \
+               ? random_obj_to_glyph(rng)                       \
+               : ((obj)->otyp == CORPSE)                        \
+                     ? (int) (obj)->corpsenm + GLYPH_BODY_OFF   \
                      : (int) (obj)->otyp + GLYPH_OBJ_OFF)
 
 /* MRKR: Statues now have glyphs corresponding to the monster they    */
@@ -349,6 +349,16 @@ enum explosion_types {
     (Hallucination ? random_monster(rng) + GLYPH_MON_OFF       \
                    : (int) (obj)->corpsenm + GLYPH_STATUE_OFF)
 
+/* briefly used for Qt's "paper doll" inventory which shows map tiles for
+   equipped objects; those vary like floor items during hallucination now
+   so this isn't used anywhere */
+#define obj_to_true_glyph(obj) \
+    (((obj)->otyp == STATUE)                            \
+     ? ((int) (obj)->corpsenm + GLYPH_STATUE_OFF)       \
+       : ((obj)->otyp == CORPSE)                        \
+         ? ((int) (obj)->corpsenm + GLYPH_BODY_OFF)     \
+           : ((int) (obj)->otyp + GLYPH_OBJ_OFF))
+
 #define cmap_to_glyph(cmap_idx) ((int) (cmap_idx) + GLYPH_CMAP_OFF)
 #define explosion_to_glyph(expltype, idx) \
     ((((expltype) * MAXEXPCHARS) + ((idx) - S_explode1)) + GLYPH_EXPLODE_OFF)
index 7445486dd422bb977d3fa750a0f0089f7c715224..0efe1582c9c33cfe9a463bcf081fe46e2480965d 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 display.c       $NHDT-Date: 1596498156 2020/08/03 23:42:36 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.135 $ */
+/* NetHack 3.7 display.c       $NHDT-Date: 1597700875 2020/08/17 21:47:55 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.136 $ */
 /* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
 /* and Dave Cohrs, 1990.                                          */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1339,9 +1339,16 @@ void
 see_objects()
 {
     register struct obj *obj;
+
     for (obj = fobj; obj; obj = obj->nobj)
         if (vobj_at(obj->ox, obj->oy) == obj)
             newsym(obj->ox, obj->oy);
+
+    /* Qt's "paper doll" subset of persistent inventory shows map tiles
+       for objects which aren't on the floor so not handled by above loop;
+       inventory which includes glyphs should also be affected, so do this
+       for all interfaces in case any feature that for persistent inventory */
+    update_inventory();
 }
 
 /*
index 758fcb7b6b9ad38f27ce0b63b8c8dd7786a05c38..f34d0e48aa6342cf097763a5da942daba4de0f09 100644 (file)
@@ -48,13 +48,12 @@ void NetHackQtInvUsageWindow::drawWorn(QPainter& painter, obj* nhobj,
                                        int x, int y, bool canbe)
 {
     short int glyph;
-    if (nhobj)
-       glyph = obj_to_glyph(nhobj, rn2_on_display_rng);
-    else if (canbe)
-       glyph = cmap_to_glyph(S_room);
-    else
-       glyph = GLYPH_UNEXPLORED; // was cmap_to_glyph(S_stone)
-
+    if (nhobj) {
+        /* Hallucination doesn't affect inventory */
+        glyph = obj_to_glyph(nhobj, rn2_on_display_rng);
+    } else {
+        glyph = canbe ? cmap_to_glyph(S_room) : GLYPH_UNEXPLORED;
+    }
     qt_settings->glyphs().drawCell(painter, glyph, x, y);
 }