Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: imbuement check for empty slots #3370

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading