Skip to content

Commit

Permalink
fix: update supply for equipped ring and amulets
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Dec 18, 2024
1 parent 34b6fa8 commit b76bdb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ CombatDamage Combat::getCombatDamage(const std::shared_ptr<Creature> &creature,
damage.secondary.value = weapon->getElementDamage(player, target, tool);
if (params.useCharges) {
auto charges = tool->getAttribute<uint16_t>(ItemAttribute_t::CHARGES);
if (charges != 0) {
if (charges == 0) {
player->updateSupplyTracker(tool);
} else {
g_game().transformItem(tool, tool->getID(), charges - 1);
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/items/decay/decay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ void Decay::internalDecayItem(const std::shared_ptr<Item> &item) {

const ItemType &it = Item::items[item->getID()];
// Remove the item and halt the decay process if a player triggers a bug where the item's decay ID matches its equip or de-equip transformation ID
const auto &player = item->getHoldingPlayer();
if (it.id == it.transformEquipTo || it.id == it.transformDeEquipTo) {
g_game().internalRemoveItem(item);
const auto &player = item->getHoldingPlayer();
if (player) {
g_logger().error("[{}] - internalDecayItem failed to player {}, item id is same from transform equip/deequip, "
" item id: {}, equip to id: '{}', deequip to id '{}'",
Expand All @@ -173,7 +173,6 @@ void Decay::internalDecayItem(const std::shared_ptr<Item> &item) {
}

if (it.decayTo != 0) {
const auto &player = item->getHoldingPlayer();
if (player) {
bool needUpdateSkills = false;
for (int32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i) {
Expand Down Expand Up @@ -214,6 +213,13 @@ void Decay::internalDecayItem(const std::shared_ptr<Item> &item) {
return;
}

if (player) {
auto slotPosition = item->getSlotPosition();
if ((slotPosition & SLOTP_NECKLACE) || (slotPosition & SLOTP_RING)) {
player->updateSupplyTracker(item);
}
}

ReturnValue ret = g_game().internalRemoveItem(item);
if (ret != RETURNVALUE_NOERROR) {
g_logger().error("[Decay::internalDecayItem] - internalDecayItem failed, "
Expand Down

0 comments on commit b76bdb9

Please sign in to comment.