diff options
author | Shauren <none@none> | 2010-09-28 18:50:38 +0200 |
---|---|---|
committer | Shauren <none@none> | 2010-09-28 18:50:38 +0200 |
commit | 956f9115dc7f19f5e802f26db992b5d46338d91f (patch) | |
tree | 001cd59420111166ec0fb5f9785d5ca50a6241ea | |
parent | b4b3eeee10190a523696349c47d24511f91213cf (diff) |
Core/Spells: Moved checking if item has USE: effect to Spell::CheckItems (from effect handler), also generates blizzlike error message now
--HG--
branch : trunk
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 23 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 18 |
2 files changed, 21 insertions, 20 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index d74da597ff8..094b3d1778e 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -6285,11 +6285,30 @@ SpellCastResult Spell::CheckItems() if (targetItem->GetProto()->ItemLevel < m_spellInfo->baseLevel) return SPELL_FAILED_LOWLEVEL; + + bool isItemUsable = false; + for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) + { + ItemPrototype const *proto = targetItem->GetProto(); + if (proto->Spells[i].SpellId && ( + proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE || + proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE)) + { + isItemUsable = true; + break; + } + } + + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(m_spellInfo->EffectMiscValue[i]); + // do not allow adding usable enchantments to items that have use effect already + if (pEnchant && isItemUsable) + for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s) + if (pEnchant->type[s] == ITEM_ENCHANTMENT_TYPE_USE_SPELL) + return SPELL_FAILED_ON_USE_ENCHANT; + // Not allow enchant in trade slot for some enchant type if (targetItem->GetOwner() != m_caster) { - uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) return SPELL_FAILED_ERROR; if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 6c9cbabb01d..548a3220c97 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -3424,24 +3424,6 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) if (!pEnchant) return; - // Prevent applying enchantments with Use: spell on items that already have an Use: effect, client-side check is not enough - for (int s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s) - { - if (pEnchant->type[s] == ITEM_ENCHANTMENT_TYPE_USE_SPELL) - { - for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) - { - ItemPrototype const *proto = itemTarget->GetProto(); - if (proto->Spells[i].SpellId && proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE) - { - sLog.outError("Exploiting attempt: Player %s(GUID: %u) tried to apply an enchanement with Use: spell on an item that already has a Use: effect," - " this should be blocked from client side.", p_caster->GetName(), p_caster->GetGUIDLow()); - return; - } - } - } - } - // item can be in trade slot and have owner diff. from caster Player* item_owner = itemTarget->GetOwner(); if (!item_owner) |