fix(Core/Items): toggle temporary items enchantments during items swap. (#8067)

- Closes #7957
This commit is contained in:
UltraNix
2021-10-04 15:44:49 +02:00
committed by GitHub
parent 3f947392fe
commit de8d0b49f8
2 changed files with 65 additions and 5 deletions

View File

@@ -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
InventoryResult msg = EQUIP_ERR_OK;
@@ -3738,6 +3746,13 @@ void Player::SwapItem(uint16 src, uint16 dst)
if (msg != EQUIP_ERR_OK)
{
// Restore enchantments
ApplyEnchantment(pSrcItem, true);
if (pDstItem)
{
ApplyEnchantment(pDstItem, true);
}
SendEquipError(msg, pSrcItem, pDstItem);
return;
}
@@ -3758,10 +3773,24 @@ void Player::SwapItem(uint16 src, uint16 dst)
if (msg != EQUIP_ERR_OK)
{
// Restore enchantments
ApplyEnchantment(pSrcItem, true);
if (pDstItem)
{
ApplyEnchantment(pDstItem, true);
}
SendEquipError(msg, pDstItem, pSrcItem);
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)
if (Bag* srcBag = pSrcItem->ToBag())
{