diff --git a/Source/inv.cpp b/Source/inv.cpp index 18ae9ba16..525d52408 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1058,7 +1058,7 @@ bool CanBePlacedOnBelt(const Item &item) return FitsInBeltSlot(item) && item._itype != ItemType::Gold && MyPlayer->CanUseItem(item) - && AllItemsList[item.IDidx].iUsable; + && item.isUsable(); } void FreeInvGFX() @@ -1210,7 +1210,7 @@ void DrawInvBelt(const Surface &out) DrawItem(myPlayer.SpdList[i], out, position, sprite); - if (AllItemsList[myPlayer.SpdList[i].IDidx].iUsable + if (myPlayer.SpdList[i].isUsable() && myPlayer.SpdList[i]._itype != ItemType::Gold) { DrawString(out, StrCat(i + 1), { position - Displacement { 0, 12 }, InventorySlotSizeInPixels }, UiFlags::ColorWhite | UiFlags::AlignRight); } @@ -2082,7 +2082,7 @@ bool UseInvItem(size_t pnum, int cii) } } - if (!AllItemsList[item->IDidx].iUsable) + if (!item->isUsable()) return false; if (!player.CanUseItem(*item)) { diff --git a/Source/items.cpp b/Source/items.cpp index 78ed35dc8..4a8f9fff5 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -4482,6 +4482,11 @@ std::string DebugSpawnUniqueItem(std::string itemName) } #endif +bool Item::isUsable() const +{ + return AllItemsList[IDidx].iUsable; +} + void Item::setNewAnimation(bool showAnimation) { int8_t it = ItemCAnimTbl[_iCurs]; diff --git a/Source/items.h b/Source/items.h index 6e5788298..f4ab54827 100644 --- a/Source/items.h +++ b/Source/items.h @@ -414,6 +414,8 @@ struct Item { } } + [[nodiscard]] bool isUsable() const; + [[nodiscard]] bool keyAttributesMatch(int32_t seed, _item_indexes itemIndex, uint16_t createInfo) const { return _iSeed == seed && IDidx == itemIndex && _iCreateInfo == createInfo; diff --git a/Source/qol/stash.cpp b/Source/qol/stash.cpp index a8f5fd993..ae72673c5 100644 --- a/Source/qol/stash.cpp +++ b/Source/qol/stash.cpp @@ -467,7 +467,7 @@ bool UseStashItem(uint16_t c) return true; } - if (!AllItemsList[item->IDidx].iUsable) + if (!item->isUsable()) return false; if (!MyPlayer->CanUseItem(*item)) {