Qt misuse of Role_if()

The Qt paper doll highlights known blessed/uncursed/cursed items with
a color border.  It was trying to force obj->bknown for non-blinded
priest[ess] but passed the old role letter argument to Role_if()
instead of the monster number that's used these days.  It was also
potentially modifying an invent item in a way that's observable to
the player but not updating persistent inventory to show that.

Probably didn't matter though; I don't think the situation it checks
for can occur anymore.  On the off chance that it could, move the
check-and-set out of #if ENHANCED_PAPERDOLL so that same inventory
update would occur for ordinary paper doll even though that doesn't
care about displayed items' bless/curse state.
This commit is contained in:
PatR
2021-12-27 14:27:35 -08:00
parent 8b30f3e1d1
commit 43317a2ef7
2 changed files with 8 additions and 3 deletions

View File

@@ -2331,7 +2331,7 @@ learn_unseen_invent(void)
return; /* sanity check */
for (otmp = g.invent; otmp; otmp = otmp->nobj) {
if (otmp->dknown)
if (otmp->dknown && (otmp->bknown || !Role_if(PM_CLERIC)))
continue; /* already seen */
/* set dknown, perhaps bknown (for priest[ess]) */
(void) xname(otmp);

View File

@@ -83,10 +83,15 @@ void NetHackQtInvUsageWindow::drawWorn(QPainter &painter, obj *nhobj,
if (nhobj) {
border = BORDER_DEFAULT;
// don't expect this to happen but check just in case;
// learn_unseen_invent() is normally called when regaining sight
// and sets dknown and maybe bknown, then updates perm_invent (do
// it regardless of ENHANCED_PAPERDOLL for same effect either way)
if (!Blind && (!nhobj->dknown
|| (Role_if(PM_CLERIC) && !nhobj->bknown)))
::learn_unseen_invent();
#ifdef ENHANCED_PAPERDOLL
// color margin around cell containing item whose BUC state is known
if (Role_if('P') && !Blind)
nhobj->bknown = 1;
if (nhobj->bknown)
border = nhobj->cursed ? BORDER_CURSED
: !nhobj->blessed ? BORDER_UNCURSED