Skip to content

Commit

Permalink
fix: remove imbuement check for empty slots
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Feb 15, 2025
1 parent ab32754 commit a43c3f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/items/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,18 @@ std::shared_ptr<Item> Item::CreateItem(const uint16_t type, uint16_t count /*= 0
return newItem;
}

bool Item::hasImbuementAttribute(const std::string &attributeSlot) const {
// attributeSlot = ITEM_IMBUEMENT_SLOT + slot id
return getCustomAttribute(attributeSlot) != nullptr;
}

bool Item::getImbuementInfo(uint8_t slot, ImbuementInfo* imbuementInfo) const {
const CustomAttribute* attribute = getCustomAttribute(std::to_string(ITEM_IMBUEMENT_SLOT + slot));
std::string attributeSlot = std::to_string(ITEM_IMBUEMENT_SLOT + slot);
if (!hasImbuementAttribute(attributeSlot)) {
return false;
}

const CustomAttribute* attribute = getCustomAttribute(attributeSlot);
const auto info = attribute ? attribute->getAttribute<uint32_t>() : 0;
imbuementInfo->imbuement = g_imbuements().getImbuement(info & 0xFF);
imbuementInfo->duration = info >> 8;
Expand Down
1 change: 1 addition & 0 deletions src/items/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ class Item : virtual public Thing, public ItemProperties, public SharedObject {
return false;
}
bool hasImbuementCategoryId(uint16_t categoryId) const;
bool hasImbuementAttribute(const std::string &attributeSlot) const;
bool hasImbuements() const {
for (uint8_t slotid = 0; slotid < getImbuementSlot(); slotid++) {
ImbuementInfo imbuementInfo;
Expand Down

0 comments on commit a43c3f8

Please sign in to comment.