Browse Source

Introduce Item::isUsable()

pull/5785/head
obligaron 3 years ago committed by Anders Jenbo
parent
commit
715e689ecb
  1. 6
      Source/inv.cpp
  2. 5
      Source/items.cpp
  3. 2
      Source/items.h
  4. 2
      Source/qol/stash.cpp

6
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)) {

5
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];

2
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;

2
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)) {

Loading…
Cancel
Save