Skip to content
Open
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
17 changes: 9 additions & 8 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4664,32 +4664,33 @@ void Game::unwrapItem(const std::shared_ptr<Item> &item, uint16_t unWrapId, cons
return;
}

auto hiddenCharges = item->getAttribute<uint16_t>(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<uint16_t>(ItemAttribute_t::AMOUNT);
if (!amount) {
amount = 1;
}
const uint16_t ownerAttr = item->getAttribute<uint16_t>(ItemAttribute_t::OWNER);
const uint16_t amountAttr = item->getAttribute<uint16_t>(ItemAttribute_t::AMOUNT);
const uint16_t amount = amountAttr ? amountAttr : 1;

std::shared_ptr<Item> newItem = transformItem(item, unWrapId, amount);
if (house && newiType.isBed()) {
house->addBed(newItem->getBed());
}

if (newItem) {
if (hiddenCharges > 0 && isCaskItem(unWrapId)) {
newItem->setSubType(hiddenCharges);
if (isCaskItem(unWrapId)) {
const uint16_t hiddenCharges = item->getAttribute<uint16_t>(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<uint16_t>(ItemAttribute_t::OWNER));
newItem->setAttribute(ItemAttribute_t::OWNER, ownerAttr);
}
}

Expand Down
Loading