aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2014-05-05 20:05:33 +0200
committerjackpoz <giacomopoz@gmail.com>2014-05-05 20:05:33 +0200
commit2878b0d1051ed01f9ff024828ed409f0db25cdc7 (patch)
tree2511ca4addd5abfa52ffcf82a6a169fb25986a19 /src
parent3ac4e3033cb0f8b33554dcfbd29a2cf5d94a19bf (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')
-rw-r--r--src/server/game/Spells/Spell.cpp48
-rw-r--r--src/server/game/Spells/Spell.h1
-rw-r--r--src/server/game/Spells/SpellEffects.cpp3
3 files changed, 15 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;
}
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 9c6353da486..341867ff787 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -451,6 +451,7 @@ class Spell
SpellInfo const* const m_spellInfo;
Item* m_CastItem;
uint64 m_castItemGUID;
+ uint32 m_castItemEntry;
uint8 m_cast_count;
uint32 m_glyphIndex;
uint32 m_preCastSpell;
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 31e0006d9f3..65530b4b282 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -2097,6 +2097,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
m_CastItem = NULL;
m_castItemGUID = 0;
+ m_castItemEntry = 0;
player->StoreItem(dest, pNewItem, true);
return;
@@ -2116,6 +2117,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
m_CastItem = NULL;
m_castItemGUID = 0;
+ m_castItemEntry = 0;
player->BankItem(dest, pNewItem, true);
return;
@@ -2139,6 +2141,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
m_CastItem = NULL;
m_castItemGUID = 0;
+ m_castItemEntry = 0;
player->EquipItem(dest, pNewItem, true);
player->AutoUnequipOffhandIfNeed();