diff --git a/src/game/game.cpp b/src/game/game.cpp index 9b011fd9a..24b4342d0 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -4664,17 +4664,15 @@ void Game::unwrapItem(const std::shared_ptr &item, uint16_t unWrapId, cons return; } - auto hiddenCharges = item->getAttribute(ItemAttribute_t::DATE); const ItemType &newiType = Item::items.getItemType(unWrapId); if (player != nullptr && house != nullptr && newiType.isBed() && house->getMaxBeds() > -1 && house->getBedCount() >= house->getMaxBeds()) { player->sendCancelMessage("You reached the maximum beds in this house"); return; } - auto amount = item->getAttribute(ItemAttribute_t::AMOUNT); - if (!amount) { - amount = 1; - } + const uint16_t ownerAttr = item->getAttribute(ItemAttribute_t::OWNER); + const uint16_t amountAttr = item->getAttribute(ItemAttribute_t::AMOUNT); + const uint16_t amount = amountAttr ? amountAttr : 1; std::shared_ptr newItem = transformItem(item, unWrapId, amount); if (house && newiType.isBed()) { @@ -4682,14 +4680,17 @@ void Game::unwrapItem(const std::shared_ptr &item, uint16_t unWrapId, cons } if (newItem) { - if (hiddenCharges > 0 && isCaskItem(unWrapId)) { - newItem->setSubType(hiddenCharges); + if (isCaskItem(unWrapId)) { + const uint16_t hiddenCharges = item->getAttribute(ItemAttribute_t::DATE); + if (hiddenCharges > 0) { + newItem->setSubType(hiddenCharges); + } } newItem->removeCustomAttribute("unWrapId"); newItem->removeAttribute(ItemAttribute_t::DESCRIPTION); newItem->startDecaying(); - newItem->setAttribute(ItemAttribute_t::OWNER, item->getAttribute(ItemAttribute_t::OWNER)); + newItem->setAttribute(ItemAttribute_t::OWNER, ownerAttr); } }