fix(Core/Items): toggle temporary items enchantments during items swap. (#8067)
- Closes #7957
This commit is contained in:
@@ -3719,6 +3719,14 @@ void Player::SwapItem(uint16 src, uint16 dst)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove item enchantments for now and restore it later
|
||||||
|
// Needed for swap sanity checks
|
||||||
|
ApplyEnchantment(pSrcItem, false);
|
||||||
|
if (pDstItem)
|
||||||
|
{
|
||||||
|
ApplyEnchantment(pDstItem, false);
|
||||||
|
}
|
||||||
|
|
||||||
// impossible merge/fill, do real swap
|
// impossible merge/fill, do real swap
|
||||||
InventoryResult msg = EQUIP_ERR_OK;
|
InventoryResult msg = EQUIP_ERR_OK;
|
||||||
|
|
||||||
@@ -3738,6 +3746,13 @@ void Player::SwapItem(uint16 src, uint16 dst)
|
|||||||
|
|
||||||
if (msg != EQUIP_ERR_OK)
|
if (msg != EQUIP_ERR_OK)
|
||||||
{
|
{
|
||||||
|
// Restore enchantments
|
||||||
|
ApplyEnchantment(pSrcItem, true);
|
||||||
|
if (pDstItem)
|
||||||
|
{
|
||||||
|
ApplyEnchantment(pDstItem, true);
|
||||||
|
}
|
||||||
|
|
||||||
SendEquipError(msg, pSrcItem, pDstItem);
|
SendEquipError(msg, pSrcItem, pDstItem);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3758,10 +3773,24 @@ void Player::SwapItem(uint16 src, uint16 dst)
|
|||||||
|
|
||||||
if (msg != EQUIP_ERR_OK)
|
if (msg != EQUIP_ERR_OK)
|
||||||
{
|
{
|
||||||
|
// Restore enchantments
|
||||||
|
ApplyEnchantment(pSrcItem, true);
|
||||||
|
if (pDstItem)
|
||||||
|
{
|
||||||
|
ApplyEnchantment(pDstItem, true);
|
||||||
|
}
|
||||||
|
|
||||||
SendEquipError(msg, pDstItem, pSrcItem);
|
SendEquipError(msg, pDstItem, pSrcItem);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore enchantments
|
||||||
|
ApplyEnchantment(pSrcItem, true);
|
||||||
|
if (pDstItem)
|
||||||
|
{
|
||||||
|
ApplyEnchantment(pDstItem, true);
|
||||||
|
}
|
||||||
|
|
||||||
// Check bag swap with item exchange (one from empty in not bag possition (equipped (not possible in fact) or store)
|
// Check bag swap with item exchange (one from empty in not bag possition (equipped (not possible in fact) or store)
|
||||||
if (Bag* srcBag = pSrcItem->ToBag())
|
if (Bag* srcBag = pSrcItem->ToBag())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -172,19 +172,47 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
|||||||
if (!pSrcItem)
|
if (!pSrcItem)
|
||||||
return; // only at cheat
|
return; // only at cheat
|
||||||
|
|
||||||
uint16 dest;
|
ItemTemplate const* pProto = pSrcItem->GetTemplate();
|
||||||
InventoryResult msg = _player->CanEquipItem(NULL_SLOT, dest, pSrcItem, !pSrcItem->IsBag());
|
if (!pProto)
|
||||||
if (msg != EQUIP_ERR_OK)
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 eslot = _player->FindEquipSlot(pProto, NULL_SLOT, !pSrcItem->IsBag());
|
||||||
|
if (eslot == NULL_SLOT)
|
||||||
{
|
{
|
||||||
_player->SendEquipError(msg, pSrcItem, nullptr);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 src = pSrcItem->GetPos();
|
uint16 src = pSrcItem->GetPos();
|
||||||
|
uint16 dest = ((INVENTORY_SLOT_BAG_0 << 8) | eslot);
|
||||||
if (dest == src) // prevent equip in same slot, only at cheat
|
if (dest == src) // prevent equip in same slot, only at cheat
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Item* pDstItem = _player->GetItemByPos(dest);
|
Item* pDstItem = _player->GetItemByPos(dest);
|
||||||
|
|
||||||
|
// Remove item enchantments for now and restore it later
|
||||||
|
// Needed for swap sanity checks
|
||||||
|
if (pDstItem)
|
||||||
|
{
|
||||||
|
_player->ApplyEnchantment(pDstItem, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
InventoryResult msg = _player->CanEquipItem(NULL_SLOT, dest, pSrcItem, !pSrcItem->IsBag());
|
||||||
|
if (msg != EQUIP_ERR_OK)
|
||||||
|
{
|
||||||
|
// Restore enchantments
|
||||||
|
if (pDstItem)
|
||||||
|
{
|
||||||
|
_player->ApplyEnchantment(pDstItem, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
_player->SendEquipError(msg, pSrcItem, nullptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!pDstItem) // empty slot, simple case
|
if (!pDstItem) // empty slot, simple case
|
||||||
{
|
{
|
||||||
_player->RemoveItem(srcbag, srcslot, true);
|
_player->RemoveItem(srcbag, srcslot, true);
|
||||||
@@ -193,6 +221,9 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
|||||||
}
|
}
|
||||||
else // have currently equipped item, not simple case
|
else // have currently equipped item, not simple case
|
||||||
{
|
{
|
||||||
|
// Restore enchantments
|
||||||
|
_player->ApplyEnchantment(pDstItem, true);
|
||||||
|
|
||||||
uint8 dstbag = pDstItem->GetBagSlot();
|
uint8 dstbag = pDstItem->GetBagSlot();
|
||||||
uint8 dstslot = pDstItem->GetSlot();
|
uint8 dstslot = pDstItem->GetSlot();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user