From 5ddf90c5fe8e51a72697fea5b483b0138bf0d308 Mon Sep 17 00:00:00 2001 From: Shocker Date: Thu, 23 Jun 2011 23:43:49 +0300 Subject: Core/Spells: Don't allow players to cast client-side hidden spells directly --- src/server/game/Server/Protocol/Handlers/SpellHandler.cpp | 2 +- src/server/game/Spells/Spell.cpp | 6 +++++- src/server/game/Spells/Spell.h | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp b/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp index b127831bad5..6193b0c6213 100755 --- a/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp @@ -402,7 +402,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) spellInfo = actualSpellInfo; } - Spell* spell = new Spell(mover, spellInfo, false); + Spell* spell = new Spell(mover, spellInfo, false, 0, false, true); spell->m_cast_count = castCount; // set count of casts spell->prepare(&targets); } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index bf444f27e86..4357fb4bbc2 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -439,7 +439,7 @@ void SpellCastTargets::OutDebug() const sLog->outString("elevation: %f", m_elevation); } -Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, bool skipCheck): +Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, bool skipCheck, bool castedClientside): m_spellInfo(sSpellMgr->GetSpellForDifficultyFromSpell(info, Caster)), m_caster(Caster), m_spellValue(new SpellValue(m_spellInfo)) { @@ -502,6 +502,7 @@ m_caster(Caster), m_spellValue(new SpellValue(m_spellInfo)) m_spellState = SPELL_STATE_NULL; + m_castedClientside = castedClientside; m_IsTriggeredSpell = bool(triggered || (info->AttributesEx4 & SPELL_ATTR4_TRIGGERED)); m_CastItem = NULL; @@ -4651,6 +4652,9 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_spellInfo->AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL && !m_caster->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_ALLOW_CHEAT_SPELLS)) return SPELL_FAILED_SPELL_UNAVAILABLE; + if (m_castedClientside && m_spellInfo->Attributes & SPELL_ATTR0_HIDDEN_CLIENTSIDE && m_caster->GetTypeId() == TYPEID_PLAYER && !m_CastItem) + return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + // Check global cooldown if (strict && !m_IsTriggeredSpell && HasGlobalCooldown()) return SPELL_FAILED_NOT_READY; diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index ddb700aa8ab..9a5b98efaa4 100755 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -386,7 +386,7 @@ class Spell typedef std::set UsedSpellMods; - Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID = 0, bool skipCheck = false); + Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID = 0, bool skipCheck = false, bool castedClientside = false); ~Spell(); void prepare(SpellCastTargets const* targets, AuraEffect const* triggeredByAura = NULL); @@ -683,6 +683,7 @@ class Spell uint32 m_timer; bool m_IsTriggeredSpell; + bool m_castedClientside; // if need this can be replaced by Aura copy // we can't store original aura link to prevent access to deleted auras -- cgit v1.2.3