paper doll inventory display vs hallucination

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.
This commit is contained in:
PatR
2020-08-17 14:48:00 -07:00
parent 9a866d3601
commit 3a07880684
4 changed files with 37 additions and 20 deletions

View 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"

View 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)

View 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();
}
/*

View 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);
}