fix(Core/Spells): Properly remove item dependent passive auras on item unequip (#7944)

This commit is contained in:
UltraNix
2021-09-20 20:37:07 +02:00
committed by GitHub
parent f130099170
commit ab59991106
@@ -2905,19 +2905,29 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update, bool swap)
RemoveItemsSetItem(this, pProto); RemoveItemsSetItem(this, pProto);
_ApplyItemMods(pItem, slot, false); _ApplyItemMods(pItem, slot, false);
}
m_items[slot] = nullptr;
// remove item dependent auras and casts (only weapon and armor slots) // remove item dependent auras and casts (only weapon and armor slots)
if (slot < EQUIPMENT_SLOT_END) if (slot < INVENTORY_SLOT_BAG_END && slot < EQUIPMENT_SLOT_END)
{ {
// Xinef: Ensure that this function is called for places with swap=true // Xinef: Ensure that this function is called for places with swap=true
if (!swap) if (!swap)
{
RemoveItemDependentAurasAndCasts(pItem); RemoveItemDependentAurasAndCasts(pItem);
}
// remove held enchantments, update expertise // remove held enchantments, update expertise
if (slot == EQUIPMENT_SLOT_MAINHAND) if (slot == EQUIPMENT_SLOT_MAINHAND)
{
UpdateExpertise(BASE_ATTACK); UpdateExpertise(BASE_ATTACK);
}
else if (slot == EQUIPMENT_SLOT_OFFHAND) else if (slot == EQUIPMENT_SLOT_OFFHAND)
{
UpdateExpertise(OFF_ATTACK); UpdateExpertise(OFF_ATTACK);
}
// update armor penetration - passive auras may need it // update armor penetration - passive auras may need it
switch (slot) switch (slot)
{ {
@@ -2929,9 +2939,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update, bool swap)
break; break;
} }
} }
}
m_items[slot] = nullptr;
SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty); SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty);
if (slot < EQUIPMENT_SLOT_END) if (slot < EQUIPMENT_SLOT_END)