mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[7611] Prevent casting owner spell/use item or gameobject by mind controlled player or creature.
This also prevent some crashes in like wrong case.
This commit is contained in:
parent
e4daaaedb1
commit
485eb8adb1
2 changed files with 63 additions and 10 deletions
|
|
@ -34,6 +34,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)
|
||||
|
|
@ -138,6 +143,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;
|
||||
|
|
@ -215,6 +225,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)
|
||||
|
|
@ -235,6 +250,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;
|
||||
|
|
@ -255,6 +274,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());
|
||||
|
||||
|
|
@ -266,16 +290,28 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
|
@ -288,7 +324,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);
|
||||
}
|
||||
|
|
@ -297,6 +333,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;
|
||||
|
|
@ -307,14 +348,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;
|
||||
|
||||
|
|
@ -349,6 +394,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;
|
||||
|
||||
|
|
@ -396,7 +445,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
|
||||
|
|
@ -414,6 +463,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue