diff options
| author | jackpoz <giacomopoz@gmail.com> | 2014-05-05 20:05:33 +0200 |
|---|---|---|
| committer | jackpoz <giacomopoz@gmail.com> | 2014-05-05 20:05:33 +0200 |
| commit | 2878b0d1051ed01f9ff024828ed409f0db25cdc7 (patch) | |
| tree | 2511ca4addd5abfa52ffcf82a6a169fb25986a19 /src/server/game/Spells/Spell.cpp | |
| parent | 3ac4e3033cb0f8b33554dcfbd29a2cf5d94a19bf (diff) | |
Core/Misc: Fix enchants broken in 3aca9e64b34baee781f402c3f33ad7ee7991c232
Compare cast item entry instead of checking cast item spells to fix the exploit mentioned in 3aca9e64b34baee781f402c3f33ad7ee7991c232 without breaking any functionality.
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 2dc501d896f..7c6f2552b44 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -571,6 +571,7 @@ m_caster((info->AttributesEx6 & SPELL_ATTR6_CAST_BY_CHARMER && caster->GetCharme m_CastItem = NULL; m_castItemGUID = 0; + m_castItemEntry = 0; unitTarget = NULL; itemTarget = NULL; @@ -2806,9 +2807,15 @@ bool Spell::UpdateChanneledTargetList() void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggeredByAura) { if (m_CastItem) + { m_castItemGUID = m_CastItem->GetGUID(); + m_castItemEntry = m_CastItem->GetEntry(); + } else + { m_castItemGUID = 0; + m_castItemEntry = 0; + } InitExplicitTargets(*targets); @@ -4264,6 +4271,7 @@ void Spell::TakeCastItem() m_CastItem = NULL; m_castItemGUID = 0; + m_castItemEntry = 0; } } @@ -4509,6 +4517,7 @@ void Spell::TakeReagents() m_CastItem = NULL; m_castItemGUID = 0; + m_castItemEntry = 0; } // if GetItemTarget is also spell reagent @@ -6336,43 +6345,8 @@ bool Spell::UpdatePointers() if (!m_CastItem) return false; - // check if the retrieved item can even cast the spell - ItemTemplate const* proto = m_CastItem->GetTemplate(); - bool spellFound = false; - for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) - { - if (uint32(proto->Spells[i].SpellId) == GetSpellInfo()->Id) - { - spellFound = true; - break; - } - } - - // check enchantment if the spell wasn't found in item proto - if (!spellFound) - { - for (uint8 e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot) - { - uint32 enchant_id = m_CastItem->GetEnchantmentId(EnchantmentSlot(e_slot)); - SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if (!pEnchant) - continue; - - for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s) - { - if (pEnchant->spellid[s] == GetSpellInfo()->Id) - { - spellFound = true; - break; - } - } - - if (spellFound) - break; - } - } - - if (!spellFound) + // check if the item is really the same, in case it has been wrapped for example + if (m_castItemEntry != m_CastItem->GetEntry()) return false; } |
