aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2014-05-04 13:41:07 +0200
committerjackpoz <giacomopoz@gmail.com>2014-05-04 13:41:07 +0200
commit3aca9e64b34baee781f402c3f33ad7ee7991c232 (patch)
treec73cf1663fb74e70fb058788dbed509674250180 /src
parent49018c4bdbcec5e64413b908ba998bacc2ff708a (diff)
Core/Misc: Fix exploit
Fix exploit that allowed to learn spells from recipes without consuming them.
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Spells/Spell.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 3a947b1b07f..3282ce880f9 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -6335,6 +6335,45 @@ bool Spell::UpdatePointers()
// cast item not found, somehow the item is no longer where we expected
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 (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)
+ return false;
}
m_targets.Update(m_caster);