diff --git a/Source/control.cpp b/Source/control.cpp index c9ff552e3..4a4e3c38a 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -832,7 +832,7 @@ void DrawInfoBox(const Surface &out) if (myPlayer.HoldItem._itype == ItemType::Gold) { int nGold = myPlayer.HoldItem._ivalue; strcpy(infostr, fmt::format(ngettext("{:d} gold piece", "{:d} gold pieces", nGold), nGold).c_str()); - } else if (!myPlayer.HoldItem._iStatFlag) { + } else if (!myPlayer.CanUseItem(myPlayer.HoldItem)) { ClearPanel(); AddPanelString(_("Requirements not met")); } else { diff --git a/Source/inv.cpp b/Source/inv.cpp index eadca029d..283aee125 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -412,7 +412,7 @@ void CheckInvPaste(int pnum, Point cursorPosition) done = true; if (!AllItemsList[player.HoldItem.IDidx].iUsable) done = false; - if (!player.HoldItem._iStatFlag) + if (!player.CanUseItem(player.HoldItem)) done = false; if (player.HoldItem._itype == ItemType::Gold) done = false; @@ -464,7 +464,7 @@ void CheckInvPaste(int pnum, Point cursorPosition) if (!done) return; - if (IsNoneOf(il, ILOC_UNEQUIPABLE, ILOC_BELT) && !player.HoldItem._iStatFlag) { + if (IsNoneOf(il, ILOC_UNEQUIPABLE, ILOC_BELT) && !player.CanUseItem(player.HoldItem)) { done = false; player.Say(HeroSpeech::ICantUseThisYet); } @@ -1614,13 +1614,7 @@ void CheckItemStats(Player &player) { Item &item = player.HoldItem; - item._iStatFlag = false; - - if (player._pStrength >= item._iMinStr - && player._pMagic >= item._iMinMag - && player._pDexterity >= item._iMinDex) { - item._iStatFlag = true; - } + item._iStatFlag = player.CanUseItem(item); } void InvGetItem(int pnum, int ii) @@ -2118,7 +2112,7 @@ bool UseInvItem(int pnum, int cii) if (!AllItemsList[item->IDidx].iUsable) return false; - if (!item->_iStatFlag) { + if (!player.CanUseItem(*item)) { player.Say(HeroSpeech::ICantUseThisYet); return true; }