diff options
author | megamage <none@none> | 2009-04-03 16:42:19 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-04-03 16:42:19 -0600 |
commit | b922da4db1b1e2d535be3eb023f6ed143904967c (patch) | |
tree | 5e8f81147e607c4c94a3c3fda1df4824320385bb /src | |
parent | 3d1200f4ac8adc439d5580cb9fdea6f827d4e9d9 (diff) |
[7611] Prevent casting owner spell/use item or gameobject by mind controlled player or creature. Author: VladimirMangos
This also prevent some crashes in like wrong case.
[7610] skipped.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/SpellAuras.cpp | 17 | ||||
-rw-r--r-- | src/game/SpellHandler.cpp | 71 |
2 files changed, 74 insertions, 14 deletions
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 10028c9095a..f7139d06820 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3072,21 +3072,28 @@ void Aura::HandleAuraModScale(bool apply, bool Real) m_target->StopMoving(); m_target->GetMotionMaster()->Clear(); m_target->GetMotionMaster()->MoveIdle(); - CharmInfo *charmInfo = ((Creature*)m_target)->InitCharmInfo(m_target); - charmInfo->InitPossessCreateSpells(); } + else if(m_target->GetTypeId() == TYPEID_PLAYER) + { + ((Player*)m_target)->SetClientControl(m_target, 0); + } + + if(CharmInfo *charmInfo = m_target->InitCharmInfo(m_target)) + charmInfo->InitPossessCreateSpells(); if(caster->GetTypeId() == TYPEID_PLAYER) - { ((Player*)caster)->PossessSpellInitialize(); - } } else { m_target->SetCharmerGUID(0); + caster->InterruptSpell(CURRENT_CHANNELED_SPELL); // the spell is not automatically canceled when interrupted, do it now if(m_target->GetTypeId() == TYPEID_PLAYER) + { ((Player*)m_target)->setFactionForRace(m_target->getRace()); + ((Player*)m_target)->SetClientControl(m_target, 1); + } else if(m_target->GetTypeId() == TYPEID_UNIT) { CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo(); @@ -3193,7 +3200,7 @@ void Aura::HandleAuraModPetTalentsPoints(bool Apply, bool Real) if(m_target->GetTypeId() == TYPEID_UNIT) { ((Creature*)m_target)->AIM_Initialize(); - CharmInfo *charmInfo = ((Creature*)m_target)->InitCharmInfo(m_target); + CharmInfo *charmInfo = m_target->InitCharmInfo(m_target); charmInfo->InitCharmCreateSpells(); charmInfo->SetReactState( REACT_DEFENSIVE ); diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index cc369f5fee2..098a5624e1d 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -38,6 +38,11 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) CHECK_PACKET_SIZE(recvPacket,1+1+1+4+8+4+1); Player* pUser = _player; + + // ignore for remote control state + if(pUser->m_mover != pUser) + return; + uint8 bagIndex, slot; uint8 unk_flags; // flags (if 0x02 - some additional data are received) uint8 cast_count; // next cast if exists (single or not) @@ -142,6 +147,11 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) sLog.outDetail("WORLD: CMSG_OPEN_ITEM packet, data length = %i",(uint32)recvPacket.size()); Player* pUser = _player; + + // ignore for remote control state + if(pUser->m_mover != pUser) + return; + uint8 bagIndex, slot; recvPacket >> bagIndex >> slot; @@ -219,6 +229,11 @@ void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data ) recv_data >> guid; sLog.outDebug( "WORLD: Recvd CMSG_GAMEOBJ_USE Message [guid=%u]", GUID_LOPART(guid)); + + // ignore for remote control state + if(_player->m_mover != _player) + return; + GameObject *obj = ObjectAccessor::GetGameObject(*_player, guid); if(!obj) @@ -239,6 +254,10 @@ void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket) sLog.outDebug( "WORLD: Recvd CMSG_GAMEOBJ_REPORT_USE Message [in game guid: %u]", GUID_LOPART(guid)); + // ignore for remote control state + if(_player->m_mover != _player) + return; + GameObject* go = ObjectAccessor::GetGameObject(*_player,guid); if(!go) return; @@ -259,6 +278,11 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) recvPacket >> spellId; recvPacket >> unk_flags; // flags (if 0x02 - some additional data are received) + // ignore for remote control state (for player case) + Unit* mover = _player->m_mover; + if(mover != _player && mover->GetTypeId()==TYPEID_PLAYER) + return; + sLog.outDebug("WORLD: got cast spell packet, spellId - %u, cast_count: %u, unk_flags %u, data length = %i", spellId, cast_count, unk_flags, (uint32)recvPacket.size()); @@ -270,11 +294,23 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) return; } - // not have spell in spellbook or spell passive and not casted by client - if ( !_player->HasActiveSpell (spellId) || IsPassiveSpell(spellId) ) + if(mover->GetTypeId()==TYPEID_PLAYER) { - //cheater? kick? ban? - return; + // not have spell in spellbook or spell passive and not casted by client + if (!((Player*)mover)->HasActiveSpell (spellId) || IsPassiveSpell(spellId) ) + { + //cheater? kick? ban? + return; + } + } + else + { + // not have spell in spellbook or spell passive and not casted by client + if (!((Creature*)mover)->HasSpell(spellId) || IsPassiveSpell(spellId) ) + { + //cheater? kick? ban? + return; + } } // can't use our own spells when we're in possession of another unit, @@ -283,7 +319,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) // client provided targets SpellCastTargets targets; - if(!targets.read(&recvPacket,_player)) + if(!targets.read(&recvPacket,mover)) return; // auto-selection buff level base at target level (in spellInfo) @@ -296,7 +332,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) spellInfo = actualSpellInfo; } - Spell *spell = new Spell(_player, spellInfo, false); + Spell *spell = new Spell(mover, spellInfo, false); spell->m_cast_count = cast_count; // set count of casts spell->prepare(&targets); } @@ -305,6 +341,11 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket) { CHECK_PACKET_SIZE(recvPacket,5); + // ignore for remote control state (for player case) + Unit* mover = _player->m_mover; + if(mover != _player && mover->GetTypeId()==TYPEID_PLAYER) + return; + // increments with every CANCEL packet, don't use for now uint8 counter; uint32 spellId; @@ -315,14 +356,18 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket) if(spellId==26679) return; - if(_player->IsNonMeleeSpellCasted(false)) - _player->InterruptNonMeleeSpells(false,spellId); + if(mover->IsNonMeleeSpellCasted(false)) + mover->InterruptNonMeleeSpells(false,spellId); } void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket) { CHECK_PACKET_SIZE(recvPacket,4); + // ignore for remote control state + if(_player->m_mover != _player) + return; + uint32 spellId; recvPacket >> spellId; @@ -357,6 +402,10 @@ void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket) { CHECK_PACKET_SIZE(recvPacket, 8+4); + // ignore for remote control state + if(_player->m_mover != _player) + return; + uint64 guid; uint32 spellId; @@ -404,7 +453,7 @@ void WorldSession::HandleCancelAutoRepeatSpellOpcode( WorldPacket& /*recvPacket* { // may be better send SMSG_CANCEL_AUTO_REPEAT? // cancel and prepare for deleting - _player->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); + _player->m_mover->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); } /// \todo Complete HandleCancelChanneling function @@ -422,6 +471,10 @@ void WorldSession::HandleTotemDestroy( WorldPacket& recvPacket) { CHECK_PACKET_SIZE(recvPacket, 1); + // ignore for remote control state + if(_player->m_mover != _player) + return; + uint8 slotId; recvPacket >> slotId; |