From 43317a2ef789cbf23170b413d538e1439e303f2e Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 27 Dec 2021 14:27:35 -0800 Subject: [PATCH] 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. --- src/invent.c | 2 +- win/Qt/qt_inv.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/invent.c b/src/invent.c index eab574ee6..f6bb20454 100644 --- a/src/invent.c +++ b/src/invent.c @@ -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); diff --git a/win/Qt/qt_inv.cpp b/win/Qt/qt_inv.cpp index ca9eda461..50f17f47c 100644 --- a/win/Qt/qt_inv.cpp +++ b/win/Qt/qt_inv.cpp @@ -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