From ab599911064a16d4e4b2ab824a8540a18cdc3cab Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Mon, 20 Sep 2021 20:37:07 +0200 Subject: [PATCH] fix(Core/Spells): Properly remove item dependent passive auras on item unequip (#7944) --- .../game/Entities/Player/PlayerStorage.cpp | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/server/game/Entities/Player/PlayerStorage.cpp b/src/server/game/Entities/Player/PlayerStorage.cpp index 2948a14e2..d99786d66 100644 --- a/src/server/game/Entities/Player/PlayerStorage.cpp +++ b/src/server/game/Entities/Player/PlayerStorage.cpp @@ -2905,33 +2905,41 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update, bool swap) RemoveItemsSetItem(this, pProto); _ApplyItemMods(pItem, slot, false); - - // remove item dependent auras and casts (only weapon and armor slots) - if (slot < EQUIPMENT_SLOT_END) - { - // Xinef: Ensure that this function is called for places with swap=true - if (!swap) - RemoveItemDependentAurasAndCasts(pItem); - - // remove held enchantments, update expertise - if (slot == EQUIPMENT_SLOT_MAINHAND) - UpdateExpertise(BASE_ATTACK); - else if (slot == EQUIPMENT_SLOT_OFFHAND) - UpdateExpertise(OFF_ATTACK); - // update armor penetration - passive auras may need it - switch (slot) - { - case EQUIPMENT_SLOT_MAINHAND: - case EQUIPMENT_SLOT_OFFHAND: - case EQUIPMENT_SLOT_RANGED: - RecalculateRating(CR_ARMOR_PENETRATION); - default: - break; - } - } } m_items[slot] = nullptr; + + // remove item dependent auras and casts (only weapon and armor slots) + if (slot < INVENTORY_SLOT_BAG_END && slot < EQUIPMENT_SLOT_END) + { + // Xinef: Ensure that this function is called for places with swap=true + if (!swap) + { + RemoveItemDependentAurasAndCasts(pItem); + } + + // remove held enchantments, update expertise + if (slot == EQUIPMENT_SLOT_MAINHAND) + { + UpdateExpertise(BASE_ATTACK); + } + else if (slot == EQUIPMENT_SLOT_OFFHAND) + { + UpdateExpertise(OFF_ATTACK); + } + + // update armor penetration - passive auras may need it + switch (slot) + { + case EQUIPMENT_SLOT_MAINHAND: + case EQUIPMENT_SLOT_OFFHAND: + case EQUIPMENT_SLOT_RANGED: + RecalculateRating(CR_ARMOR_PENETRATION); + default: + break; + } + } + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty); if (slot < EQUIPMENT_SLOT_END)