Skip to content

Commit

Permalink
fix: loop related to decay items with duration (#2419)
Browse files Browse the repository at this point in the history
Fixes a loop related to decay item with duration

Resolves #1074
  • Loading branch information
dudantas authored Mar 12, 2024
1 parent b61cd9d commit c6895eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,15 @@ std::shared_ptr<Item> Game::transformItem(std::shared_ptr<Item> item, uint16_t n
uint16_t itemId = item->getID();
int32_t count = item->getSubType();

if (curType.id != newType.id) {
auto decaying = item->getDecaying();
// If the item is decaying, we need to transform it to the new item
if (decaying > DECAYING_FALSE && item->getDuration() <= 1) {
g_logger().debug("Decay duration old type {}, transformEquipTo {}, transformDeEquipTo {}", curType.decayTo, curType.transformEquipTo, curType.transformDeEquipTo);
g_logger().debug("Decay duration new type, decayTo {}, transformEquipTo {}, transformDeEquipTo {}", newType.decayTo, newType.transformEquipTo, newType.transformDeEquipTo);
if (newType.decayTo) {
itemId = newType.decayTo;
}
} else if (curType.id != newType.id) {
if (newType.group != curType.group) {
item->setDefaultSubtype();
}
Expand Down
11 changes: 6 additions & 5 deletions src/lua/creature/movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,17 +524,18 @@ uint32_t MoveEvent::EquipItem(const std::shared_ptr<MoveEvent> moveEvent, std::s
return 1;
}

const ItemType &it = Item::items[item->getID()];
if (it.transformEquipTo != 0) {
g_game().transformItem(item, it.transformEquipTo);
}

if (player->isItemAbilityEnabled(slot)) {
g_logger().debug("[{}] item ability is already enabled", __FUNCTION__);
return 1;
}

player->setItemAbility(slot, true);

const ItemType &it = Item::items[item->getID()];
if (it.transformEquipTo != 0) {
g_game().transformItem(item, it.transformEquipTo);
}

for (uint8_t slotid = 0; slotid < item->getImbuementSlot(); slotid++) {
player->updateImbuementTrackerStats();
ImbuementInfo imbuementInfo;
Expand Down

0 comments on commit c6895eb

Please sign in to comment.