Core/Misc: Fix enchants broken in 3aca9e64b3

Compare cast item entry instead of checking cast item spells to fix the exploit mentioned in 3aca9e64b3 without breaking any functionality.
This commit is contained in:
jackpoz committed 2014-05-05 20:05:33 +02:00
1 parent 3ac4e3033c
commit 2878b0d105
3 files changed
+15 -37

No files matched your search

+11 -37
View File
@@ -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;
}
+1
View File
@@ -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;
+3
View File
@@ -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();