2010-10-07 15:35:36 +02:00
/*
2012-12-31 23:15:50 +01:00
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
2010-10-07 15:35:36 +02:00
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
2008-10-11 14:16:25 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
#include "Common.h"
#include "Language.h"
2010-06-08 17:01:03 -06:00
#include "DatabaseEnv.h"
2008-10-11 14:16:25 -05:00
#include "WorldPacket.h"
#include "Opcodes.h"
#include "Log.h"
#include "Player.h"
2009-03-30 16:57:17 +02:00
#include "GossipDef.h"
2008-10-11 14:16:25 -05:00
#include "World.h"
#include "ObjectMgr.h"
2011-05-04 10:08:09 +02:00
#include "GuildMgr.h"
2008-10-11 14:16:25 -05:00
#include "WorldSession.h"
2010-06-07 16:21:52 -06:00
#include "BigNumber.h"
#include "SHA1.h"
2008-10-11 14:16:25 -05:00
#include "UpdateData.h"
#include "LootMgr.h"
#include "Chat.h"
2010-06-07 16:21:52 -06:00
#include "zlib.h"
2008-10-11 14:16:25 -05:00
#include "ObjectAccessor.h"
#include "Object.h"
2010-08-08 04:37:24 +02:00
#include "Battleground.h"
2008-10-14 11:57:03 -05:00
#include "OutdoorPvP.h"
2008-10-11 14:16:25 -05:00
#include "Pet.h"
#include "SocialMgr.h"
2008-11-15 15:11:31 -06:00
#include "CellImpl.h"
2009-05-14 23:07:17 +02:00
#include "AccountMgr.h"
2009-04-17 15:08:58 -05:00
#include "Vehicle.h"
2009-05-03 11:41:58 -05:00
#include "CreatureAI.h"
2009-12-17 14:06:20 +01:00
#include "DBCEnums.h"
2010-01-19 11:36:05 +01:00
#include "ScriptMgr.h"
2010-05-04 18:25:30 +02:00
#include "MapManager.h"
2010-08-08 22:54:58 +06:00
#include "InstanceScript.h"
2010-10-27 21:01:47 +02:00
#include "GameObjectAI.h"
2010-11-29 07:50:31 +01:00
#include "Group.h"
2011-09-08 15:11:55 +02:00
#include "AccountMgr.h"
2012-05-23 14:24:28 +02:00
#include "Spell.h"
2012-08-21 23:01:24 +02:00
#include "BattlegroundMgr.h"
2012-08-20 16:23:24 -04:00
#include "Battlefield.h"
#include "BattlefieldMgr.h"
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleRepopRequestOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Recvd CMSG_REPOP_REQUEST Message" );
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData . read_skip < uint8 > ();
2009-10-17 15:51:44 -07:00
2011-08-21 12:42:22 +02:00
if ( GetPlayer () -> isAlive () || GetPlayer () -> HasFlag ( PLAYER_FLAGS , PLAYER_FLAGS_GHOST ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-06 14:23:53 +02:00
if ( GetPlayer () -> HasAuraType ( SPELL_AURA_PREVENT_RESURRECTION ))
2011-08-21 12:42:22 +02:00
return ; // silently return, client should display the error by itself
2008-10-11 14:16:25 -05:00
// the world update order is sessions, players, creatures
// the netcode runs in parallel with all of these
// creatures can kill players
// so if the server is lagging enough the player can
// release spirit after he's killed but before he is updated
2010-04-07 19:14:10 +02:00
if ( GetPlayer () -> getDeathState () == JUST_DIED )
2008-10-11 14:16:25 -05:00
{
2012-10-24 13:29:34 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated" ,
GetPlayer () -> GetName (). c_str (), GetPlayer () -> GetGUIDLow ());
2008-10-11 14:16:25 -05:00
GetPlayer () -> KillPlayer ();
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
//this is spirit release confirm?
2011-04-29 20:47:02 +02:00
GetPlayer () -> RemovePet ( NULL , PET_SAVE_NOT_IN_SLOT , true );
2008-10-11 14:16:25 -05:00
GetPlayer () -> BuildPlayerRepop ();
GetPlayer () -> RepopAtGraveyard ();
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleGossipSelectOptionOpcode ( WorldPacket & recvData )
2009-03-30 16:57:17 +02:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_GOSSIP_SELECT_OPTION" );
2009-10-17 15:51:44 -07:00
2009-12-20 13:35:08 +02:00
uint32 gossipListId ;
uint32 menuId ;
2009-03-30 16:57:17 +02:00
uint64 guid ;
std :: string code = "" ;
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> guid >> menuId >> gossipListId ;
2009-10-17 15:51:44 -07:00
2011-05-26 23:57:17 +02:00
if ( _player -> PlayerTalkClass -> IsGossipOptionCoded ( gossipListId ))
2012-10-24 13:29:34 +02:00
recvData >> code ;
2009-10-17 15:51:44 -07:00
2011-06-12 01:47:45 +02:00
Creature * unit = NULL ;
2011-09-15 14:08:17 +02:00
GameObject * go = NULL ;
2010-04-07 19:14:10 +02:00
if ( IS_CRE_OR_VEH_GUID ( guid ))
2009-03-30 16:57:17 +02:00
{
2009-04-19 19:42:52 -05:00
unit = GetPlayer () -> GetNPCIfCanInteractWith ( guid , UNIT_NPC_FLAG_NONE );
2009-03-30 16:57:17 +02:00
if ( ! unit )
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him." , uint32 ( GUID_LOPART ( guid )));
2009-03-30 16:57:17 +02:00
return ;
}
}
2010-04-07 19:14:10 +02:00
else if ( IS_GAMEOBJECT_GUID ( guid ))
2009-03-30 16:57:17 +02:00
{
2009-04-20 20:28:19 -05:00
go = _player -> GetMap () -> GetGameObject ( guid );
2009-03-30 16:57:17 +02:00
if ( ! go )
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: HandleGossipSelectOptionOpcode - GameObject (GUID: %u) not found." , uint32 ( GUID_LOPART ( guid )));
2009-03-30 16:57:17 +02:00
return ;
}
}
else
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for highguid %u. lowpart %u." , uint32 ( GUID_HIPART ( guid )), uint32 ( GUID_LOPART ( guid )));
2009-04-20 17:48:14 -05:00
return ;
2009-03-30 16:57:17 +02:00
}
2009-10-17 15:51:44 -07:00
2009-03-30 16:57:17 +02:00
// remove fake death
2012-02-03 19:02:17 +02:00
if ( GetPlayer () -> HasUnitState ( UNIT_STATE_DIED ))
2009-04-06 13:31:14 +02:00
GetPlayer () -> RemoveAurasByType ( SPELL_AURA_FEIGN_DEATH );
2009-10-17 15:51:44 -07:00
2012-02-27 14:58:47 +01:00
if (( unit && unit -> GetCreatureTemplate () -> ScriptID != unit -> LastUsedScriptID ) || ( go && go -> GetGOInfo () -> ScriptId != go -> LastUsedScriptID ))
2010-05-16 17:45:45 +02:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: HandleGossipSelectOptionOpcode - Script reloaded while in use, ignoring and set new scipt id" );
2010-05-16 17:45:45 +02:00
if ( unit )
2012-02-27 14:58:47 +01:00
unit -> LastUsedScriptID = unit -> GetCreatureTemplate () -> ScriptID ;
2010-05-16 17:45:45 +02:00
if ( go )
go -> LastUsedScriptID = go -> GetGOInfo () -> ScriptId ;
2011-05-26 23:57:17 +02:00
_player -> PlayerTalkClass -> SendCloseGossip ();
2010-05-16 17:45:45 +02:00
return ;
}
2010-04-07 19:14:10 +02:00
if ( ! code . empty ())
2009-03-30 16:57:17 +02:00
{
2010-04-07 19:14:10 +02:00
if ( unit )
2009-03-30 16:57:17 +02:00
{
2010-11-04 22:08:15 +01:00
unit -> AI () -> sGossipSelectCode ( _player , menuId , gossipListId , code . c_str ());
2011-05-26 23:57:17 +02:00
if ( ! sScriptMgr -> OnGossipSelectCode ( _player , unit , _player -> PlayerTalkClass -> GetGossipOptionSender ( gossipListId ), _player -> PlayerTalkClass -> GetGossipOptionAction ( gossipListId ), code . c_str ()))
2009-12-20 13:35:08 +02:00
_player -> OnGossipSelect ( unit , gossipListId , menuId );
2009-03-30 16:57:17 +02:00
}
else
2010-12-13 22:37:56 +01:00
{
2010-11-04 22:08:15 +01:00
go -> AI () -> GossipSelectCode ( _player , menuId , gossipListId , code . c_str ());
2011-05-26 23:57:17 +02:00
sScriptMgr -> OnGossipSelectCode ( _player , go , _player -> PlayerTalkClass -> GetGossipOptionSender ( gossipListId ), _player -> PlayerTalkClass -> GetGossipOptionAction ( gossipListId ), code . c_str ());
2010-10-27 21:01:47 +02:00
}
2009-03-30 16:57:17 +02:00
}
else
{
2010-04-07 19:14:10 +02:00
if ( unit )
2009-03-30 16:57:17 +02:00
{
2010-11-04 22:08:15 +01:00
unit -> AI () -> sGossipSelect ( _player , menuId , gossipListId );
2011-05-26 23:57:17 +02:00
if ( ! sScriptMgr -> OnGossipSelect ( _player , unit , _player -> PlayerTalkClass -> GetGossipOptionSender ( gossipListId ), _player -> PlayerTalkClass -> GetGossipOptionAction ( gossipListId )))
2009-12-20 13:35:08 +02:00
_player -> OnGossipSelect ( unit , gossipListId , menuId );
2009-03-30 16:57:17 +02:00
}
else
2010-10-27 21:01:47 +02:00
{
2010-11-04 22:08:15 +01:00
go -> AI () -> GossipSelect ( _player , menuId , gossipListId );
2012-01-09 09:29:45 -05:00
if ( ! sScriptMgr -> OnGossipSelect ( _player , go , _player -> PlayerTalkClass -> GetGossipOptionSender ( gossipListId ), _player -> PlayerTalkClass -> GetGossipOptionAction ( gossipListId )))
_player -> OnGossipSelect ( go , gossipListId , menuId );
2010-10-27 21:01:47 +02:00
}
2009-03-30 16:57:17 +02:00
}
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleWhoOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Recvd CMSG_WHO Message" );
2009-10-17 15:51:44 -07:00
2012-01-06 19:36:17 +01:00
time_t now = time ( NULL );
if ( now - timeLastWhoCommand < 5 )
return ;
else timeLastWhoCommand = now ;
2010-12-17 16:36:01 +01:00
uint32 matchcount = 0 ;
2009-10-17 15:51:44 -07:00
2009-11-01 23:01:26 -08:00
uint32 level_min , level_max , racemask , classmask , zones_count , str_count ;
2008-10-11 14:16:25 -05:00
uint32 zoneids [ 10 ]; // 10 is client limit
std :: string player_name , guild_name ;
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> level_min ; // maximal player level, default 0
recvData >> level_max ; // minimal player level, default 100 (MAX_LEVEL)
recvData >> player_name ; // player name, case sensitive...
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> guild_name ; // guild name, case sensitive...
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> racemask ; // race mask
recvData >> classmask ; // class mask
recvData >> zones_count ; // zones count, client limit = 10 (2.0.10)
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( zones_count > 10 )
2008-10-11 14:16:25 -05:00
return ; // can't be received from real client or broken packet
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < zones_count ; ++ i )
2008-10-11 14:16:25 -05:00
{
uint32 temp ;
2012-10-24 13:29:34 +02:00
recvData >> temp ; // zone id, 0 if zone is unknown...
2008-10-11 14:16:25 -05:00
zoneids [ i ] = temp ;
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Zone %u: %u" , i , zoneids [ i ]);
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> str_count ; // user entered strings count, client limit=4 (checked on 2.0.10)
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( str_count > 4 )
2008-10-11 14:16:25 -05:00
return ; // can't be received from real client or broken packet
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Minlvl %u, maxlvl %u, name %s, guild %s, racemask %u, classmask %u, zones %u, strings %u" , level_min , level_max , player_name . c_str (), guild_name . c_str (), racemask , classmask , zones_count , str_count );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
std :: wstring str [ 4 ]; // 4 is client limit
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < str_count ; ++ i )
2008-10-11 14:16:25 -05:00
{
std :: string temp ;
2012-10-24 13:29:34 +02:00
recvData >> temp ; // user entered string, it used as universal search pattern(guild+player name)?
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
if ( ! Utf8toWStr ( temp , str [ i ]))
2008-10-11 14:16:25 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
wstrToLower ( str [ i ]);
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "String %u: %s" , i , temp . c_str ());
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
std :: wstring wplayer_name ;
std :: wstring wguild_name ;
2009-11-01 17:53:07 -08:00
if ( ! ( Utf8toWStr ( player_name , wplayer_name ) && Utf8toWStr ( guild_name , wguild_name )))
2008-10-11 14:16:25 -05:00
return ;
wstrToLower ( wplayer_name );
wstrToLower ( wguild_name );
2009-10-17 15:51:44 -07:00
2010-02-05 00:31:28 +01:00
// client send in case not set max level value 100 but Trinity supports 255 max level,
2008-10-11 14:16:25 -05:00
// update it to show GMs with characters after 100 level
2009-11-01 17:53:07 -08:00
if ( level_max >= MAX_LEVEL )
2008-12-19 16:05:13 -06:00
level_max = STRONG_MAX_LEVEL ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 team = _player -> GetTeam ();
uint32 security = GetSecurity ();
2010-12-23 23:25:44 +01:00
bool allowTwoSideWhoList = sWorld -> getBoolConfig ( CONFIG_ALLOW_TWO_SIDE_WHO_LIST );
uint32 gmLevelInWhoList = sWorld -> getIntConfig ( CONFIG_GM_LEVEL_IN_WHO_LIST );
2010-12-17 16:36:01 +01:00
uint32 displaycount = 0 ;
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
WorldPacket data ( SMSG_WHO , 50 ); // guess size
2010-12-17 16:36:01 +01:00
data << uint32 ( matchcount ); // placeholder, count of players matching criteria
data << uint32 ( displaycount ); // placeholder, count of players displayed
2009-10-17 15:51:44 -07:00
2011-10-31 17:25:12 -04:00
TRINITY_READ_GUARD ( HashMapHolder < Player >:: LockType , * HashMapHolder < Player >:: GetLock ());
2011-10-21 17:29:09 -04:00
HashMapHolder < Player >:: MapType const & m = sObjectAccessor -> GetPlayers ();
2009-10-17 16:20:24 -07:00
for ( HashMapHolder < Player >:: MapType :: const_iterator itr = m . begin (); itr != m . end (); ++ itr )
2008-10-11 14:16:25 -05:00
{
2011-09-08 15:11:55 +02:00
if ( AccountMgr :: IsPlayerAccount ( security ))
2008-10-11 14:16:25 -05:00
{
// player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST
2010-04-07 22:59:46 +02:00
if ( itr -> second -> GetTeam () != team && ! allowTwoSideWhoList )
2008-10-11 14:16:25 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST
2010-08-23 14:10:24 +02:00
if (( itr -> second -> GetSession () -> GetSecurity () > AccountTypes ( gmLevelInWhoList )))
2008-10-11 14:16:25 -05:00
continue ;
}
2009-10-17 15:51:44 -07:00
2009-07-01 18:36:03 -05:00
//do not process players which are not in world
2010-04-07 19:14:10 +02:00
if ( ! ( itr -> second -> IsInWorld ()))
2009-07-01 18:36:03 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// check if target is globally visible for player
if ( ! ( itr -> second -> IsVisibleGloballyFor ( _player )))
continue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// check if target's level is in level range
2009-11-01 17:53:07 -08:00
uint8 lvl = itr -> second -> getLevel ();
2008-10-11 14:16:25 -05:00
if ( lvl < level_min || lvl > level_max )
continue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// check if class matches classmask
uint32 class_ = itr -> second -> getClass ();
if ( ! ( classmask & ( 1 << class_ )))
continue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// check if race matches racemask
uint32 race = itr -> second -> getRace ();
if ( ! ( racemask & ( 1 << race )))
continue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 pzoneid = itr -> second -> GetZoneId ();
2010-08-04 22:12:43 +06:00
uint8 gender = itr -> second -> getGender ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
bool z_show = true ;
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < zones_count ; ++ i )
2008-10-11 14:16:25 -05:00
{
2010-04-07 19:14:10 +02:00
if ( zoneids [ i ] == pzoneid )
2008-10-11 14:16:25 -05:00
{
z_show = true ;
break ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
z_show = false ;
}
if ( ! z_show )
continue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
std :: string pname = itr -> second -> GetName ();
std :: wstring wpname ;
2011-04-29 20:47:02 +02:00
if ( ! Utf8toWStr ( pname , wpname ))
2008-10-11 14:16:25 -05:00
continue ;
wstrToLower ( wpname );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
if ( ! ( wplayer_name . empty () || wpname . find ( wplayer_name ) != std :: wstring :: npos ))
continue ;
2009-10-17 15:51:44 -07:00
2011-05-04 10:08:09 +02:00
std :: string gname = sGuildMgr -> GetGuildNameById ( itr -> second -> GetGuildId ());
2008-10-11 14:16:25 -05:00
std :: wstring wgname ;
2011-04-29 20:47:02 +02:00
if ( ! Utf8toWStr ( gname , wgname ))
2008-10-11 14:16:25 -05:00
continue ;
wstrToLower ( wgname );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
if ( ! ( wguild_name . empty () || wgname . find ( wguild_name ) != std :: wstring :: npos ))
continue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
std :: string aname ;
2010-04-07 19:14:10 +02:00
if ( AreaTableEntry const * areaEntry = GetAreaEntryByAreaID ( itr -> second -> GetZoneId ()))
2008-10-11 14:16:25 -05:00
aname = areaEntry -> area_name [ GetSessionDbcLocale ()];
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
bool s_show = true ;
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < str_count ; ++ i )
2008-10-11 14:16:25 -05:00
{
if ( ! str [ i ]. empty ())
{
if ( wgname . find ( str [ i ]) != std :: wstring :: npos ||
wpname . find ( str [ i ]) != std :: wstring :: npos ||
2010-04-07 22:59:46 +02:00
Utf8FitTo ( aname , str [ i ]))
2008-10-11 14:16:25 -05:00
{
s_show = true ;
break ;
}
s_show = false ;
}
}
if ( ! s_show )
continue ;
2009-10-17 15:51:44 -07:00
2010-12-17 16:36:01 +01:00
// 49 is maximum player count sent to client - can be overridden
// through config, but is unstable
2010-12-23 23:25:44 +01:00
if (( matchcount ++ ) >= sWorld -> getIntConfig ( CONFIG_MAX_WHO ))
2010-12-17 16:36:01 +01:00
continue ;
2010-08-04 22:12:43 +06:00
data << pname ; // player name
data << gname ; // guild name
2010-04-07 22:59:46 +02:00
data << uint32 ( lvl ); // player level
data << uint32 ( class_ ); // player class
data << uint32 ( race ); // player race
2010-08-04 22:12:43 +06:00
data << uint8 ( gender ); // player gender
2010-04-07 22:59:46 +02:00
data << uint32 ( pzoneid ); // player zone id
2009-10-17 15:51:44 -07:00
2010-12-17 16:36:01 +01:00
++ displaycount ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-12-18 16:09:50 +01:00
data . put ( 0 , displaycount ); // insert right count, count displayed
data . put ( 4 , matchcount ); // insert right count, count of matches
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
SendPacket ( & data );
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Send SMSG_WHO Message" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleLogoutRequestOpcode ( WorldPacket & /*recvData*/ )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u" , GetSecurity ());
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
if ( uint64 lguid = GetPlayer () -> GetLootGUID ())
DoLootRelease ( lguid );
2009-10-17 15:51:44 -07:00
2013-02-20 20:52:58 +01:00
bool instantLogout = ( GetPlayer () -> HasFlag ( PLAYER_FLAGS , PLAYER_FLAGS_RESTING ) && ! GetPlayer () -> isInCombat ()) ||
GetPlayer () -> isInFlight () || HasPermission ( RBAC_PERM_INSTANT_LOGOUT );
2010-05-28 02:07:47 +02:00
2013-02-20 20:52:58 +01:00
/// TODO: Possibly add RBAC permission to log out in combat
bool canLogoutInCombat = GetPlayer () -> HasFlag ( PLAYER_FLAGS , PLAYER_FLAGS_RESTING );
uint32 reason = 0 ;
if ( GetPlayer () -> isInCombat () && ! canLogoutInCombat )
2010-05-28 02:07:47 +02:00
reason = 1 ;
2012-03-17 20:34:03 +01:00
else if ( GetPlayer () -> m_movementInfo . HasMovementFlag ( MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR ))
2010-05-28 02:07:47 +02:00
reason = 3 ; // is jumping or falling
else if ( GetPlayer () -> duel || GetPlayer () -> HasAura ( 9454 )) // is dueling or frozen by GM via freeze command
reason = 2 ; // FIXME - Need the correct value
2013-02-20 20:52:58 +01:00
WorldPacket data ( SMSG_LOGOUT_RESPONSE , 1 + 4 );
data << uint32 ( reason );
data << uint8 ( instantLogout );
SendPacket ( & data );
2010-05-28 02:07:47 +02:00
if ( reason )
2008-10-11 14:16:25 -05:00
{
LogoutRequest ( 0 );
return ;
}
2009-10-17 15:51:44 -07:00
2010-06-19 13:54:19 -06:00
//instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in worldserver.conf
2013-02-20 20:52:58 +01:00
if ( instantLogout )
2008-10-11 14:16:25 -05:00
{
LogoutPlayer ( true );
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// not set flags if player can't free move to prevent lost state at logout cancel
2010-04-07 19:14:10 +02:00
if ( GetPlayer () -> CanFreeMove ())
2008-10-11 14:16:25 -05:00
{
2009-01-31 14:41:36 -06:00
GetPlayer () -> SetStandState ( UNIT_STAND_STATE_SIT );
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
WorldPacket data ( SMSG_FORCE_MOVE_ROOT , ( 8 + 4 )); // guess size
2008-10-11 14:16:25 -05:00
data . append ( GetPlayer () -> GetPackGUID ());
data << ( uint32 ) 2 ;
2010-04-07 22:59:46 +02:00
SendPacket ( & data );
2008-12-24 09:58:26 -06:00
GetPlayer () -> SetFlag ( UNIT_FIELD_FLAGS , UNIT_FLAG_STUNNED );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-12-24 10:20:15 +01:00
LogoutRequest ( time ( NULL ));
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandlePlayerLogoutOpcode ( WorldPacket & /*recvData*/ )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Recvd CMSG_PLAYER_LOGOUT Message" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleLogoutCancelOpcode ( WorldPacket & /*recvData*/ )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Recvd CMSG_LOGOUT_CANCEL Message" );
2009-10-17 15:51:44 -07:00
2012-05-27 19:57:31 +02:00
// Player have already logged out serverside, too late to cancel
if ( ! GetPlayer ())
return ;
2008-10-11 14:16:25 -05:00
LogoutRequest ( 0 );
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
WorldPacket data ( SMSG_LOGOUT_CANCEL_ACK , 0 );
SendPacket ( & data );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// not remove flags if can't free move - its not set in Logout request code.
2010-04-07 19:14:10 +02:00
if ( GetPlayer () -> CanFreeMove ())
2008-10-11 14:16:25 -05:00
{
//!we can move again
2010-04-07 22:59:46 +02:00
data . Initialize ( SMSG_FORCE_MOVE_UNROOT , 8 ); // guess size
2008-10-11 14:16:25 -05:00
data . append ( GetPlayer () -> GetPackGUID ());
data << uint32 ( 0 );
2010-04-07 22:59:46 +02:00
SendPacket ( & data );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
//! Stand Up
2009-01-31 14:41:36 -06:00
GetPlayer () -> SetStandState ( UNIT_STAND_STATE_STAND );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
//! DISABLE_ROTATE
2008-12-24 09:58:26 -06:00
GetPlayer () -> RemoveFlag ( UNIT_FIELD_FLAGS , UNIT_FLAG_STUNNED );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Sent SMSG_LOGOUT_CANCEL_ACK Message" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleTogglePvP ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
// this opcode can be used in two ways: Either set explicit new status or toggle old status
2012-10-24 13:29:34 +02:00
if ( recvData . size () == 1 )
2008-10-11 14:16:25 -05:00
{
bool newPvPStatus ;
2012-10-24 13:29:34 +02:00
recvData >> newPvPStatus ;
2008-10-11 14:16:25 -05:00
GetPlayer () -> ApplyModFlag ( PLAYER_FLAGS , PLAYER_FLAGS_IN_PVP , newPvPStatus );
2008-12-24 09:58:26 -06:00
GetPlayer () -> ApplyModFlag ( PLAYER_FLAGS , PLAYER_FLAGS_PVP_TIMER , ! newPvPStatus );
2008-10-11 14:16:25 -05:00
}
else
{
GetPlayer () -> ToggleFlag ( PLAYER_FLAGS , PLAYER_FLAGS_IN_PVP );
2008-12-24 09:58:26 -06:00
GetPlayer () -> ToggleFlag ( PLAYER_FLAGS , PLAYER_FLAGS_PVP_TIMER );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( GetPlayer () -> HasFlag ( PLAYER_FLAGS , PLAYER_FLAGS_IN_PVP ))
2008-10-11 14:16:25 -05:00
{
2010-04-07 19:14:10 +02:00
if ( ! GetPlayer () -> IsPvP () || GetPlayer () -> pvpInfo . endTimer != 0 )
2008-10-11 14:16:25 -05:00
GetPlayer () -> UpdatePvP ( true , true );
}
else
{
2010-04-07 19:14:10 +02:00
if ( ! GetPlayer () -> pvpInfo . inHostileArea && GetPlayer () -> IsPvP ())
2009-12-24 10:20:15 +01:00
GetPlayer () -> pvpInfo . endTimer = time ( NULL ); // start toggle-off
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
//if (OutdoorPvP* pvp = _player->GetOutdoorPvP())
2009-05-29 00:18:41 -05:00
// pvp->HandlePlayerActivityChanged(_player);
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleZoneUpdateOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
uint32 newZone ;
2012-10-24 13:29:34 +02:00
recvData >> newZone ;
2009-10-17 15:51:44 -07:00
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Recvd ZONE_UPDATE: %u" , newZone );
2009-10-17 15:51:44 -07:00
2009-03-11 16:17:37 -06:00
// use server size data
uint32 newzone , newarea ;
2011-04-29 20:47:02 +02:00
GetPlayer () -> GetZoneAndAreaId ( newzone , newarea );
GetPlayer () -> UpdateZone ( newzone , newarea );
//GetPlayer()->SendInitWorldStates(true, newZone);
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleSetSelectionOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
uint64 guid ;
2012-10-24 13:29:34 +02:00
recvData >> guid ;
2009-10-17 15:51:44 -07:00
2011-08-01 18:25:48 -07:00
_player -> SetSelection ( guid );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleStandStateChangeOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2012-10-24 13:29:34 +02:00
// sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_STANDSTATECHANGE"); -- too many spam in log at lags/debug stop
2009-08-19 16:54:52 -05:00
uint32 animstate ;
2012-10-24 13:29:34 +02:00
recvData >> animstate ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
_player -> SetStandState ( animstate );
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleContactListOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
uint32 unk ;
2012-10-24 13:29:34 +02:00
recvData >> unk ;
2011-07-29 14:18:28 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_CONTACT_LIST - Unk: %d" , unk );
2010-09-25 17:08:55 +02:00
_player -> GetSocial () -> SendSocialList ( _player );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleAddFriendOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_ADD_FRIEND" );
2009-10-17 15:51:44 -07:00
2008-11-05 20:10:19 -06:00
std :: string friendName = GetTrinityString ( LANG_FRIEND_IGNORE_UNKNOWN );
2008-10-11 14:16:25 -05:00
std :: string friendNote ;
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> friendName ;
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> friendNote ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! normalizePlayerName ( friendName ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: %s asked to add friend : '%s'" ,
GetPlayer () -> GetName (). c_str (), friendName . c_str ());
2009-10-17 15:51:44 -07:00
2012-01-01 01:09:38 +01:00
PreparedStatement * stmt = CharacterDatabase . GetPreparedStatement ( CHAR_SEL_GUID_RACE_ACC_BY_NAME );
2011-12-20 09:12:19 +01:00
stmt -> setString ( 0 , friendName );
2009-10-17 15:51:44 -07:00
2011-06-22 14:20:42 +02:00
_addFriendCallback . SetParam ( friendNote );
2011-12-20 09:12:19 +01:00
_addFriendCallback . SetFutureResult ( CharacterDatabase . AsyncQuery ( stmt ));
2008-11-05 20:10:19 -06:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 15:34:23 +02:00
void WorldSession :: HandleAddFriendOpcodeCallBack ( PreparedQueryResult result , std :: string const & friendNote )
2008-11-05 20:10:19 -06:00
{
2010-09-09 20:26:56 +02:00
if ( ! GetPlayer ())
return ;
2009-03-04 20:51:40 +01:00
uint64 friendGuid ;
2011-12-20 09:12:19 +01:00
uint32 friendAccountId ;
2009-03-04 20:51:40 +01:00
uint32 team ;
FriendsResult friendResult ;
2009-10-17 15:51:44 -07:00
2009-03-04 20:51:40 +01:00
friendResult = FRIEND_NOT_FOUND ;
friendGuid = 0 ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( result )
2008-10-11 14:16:25 -05:00
{
2011-12-20 09:12:19 +01:00
Field * fields = result -> Fetch ();
friendGuid = MAKE_NEW_GUID ( fields [ 0 ]. GetUInt32 (), 0 , HIGHGUID_PLAYER );
team = Player :: TeamForRace ( fields [ 1 ]. GetUInt8 ());
friendAccountId = fields [ 2 ]. GetUInt32 ();
2009-10-17 15:51:44 -07:00
2011-12-20 09:12:19 +01:00
if ( ! AccountMgr :: IsPlayerAccount ( GetSecurity ()) || sWorld -> getBoolConfig ( CONFIG_ALLOW_GM_FRIEND ) || AccountMgr :: IsPlayerAccount ( AccountMgr :: GetSecurity ( friendAccountId , realmID )))
2008-11-05 20:10:19 -06:00
{
2010-04-07 19:14:10 +02:00
if ( friendGuid )
2008-11-10 17:19:35 -06:00
{
2010-08-18 19:48:51 +02:00
if ( friendGuid == GetPlayer () -> GetGUID ())
2009-05-14 23:07:17 +02:00
friendResult = FRIEND_SELF ;
2011-09-08 15:11:55 +02:00
else if ( GetPlayer () -> GetTeam () != team && ! sWorld -> getBoolConfig ( CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND ) && AccountMgr :: IsPlayerAccount ( GetSecurity ()))
2009-05-14 23:07:17 +02:00
friendResult = FRIEND_ENEMY ;
2010-08-18 19:48:51 +02:00
else if ( GetPlayer () -> GetSocial () -> HasFriend ( GUID_LOPART ( friendGuid )))
2009-05-14 23:07:17 +02:00
friendResult = FRIEND_ALREADY ;
2009-03-04 20:51:40 +01:00
else
{
2009-05-14 23:07:17 +02:00
Player * pFriend = ObjectAccessor :: FindPlayer ( friendGuid );
2010-08-18 19:48:51 +02:00
if ( pFriend && pFriend -> IsInWorld () && pFriend -> IsVisibleGloballyFor ( GetPlayer ()))
2009-05-14 23:07:17 +02:00
friendResult = FRIEND_ADDED_ONLINE ;
else
friendResult = FRIEND_ADDED_OFFLINE ;
2010-08-18 19:48:51 +02:00
if ( ! GetPlayer () -> GetSocial () -> AddToSocialList ( GUID_LOPART ( friendGuid ), false ))
2009-05-14 23:07:17 +02:00
{
friendResult = FRIEND_LIST_FULL ;
2012-10-24 13:29:34 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: %s's friend list is full." , GetPlayer () -> GetName (). c_str ());
2009-05-14 23:07:17 +02:00
}
2009-03-04 20:51:40 +01:00
}
2010-08-18 19:48:51 +02:00
GetPlayer () -> GetSocial () -> SetFriendNote ( GUID_LOPART ( friendGuid ), friendNote );
2009-03-04 20:51:40 +01:00
}
2009-05-25 12:05:23 -05:00
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-12-22 21:25:23 +01:00
sSocialMgr -> SendFriendStatus ( GetPlayer (), friendResult , GUID_LOPART ( friendGuid ), false );
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Sent (SMSG_FRIEND_STATUS)" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleDelFriendOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
uint64 FriendGUID ;
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_DEL_FRIEND" );
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> FriendGUID ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
_player -> GetSocial () -> RemoveFromSocialList ( GUID_LOPART ( FriendGUID ), false );
2009-10-17 15:51:44 -07:00
2010-12-22 21:25:23 +01:00
sSocialMgr -> SendFriendStatus ( GetPlayer (), FRIEND_REMOVED , GUID_LOPART ( FriendGUID ), false );
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleAddIgnoreOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_ADD_IGNORE" );
2009-10-17 15:51:44 -07:00
2011-12-18 20:55:59 +01:00
std :: string ignoreName = GetTrinityString ( LANG_FRIEND_IGNORE_UNKNOWN );
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> ignoreName ;
2009-10-17 15:51:44 -07:00
2011-12-18 20:55:59 +01:00
if ( ! normalizePlayerName ( ignoreName ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: %s asked to Ignore: '%s'" ,
2012-10-24 13:29:34 +02:00
GetPlayer () -> GetName (). c_str (), ignoreName . c_str ());
2011-12-18 20:55:59 +01:00
2012-01-01 01:09:38 +01:00
PreparedStatement * stmt = CharacterDatabase . GetPreparedStatement ( CHAR_SEL_GUID_BY_NAME );
2011-12-18 20:55:59 +01:00
stmt -> setString ( 0 , ignoreName );
2009-10-17 15:51:44 -07:00
2011-12-18 20:55:59 +01:00
_addIgnoreCallback = CharacterDatabase . AsyncQuery ( stmt );
2008-11-05 20:10:19 -06:00
}
2009-10-17 15:51:44 -07:00
2011-12-18 20:55:59 +01:00
void WorldSession :: HandleAddIgnoreOpcodeCallBack ( PreparedQueryResult result )
2008-11-05 20:10:19 -06:00
{
2010-09-09 20:26:56 +02:00
if ( ! GetPlayer ())
return ;
2009-03-04 20:51:40 +01:00
uint64 IgnoreGuid ;
FriendsResult ignoreResult ;
2009-10-17 15:51:44 -07:00
2009-03-04 20:51:40 +01:00
ignoreResult = FRIEND_IGNORE_NOT_FOUND ;
IgnoreGuid = 0 ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( result )
2008-10-11 14:16:25 -05:00
{
2009-03-04 20:51:40 +01:00
IgnoreGuid = MAKE_NEW_GUID (( * result )[ 0 ]. GetUInt32 (), 0 , HIGHGUID_PLAYER );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( IgnoreGuid )
2009-03-04 20:51:40 +01:00
{
2010-08-18 19:48:51 +02:00
if ( IgnoreGuid == GetPlayer () -> GetGUID ()) //not add yourself
2009-03-04 20:51:40 +01:00
ignoreResult = FRIEND_IGNORE_SELF ;
2010-08-18 19:48:51 +02:00
else if ( GetPlayer () -> GetSocial () -> HasIgnore ( GUID_LOPART ( IgnoreGuid )))
2009-03-04 20:51:40 +01:00
ignoreResult = FRIEND_IGNORE_ALREADY ;
else
{
ignoreResult = FRIEND_IGNORE_ADDED ;
2009-10-17 15:51:44 -07:00
2009-03-04 20:51:40 +01:00
// ignore list full
2010-08-18 19:48:51 +02:00
if ( ! GetPlayer () -> GetSocial () -> AddToSocialList ( GUID_LOPART ( IgnoreGuid ), true ))
2009-03-04 20:51:40 +01:00
ignoreResult = FRIEND_IGNORE_FULL ;
}
2008-11-05 20:10:19 -06:00
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-12-22 21:25:23 +01:00
sSocialMgr -> SendFriendStatus ( GetPlayer (), ignoreResult , GUID_LOPART ( IgnoreGuid ), false );
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Sent (SMSG_FRIEND_STATUS)" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleDelIgnoreOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
uint64 IgnoreGUID ;
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_DEL_IGNORE" );
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> IgnoreGUID ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
_player -> GetSocial () -> RemoveFromSocialList ( GUID_LOPART ( IgnoreGUID ), true );
2009-10-17 15:51:44 -07:00
2010-12-22 21:25:23 +01:00
sSocialMgr -> SendFriendStatus ( GetPlayer (), FRIEND_IGNORE_REMOVED , GUID_LOPART ( IgnoreGUID ), false );
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleSetContactNotesOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "CMSG_SET_CONTACT_NOTES" );
2008-10-11 14:16:25 -05:00
uint64 guid ;
std :: string note ;
2012-10-24 13:29:34 +02:00
recvData >> guid >> note ;
2010-08-30 23:07:14 +02:00
_player -> GetSocial () -> SetFriendNote ( GUID_LOPART ( guid ), note );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleBugOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2009-12-17 14:06:20 +01:00
uint32 suggestion , contentlen , typelen ;
std :: string content , type ;
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> suggestion >> contentlen >> content ;
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> typelen >> type ;
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
if ( suggestion == 0 )
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_BUG [Bug Report]" );
2008-10-11 14:16:25 -05:00
else
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_BUG [Suggestion]" );
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "%s" , type . c_str ());
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "%s" , content . c_str ());
2009-10-17 15:51:44 -07:00
2012-01-01 01:09:38 +01:00
PreparedStatement * stmt = CharacterDatabase . GetPreparedStatement ( CHAR_INS_BUG_REPORT );
2011-12-25 18:12:58 +01:00
stmt -> setString ( 0 , type );
stmt -> setString ( 1 , content );
CharacterDatabase . Execute ( stmt );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleReclaimCorpseOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_RECLAIM_CORPSE" );
2010-04-11 11:16:42 +04:00
uint64 guid ;
2012-10-24 13:29:34 +02:00
recvData >> guid ;
2010-04-11 11:16:42 +04:00
2008-10-11 14:16:25 -05:00
if ( GetPlayer () -> isAlive ())
return ;
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
// do not allow corpse reclaim in arena
if ( GetPlayer () -> InArena ())
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// body not released yet
2010-04-07 19:14:10 +02:00
if ( ! GetPlayer () -> HasFlag ( PLAYER_FLAGS , PLAYER_FLAGS_GHOST ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
Corpse * corpse = GetPlayer () -> GetCorpse ();
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
if ( ! corpse )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// prevent resurrect before 30-sec delay after body release not finished
2010-08-30 15:25:15 +02:00
if ( time_t ( corpse -> GetGhostTime () + GetPlayer () -> GetCorpseReclaimDelay ( corpse -> GetType () == CORPSE_RESURRECTABLE_PVP )) > time_t ( time ( NULL )))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-12-17 19:09:40 +01:00
if ( ! corpse -> IsWithinDistInMap ( GetPlayer (), CORPSE_RECLAIM_RADIUS , true ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// resurrect
2010-08-08 04:37:24 +02:00
GetPlayer () -> ResurrectPlayer ( GetPlayer () -> InBattleground () ? 1.0f : 0.5f );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// spawn bones
GetPlayer () -> SpawnCorpseBones ();
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleResurrectResponseOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_RESURRECT_RESPONSE" );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint64 guid ;
uint8 status ;
2012-10-24 13:29:34 +02:00
recvData >> guid ;
recvData >> status ;
2009-10-17 15:51:44 -07:00
2010-04-11 20:20:38 +02:00
if ( GetPlayer () -> isAlive ())
return ;
2010-04-11 11:16:42 +04:00
2010-04-07 19:14:10 +02:00
if ( status == 0 )
2008-10-11 14:16:25 -05:00
{
GetPlayer () -> clearResurrectRequestData (); // reject
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! GetPlayer () -> isRessurectRequestedBy ( guid ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
GetPlayer () -> ResurectUsingRequestData ();
}
2009-10-17 15:51:44 -07:00
2010-01-15 19:50:27 +01:00
void WorldSession :: SendAreaTriggerMessage ( const char * Text , ...)
{
va_list ap ;
char szStr [ 1024 ];
szStr [ 0 ] = '\0' ;
va_start ( ap , Text );
2010-04-07 22:59:46 +02:00
vsnprintf ( szStr , 1024 , Text , ap );
2010-01-15 19:50:27 +01:00
va_end ( ap );
uint32 length = strlen ( szStr ) + 1 ;
WorldPacket data ( SMSG_AREA_TRIGGER_MESSAGE , 4 + length );
data << length ;
data << szStr ;
SendPacket ( & data );
}
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleAreaTriggerOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-09-16 10:53:24 +02:00
uint32 triggerId ;
2012-10-24 13:29:34 +02:00
recvData >> triggerId ;
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "CMSG_AREATRIGGER. Trigger ID: %u" , triggerId );
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
Player * player = GetPlayer ();
if ( player -> isInFlight ())
2008-10-11 14:16:25 -05:00
{
2012-02-27 14:58:47 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u" ,
2012-10-24 13:29:34 +02:00
player -> GetName (). c_str (), player -> GetGUIDLow (), triggerId );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
AreaTriggerEntry const * atEntry = sAreaTriggerStore . LookupEntry ( triggerId );
2010-04-07 19:14:10 +02:00
if ( ! atEntry )
2008-10-11 14:16:25 -05:00
{
2012-02-27 14:58:47 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u" ,
2012-10-24 13:29:34 +02:00
player -> GetName (). c_str (), player -> GetGUIDLow (), triggerId );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
if ( player -> GetMapId () != atEntry -> mapid )
2008-10-11 14:16:25 -05:00
{
2012-02-27 14:58:47 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u" ,
2012-10-24 13:29:34 +02:00
player -> GetName (). c_str (), atEntry -> mapid , player -> GetMapId (), player -> GetGUIDLow (), triggerId );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// delta is safe radius
const float delta = 5.0f ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
if ( atEntry -> radius > 0 )
{
// if we have radius check it
2011-09-16 10:53:24 +02:00
float dist = player -> GetDistance ( atEntry -> x , atEntry -> y , atEntry -> z );
2010-04-07 19:14:10 +02:00
if ( dist > atEntry -> radius + delta )
2008-10-11 14:16:25 -05:00
{
2012-02-27 14:58:47 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u" ,
2012-10-24 13:29:34 +02:00
player -> GetName (). c_str (), player -> GetGUIDLow (), atEntry -> radius , dist , triggerId );
2008-10-11 14:16:25 -05:00
return ;
}
}
else
{
// we have only extent
2009-10-17 15:51:44 -07:00
2009-08-19 16:58:26 -05:00
// rotate the players position instead of rotating the whole cube, that way we can make a simplified
// is-in-cube check and we have to calculate only one point instead of 4
2009-10-17 15:51:44 -07:00
2009-08-19 16:58:26 -05:00
// 2PI = 360°, keep in mind that ingame orientation is counter-clockwise
2011-09-16 10:53:24 +02:00
double rotation = 2 * M_PI - atEntry -> box_orientation ;
2012-10-02 15:06:19 +02:00
double sinVal = std :: sin ( rotation );
double cosVal = std :: cos ( rotation );
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
float playerBoxDistX = player -> GetPositionX () - atEntry -> x ;
float playerBoxDistY = player -> GetPositionY () - atEntry -> y ;
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
float rotPlayerX = float ( atEntry -> x + playerBoxDistX * cosVal - playerBoxDistY * sinVal );
float rotPlayerY = float ( atEntry -> y + playerBoxDistY * cosVal + playerBoxDistX * sinVal );
2009-10-17 15:51:44 -07:00
2009-08-19 16:58:26 -05:00
// box edges are parallel to coordiante axis, so we can treat every dimension independently :D
2011-09-16 10:53:24 +02:00
float dz = player -> GetPositionZ () - atEntry -> z ;
2009-08-19 16:58:26 -05:00
float dx = rotPlayerX - atEntry -> x ;
float dy = rotPlayerY - atEntry -> y ;
2011-09-16 10:53:24 +02:00
if (( fabs ( dx ) > atEntry -> box_x / 2 + delta ) ||
( fabs ( dy ) > atEntry -> box_y / 2 + delta ) ||
( fabs ( dz ) > atEntry -> box_z / 2 + delta ))
2008-10-11 14:16:25 -05:00
{
2012-02-27 14:58:47 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (1/2 box X: %f 1/2 box Y: %f 1/2 box Z: %f rotatedPlayerX: %f rotatedPlayerY: %f dZ:%f), ignore Area Trigger ID: %u" ,
2012-10-24 13:29:34 +02:00
player -> GetName (). c_str (), player -> GetGUIDLow (), atEntry -> box_x / 2 , atEntry -> box_y / 2 , atEntry -> box_z / 2 , rotPlayerX , rotPlayerY , dz , triggerId );
2008-10-11 14:16:25 -05:00
return ;
}
}
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
if ( player -> isDebugAreaTriggers )
2012-11-17 05:18:37 +01:00
ChatHandler ( player -> GetSession ()). PSendSysMessage ( LANG_DEBUG_AREATRIGGER_REACHED , triggerId );
2010-10-01 00:07:14 +02:00
2011-09-16 10:53:24 +02:00
if ( sScriptMgr -> OnAreaTrigger ( player , atEntry ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
if ( player -> isAlive ())
if ( uint32 questId = sObjectMgr -> GetQuestForAreaTrigger ( triggerId ))
if ( player -> GetQuestStatus ( questId ) == QUEST_STATUS_INCOMPLETE )
player -> AreaExploredOrEventHappens ( questId );
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
if ( sObjectMgr -> IsTavernAreaTrigger ( triggerId ))
2008-10-11 14:16:25 -05:00
{
// set resting flag we are in the inn
2011-09-16 10:53:24 +02:00
player -> SetFlag ( PLAYER_FLAGS , PLAYER_FLAGS_RESTING );
player -> InnEnter ( time ( NULL ), atEntry -> mapid , atEntry -> x , atEntry -> y , atEntry -> z );
player -> SetRestType ( REST_TYPE_IN_TAVERN );
2009-10-17 15:51:44 -07:00
2010-12-23 23:25:44 +01:00
if ( sWorld -> IsFFAPvPRealm ())
2011-09-16 10:53:24 +02:00
player -> RemoveByteFlag ( UNIT_FIELD_BYTES_2 , 1 , UNIT_BYTE2_FLAG_FFA_PVP );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
if ( Battleground * bg = player -> GetBattleground ())
if ( bg -> GetStatus () == STATUS_IN_PROGRESS )
{
bg -> HandleAreaTrigger ( player , triggerId );
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
if ( OutdoorPvP * pvp = player -> GetOutdoorPvP ())
if ( pvp -> HandleAreaTrigger ( _player , triggerId ))
2008-10-14 11:57:03 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-16 10:53:24 +02:00
AreaTrigger const * at = sObjectMgr -> GetAreaTrigger ( triggerId );
2010-04-07 19:14:10 +02:00
if ( ! at )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-14 10:16:14 +02:00
bool teleported = false ;
2011-09-16 10:53:24 +02:00
if ( player -> GetMapId () != at -> target_mapId )
{
if ( ! sMapMgr -> CanPlayerEnter ( at -> target_mapId , player , false ))
return ;
if ( Group * group = player -> GetGroup ())
if ( group -> isLFGGroup () && player -> GetMap () -> IsDungeon ())
teleported = player -> TeleportToBGEntryPoint ();
}
2011-09-14 10:16:14 +02:00
if ( ! teleported )
2011-09-16 10:53:24 +02:00
player -> TeleportTo ( at -> target_mapId , at -> target_X , at -> target_Y , at -> target_Z , at -> target_Orientation , TELE_TO_NOT_LEAVE_TRANSPORT );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleUpdateAccountData ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_UPDATE_ACCOUNT_DATA" );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
uint32 type , timestamp , decompressedSize ;
2012-10-24 13:29:34 +02:00
recvData >> type >> timestamp >> decompressedSize ;
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "UAD: type %u, time %u, decompressedSize %u" , type , timestamp , decompressedSize );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( type > NUM_ACCOUNT_DATA_TYPES )
2008-12-24 09:58:26 -06:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( decompressedSize == 0 ) // erase
2008-12-24 09:58:26 -06:00
{
2009-09-01 16:47:49 -05:00
SetAccountData ( AccountDataType ( type ), 0 , "" );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
WorldPacket data ( SMSG_UPDATE_ACCOUNT_DATA_COMPLETE , 4 + 4 );
data << uint32 ( type );
data << uint32 ( 0 );
SendPacket ( & data );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( decompressedSize > 0xFFFF )
2008-12-24 09:58:26 -06:00
{
2012-10-24 13:29:34 +02:00
recvData . rfinish (); // unnneded warning spam in this case
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_NETWORKIO , "UAD: Account data packet too big, size %u" , decompressedSize );
2008-12-24 09:58:26 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
ByteBuffer dest ;
dest . resize ( decompressedSize );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
uLongf realSize = decompressedSize ;
2013-01-30 08:39:06 +01:00
if ( uncompress ( dest . contents (), & realSize , recvData . contents () + recvData . rpos (), recvData . size () - recvData . rpos ()) != Z_OK )
2008-12-24 09:58:26 -06:00
{
2012-10-24 13:29:34 +02:00
recvData . rfinish (); // unnneded warning spam in this case
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_NETWORKIO , "UAD: Failed to decompress account data" );
2008-12-24 09:58:26 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData . rfinish (); // uncompress read (recvData.size() - recvData.rpos())
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
std :: string adata ;
dest >> adata ;
2009-10-17 15:51:44 -07:00
2009-09-01 16:47:49 -05:00
SetAccountData ( AccountDataType ( type ), timestamp , adata );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
WorldPacket data ( SMSG_UPDATE_ACCOUNT_DATA_COMPLETE , 4 + 4 );
data << uint32 ( type );
data << uint32 ( 0 );
SendPacket ( & data );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleRequestAccountData ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_REQUEST_ACCOUNT_DATA" );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
uint32 type ;
2012-10-24 13:29:34 +02:00
recvData >> type ;
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "RAD: type %u" , type );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( type > NUM_ACCOUNT_DATA_TYPES )
2008-12-24 09:58:26 -06:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
AccountData * adata = GetAccountData ( AccountDataType ( type ));
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
uint32 size = adata -> Data . size ();
2009-10-17 15:51:44 -07:00
2009-07-30 10:39:53 +08:00
uLongf destSize = compressBound ( size );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
ByteBuffer dest ;
2009-07-30 10:39:53 +08:00
dest . resize ( destSize );
2009-10-17 15:51:44 -07:00
2013-01-30 08:39:06 +01:00
if ( size && compress ( dest . contents (), & destSize , ( uint8 const * ) adata -> Data . c_str (), size ) != Z_OK )
2008-12-24 09:58:26 -06:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "RAD: Failed to compress account data" );
2008-12-24 09:58:26 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
dest . resize ( destSize );
2009-10-17 15:51:44 -07:00
2009-12-17 14:06:20 +01:00
WorldPacket data ( SMSG_UPDATE_ACCOUNT_DATA , 8 + 4 + 4 + 4 + destSize );
data << uint64 ( _player ? _player -> GetGUID () : 0 ); // player guid
2008-12-24 09:58:26 -06:00
data << uint32 ( type ); // type (0-7)
data << uint32 ( adata -> Time ); // unix time
data << uint32 ( size ); // decompressed length
data . append ( dest ); // compressed data
SendPacket ( & data );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleSetActionButtonOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2009-07-01 18:07:20 -05:00
uint8 button ;
uint32 packetData ;
2012-10-24 13:29:34 +02:00
recvData >> button >> packetData ;
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "CMSG_SET_ACTION_BUTTON Button: %u Data: %u" , button , packetData );
2009-10-17 15:51:44 -07:00
2009-07-01 18:07:20 -05:00
if ( ! packetData )
2010-04-28 22:35:55 +02:00
GetPlayer () -> removeActionButton ( button );
2008-10-11 14:16:25 -05:00
else
2012-10-24 13:29:34 +02:00
GetPlayer () -> addActionButton ( button , ACTION_BUTTON_ACTION ( packetData ), ACTION_BUTTON_TYPE ( packetData ));
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleCompleteCinematic ( WorldPacket & /*recvData*/ )
2008-10-11 14:16:25 -05:00
{
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_COMPLETE_CINEMATIC" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleNextCinematicCamera ( WorldPacket & /*recvData*/ )
2008-10-11 14:16:25 -05:00
{
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_NEXT_CINEMATIC_CAMERA" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleMoveTimeSkippedOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2010-04-07 22:59:46 +02:00
/* WorldSession::Update(getMSTime());*/
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_MOVE_TIME_SKIPPED" );
2009-10-17 15:51:44 -07:00
2009-12-17 14:06:20 +01:00
uint64 guid ;
2012-10-24 13:29:34 +02:00
recvData . readPackGUID ( guid );
recvData . read_skip < uint32 > ();
2008-10-11 14:16:25 -05:00
/*
uint64 guid;
uint32 time_skipped;
2012-10-24 13:29:34 +02:00
recvData >> guid;
recvData >> time_skipped;
2011-02-20 20:16:34 +01:00
sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_MOVE_TIME_SKIPPED");
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// TODO
2008-10-14 11:57:03 -05:00
must be need use in Trinity
2010-04-07 22:59:46 +02:00
We substract server Lags to move time (AntiLags)
2008-10-11 14:16:25 -05:00
for exmaple
2010-04-07 22:59:46 +02:00
GetPlayer()->ModifyLastMoveTime(-int32(time_skipped));
2008-10-11 14:16:25 -05:00
*/
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleFeatherFallAck ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_MOVE_FEATHER_FALL_ACK" );
2009-12-25 16:23:01 +01:00
// no used
2012-10-24 13:29:34 +02:00
recvData . rfinish (); // prevent warnings spam
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleMoveUnRootAck ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2009-08-19 17:19:50 -05:00
// no used
2012-10-24 13:29:34 +02:00
recvData . rfinish (); // prevent warnings spam
2009-08-19 17:19:50 -05:00
/*
uint64 guid;
2012-10-24 13:29:34 +02:00
recvData >> guid;
2009-10-17 15:51:44 -07:00
2009-08-19 17:19:50 -05:00
// now can skip not our packet
2010-04-07 19:14:10 +02:00
if (_player->GetGUID() != guid)
2009-08-19 17:19:50 -05:00
{
2012-10-24 13:29:34 +02:00
recvData.rfinish(); // prevent warnings spam
2009-08-19 17:19:50 -05:00
return;
}
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK");
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData.read_skip<uint32>(); // unk
2009-10-17 15:51:44 -07:00
2009-08-19 17:19:50 -05:00
MovementInfo movementInfo;
2010-02-14 19:13:14 -07:00
movementInfo.guid = guid;
2012-10-24 13:29:34 +02:00
ReadMovementInfo(recvData, &movementInfo);
recvData.read_skip<float>(); // unk2
2009-08-19 17:19:50 -05:00
*/
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleMoveRootAck ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2009-08-19 17:19:50 -05:00
// no used
2012-10-24 13:29:34 +02:00
recvData . rfinish (); // prevent warnings spam
2009-08-19 17:19:50 -05:00
/*
uint64 guid;
2012-10-24 13:29:34 +02:00
recvData >> guid;
2009-10-17 15:51:44 -07:00
2009-08-19 17:19:50 -05:00
// now can skip not our packet
2010-04-07 19:14:10 +02:00
if (_player->GetGUID() != guid)
2009-08-19 17:19:50 -05:00
{
2012-10-24 13:29:34 +02:00
recvData.rfinish(); // prevent warnings spam
2009-08-19 17:19:50 -05:00
return;
}
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_FORCE_MOVE_ROOT_ACK");
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData.read_skip<uint32>(); // unk
2009-10-17 15:51:44 -07:00
2009-08-19 17:19:50 -05:00
MovementInfo movementInfo;
2012-10-24 13:29:34 +02:00
ReadMovementInfo(recvData, &movementInfo);
2009-08-19 17:19:50 -05:00
*/
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleSetActionBarToggles ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2012-10-24 13:29:34 +02:00
uint8 actionBar ;
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> actionBar ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! GetPlayer ()) // ignore until not logged (check needed because STATUS_AUTHED)
2008-10-11 14:16:25 -05:00
{
2012-10-24 13:29:34 +02:00
if ( actionBar != 0 )
sLog -> outError ( LOG_FILTER_NETWORKIO , "WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored" , uint32 ( actionBar ));
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
GetPlayer () -> SetByteValue ( PLAYER_FIELD_BYTES , 2 , actionBar );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandlePlayedTime ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2009-07-31 11:33:48 +08:00
uint8 unk1 ;
2012-10-24 13:29:34 +02:00
recvData >> unk1 ; // 0 or 1 expected
2009-10-17 15:51:44 -07:00
2009-07-31 11:33:48 +08:00
WorldPacket data ( SMSG_PLAYED_TIME , 4 + 4 + 1 );
data << uint32 ( _player -> GetTotalPlayedTime ());
data << uint32 ( _player -> GetLevelPlayedTime ());
data << uint8 ( unk1 ); // 0 - will not show in chat frame
2008-10-11 14:16:25 -05:00
SendPacket ( & data );
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleInspectOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
uint64 guid ;
2012-10-24 13:29:34 +02:00
recvData >> guid ;
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_INSPECT" );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
_player -> SetSelection ( guid );
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
Player * player = ObjectAccessor :: FindPlayer ( guid );
2012-06-03 05:41:30 +02:00
if ( ! player )
{
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "CMSG_INSPECT: No player found from GUID: " UI64FMTD , guid );
2008-10-11 14:16:25 -05:00
return ;
2012-06-03 05:41:30 +02:00
}
2009-10-17 15:51:44 -07:00
2009-08-22 13:15:46 +02:00
uint32 talent_points = 0x47 ;
2011-11-07 11:06:39 -06:00
uint32 guid_size = player -> GetPackGUID (). wpos ();
2009-10-17 16:20:24 -07:00
WorldPacket data ( SMSG_INSPECT_TALENT , guid_size + 4 + talent_points );
2011-11-07 11:06:39 -06:00
data . append ( player -> GetPackGUID ());
2009-10-17 15:51:44 -07:00
2010-12-23 23:25:44 +01:00
if ( sWorld -> getBoolConfig ( CONFIG_TALENTS_INSPECTING ) || _player -> isGameMaster ())
2011-11-07 11:06:39 -06:00
player -> BuildPlayerTalentsInfoData ( & data );
2009-06-11 00:45:59 -05:00
else
{
data << uint32 ( 0 ); // unspentTalentPoints
data << uint8 ( 0 ); // talentGroupCount
data << uint8 ( 0 ); // talentGroupIndex
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
player -> BuildEnchantmentsInfoData ( & data );
2008-10-11 14:16:25 -05:00
SendPacket ( & data );
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleInspectHonorStatsOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
uint64 guid ;
2012-10-24 13:29:34 +02:00
recvData >> guid ;
2009-10-17 15:51:44 -07:00
2011-07-27 12:14:27 +02:00
Player * player = ObjectAccessor :: FindPlayer ( guid );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! player )
2008-10-11 14:16:25 -05:00
{
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "MSG_INSPECT_HONOR_STATS: No player found from GUID: " UI64FMTD , guid );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
WorldPacket data ( MSG_INSPECT_HONOR_STATS , 8 + 1 + 4 * 4 );
data << uint64 ( player -> GetGUID ());
2010-08-10 13:26:07 +02:00
data << uint8 ( player -> GetHonorPoints ());
2008-10-11 14:16:25 -05:00
data << uint32 ( player -> GetUInt32Value ( PLAYER_FIELD_KILLS ));
data << uint32 ( player -> GetUInt32Value ( PLAYER_FIELD_TODAY_CONTRIBUTION ));
data << uint32 ( player -> GetUInt32Value ( PLAYER_FIELD_YESTERDAY_CONTRIBUTION ));
2009-09-04 19:50:00 -04:00
data << uint32 ( player -> GetUInt32Value ( PLAYER_FIELD_LIFETIME_HONORABLE_KILLS ));
2008-10-11 14:16:25 -05:00
SendPacket ( & data );
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleWorldTeleportOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
uint32 time ;
uint32 mapid ;
float PositionX ;
float PositionY ;
float PositionZ ;
float Orientation ;
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData >> time ; // time in m.sec.
recvData >> mapid ;
recvData >> PositionX ;
recvData >> PositionY ;
recvData >> PositionZ ;
recvData >> Orientation ; // o (3.141593 = 180 degrees)
2009-12-19 18:54:46 +01:00
2012-06-03 05:41:30 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_WORLD_TELEPORT" );
2010-04-07 19:14:10 +02:00
if ( GetPlayer () -> isInFlight ())
2009-12-19 18:54:46 +01:00
{
2012-10-24 13:29:34 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Player '%s' (GUID: %u) in flight, ignore worldport command." ,
GetPlayer () -> GetName (). c_str (), GetPlayer () -> GetGUIDLow ());
2009-12-19 18:54:46 +01:00
return ;
}
2012-10-24 13:29:34 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "CMSG_WORLD_TELEPORT: Player = %s, Time = %u, map = %u, x = %f, y = %f, z = %f, o = %f" ,
GetPlayer () -> GetName (). c_str (), time , mapid , PositionX , PositionY , PositionZ , Orientation );
2009-10-17 15:51:44 -07:00
2013-02-25 12:55:37 +01:00
if ( HasPermission ( RBAC_PERM_OPCODE_WORLD_TELEPORT ))
2011-04-29 20:47:02 +02:00
GetPlayer () -> TeleportTo ( mapid , PositionX , PositionY , PositionZ , Orientation );
2008-10-11 14:16:25 -05:00
else
SendNotification ( LANG_YOU_NOT_HAVE_PERMISSION );
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleWhoisOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Received opcode CMSG_WHOIS" );
2008-10-11 14:16:25 -05:00
std :: string charname ;
2012-10-24 13:29:34 +02:00
recvData >> charname ;
2009-10-17 15:51:44 -07:00
2013-02-25 12:55:37 +01:00
if ( HasPermission ( RBAC_PERM_OPCODE_WHOIS ))
2008-10-11 14:16:25 -05:00
{
SendNotification ( LANG_YOU_NOT_HAVE_PERMISSION );
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( charname . empty () || ! normalizePlayerName ( charname ))
2008-10-11 14:16:25 -05:00
{
SendNotification ( LANG_NEED_CHARACTER_NAME );
return ;
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
Player * player = sObjectAccessor -> FindPlayerByName ( charname );
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
if ( ! player )
2008-10-11 14:16:25 -05:00
{
SendNotification ( LANG_PLAYER_NOT_EXIST_OR_OFFLINE , charname . c_str ());
return ;
}
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
uint32 accid = player -> GetSession () -> GetAccountId ();
2009-10-17 15:51:44 -07:00
2012-03-24 01:25:08 +01:00
PreparedStatement * stmt = LoginDatabase . GetPreparedStatement ( LOGIN_SEL_ACCOUNT_WHOIS );
stmt -> setUInt32 ( 0 , accid );
PreparedQueryResult result = LoginDatabase . Query ( stmt );
2010-04-07 19:14:10 +02:00
if ( ! result )
2008-10-11 14:16:25 -05:00
{
SendNotification ( LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND , charname . c_str ());
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
Field * fields = result -> Fetch ();
2010-09-24 22:16:21 +02:00
std :: string acc = fields [ 0 ]. GetString ();
2010-04-07 19:14:10 +02:00
if ( acc . empty ())
2008-10-11 14:16:25 -05:00
acc = "Unknown" ;
2010-09-24 22:16:21 +02:00
std :: string email = fields [ 1 ]. GetString ();
2010-04-07 19:14:10 +02:00
if ( email . empty ())
2008-10-11 14:16:25 -05:00
email = "Unknown" ;
2010-09-24 22:16:21 +02:00
std :: string lastip = fields [ 2 ]. GetString ();
2010-04-07 19:14:10 +02:00
if ( lastip . empty ())
2008-10-11 14:16:25 -05:00
lastip = "Unknown" ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
std :: string msg = charname + "'s " + "account is " + acc + ", e-mail: " + email + ", last ip: " + lastip ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
WorldPacket data ( SMSG_WHOIS , msg . size () + 1 );
data << msg ;
2012-02-27 14:58:47 +01:00
SendPacket ( & data );
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Received whois command from player %s for character %s" ,
GetPlayer () -> GetName (). c_str (), charname . c_str ());
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleComplainOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_COMPLAIN" );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint8 spam_type ; // 0 - mail, 1 - chat
uint64 spammer_guid ;
2009-04-27 18:42:35 -05:00
uint32 unk1 = 0 ;
uint32 unk2 = 0 ;
uint32 unk3 = 0 ;
uint32 unk4 = 0 ;
2008-10-11 14:16:25 -05:00
std :: string description = "" ;
2012-10-24 13:29:34 +02:00
recvData >> spam_type ; // unk 0x01 const, may be spam type (mail/chat)
recvData >> spammer_guid ; // player guid
2011-09-29 12:43:05 +02:00
switch ( spam_type )
2008-10-11 14:16:25 -05:00
{
case 0 :
2012-10-24 13:29:34 +02:00
recvData >> unk1 ; // const 0
recvData >> unk2 ; // probably mail id
recvData >> unk3 ; // const 0
2008-10-11 14:16:25 -05:00
break ;
case 1 :
2012-10-24 13:29:34 +02:00
recvData >> unk1 ; // probably language
recvData >> unk2 ; // message type?
recvData >> unk3 ; // probably channel id
2013-01-17 17:35:47 +01:00
recvData >> unk4 ; // time
2012-10-24 13:29:34 +02:00
recvData >> description ; // spam description string (messagetype, channel name, player name, message)
2008-10-11 14:16:25 -05:00
break ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// NOTE: all chat messages from this spammer automatically ignored by spam reporter until logout in case chat spam.
// if it's mail spam - ALL mails from this spammer automatically removed by client
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Complaint Received message
WorldPacket data ( SMSG_COMPLAIN_RESULT , 1 );
data << uint8 ( 0 );
SendPacket ( & data );
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "REPORT SPAM: type %u, guid %u, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s" , spam_type , GUID_LOPART ( spammer_guid ), unk1 , unk2 , unk3 , unk4 , description . c_str ());
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleRealmSplitOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "CMSG_REALM_SPLIT" );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 unk ;
std :: string split_date = "01/01/01" ;
2012-10-24 13:29:34 +02:00
recvData >> unk ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
WorldPacket data ( SMSG_REALM_SPLIT , 4 + 4 + split_date . size () + 1 );
data << unk ;
data << uint32 ( 0x00000000 ); // realm split state
// split states:
// 0x0 realm normal
// 0x1 realm split
// 0x2 realm split pending
data << split_date ;
SendPacket ( & data );
2010-12-23 23:25:44 +01:00
//sLog->outDebug("response sent %u", unk);
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleFarSightOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_FAR_SIGHT" );
2009-10-17 15:51:44 -07:00
2012-11-15 13:42:24 +01:00
bool apply ;
2012-10-24 13:29:34 +02:00
recvData >> apply ;
2009-10-17 15:51:44 -07:00
2012-11-15 13:42:24 +01:00
if ( apply )
2008-10-11 14:16:25 -05:00
{
2012-11-15 13:42:24 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Added FarSight " UI64FMTD " to player %u" , _player -> GetUInt64Value ( PLAYER_FARSIGHT ), _player -> GetGUIDLow ());
if ( WorldObject * target = _player -> GetViewpoint ())
_player -> SetSeer ( target );
else
sLog -> outError ( LOG_FILTER_NETWORKIO , "Player %s requests non-existing seer " UI64FMTD , _player -> GetName (). c_str (), _player -> GetUInt64Value ( PLAYER_FARSIGHT ));
}
else
{
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Player %u set vision to self" , _player -> GetGUIDLow ());
_player -> SetSeer ( _player );
2008-10-11 14:16:25 -05:00
}
2010-02-27 15:25:14 +02:00
GetPlayer () -> UpdateVisibilityForPlayer ();
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleSetTitleOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "CMSG_SET_TITLE" );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
int32 title ;
2012-10-24 13:29:34 +02:00
recvData >> title ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// -1 at none
2010-04-07 19:14:10 +02:00
if ( title > 0 && title < MAX_TITLE_INDEX )
2008-10-11 14:16:25 -05:00
{
2010-04-07 19:14:10 +02:00
if ( ! GetPlayer () -> HasTitle ( title ))
2008-10-11 14:16:25 -05:00
return ;
}
else
title = 0 ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
GetPlayer () -> SetUInt32Value ( PLAYER_CHOSEN_TITLE , title );
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleTimeSyncResp ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "CMSG_TIME_SYNC_RESP" );
2009-10-17 15:51:44 -07:00
2010-04-11 20:20:38 +02:00
uint32 counter , clientTicks ;
2012-10-24 13:29:34 +02:00
recvData >> counter >> clientTicks ;
2010-04-11 11:11:32 +04:00
2010-04-11 20:20:38 +02:00
if ( counter != _player -> m_timeSyncCounter - 1 )
2012-10-24 13:29:34 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Wrong time sync counter from player %s (cheater?)" , _player -> GetName (). c_str ());
2010-04-11 11:11:32 +04:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Time sync received: counter %u, client ticks %u, time since last sync %u" , counter , clientTicks , clientTicks - _player -> m_timeSyncClient );
2010-04-11 20:20:38 +02:00
uint32 ourTicks = clientTicks + ( getMSTime () - _player -> m_timeSyncServer );
// diff should be small
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Our ticks: %u, diff %u, latency %u" , ourTicks , ourTicks - clientTicks , GetLatency ());
2010-04-11 20:20:38 +02:00
2010-04-11 11:11:32 +04:00
_player -> m_timeSyncClient = clientTicks ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleResetInstancesOpcode ( WorldPacket & /*recvData*/ )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_RESET_INSTANCES" );
2012-02-10 12:51:56 +01:00
if ( Group * group = _player -> GetGroup ())
2008-10-11 14:16:25 -05:00
{
2011-10-07 10:54:53 -05:00
if ( group -> IsLeader ( _player -> GetGUID ()))
group -> ResetInstances ( INSTANCE_RESET_ALL , false , _player );
2008-10-11 14:16:25 -05:00
}
else
2009-12-17 14:06:20 +01:00
_player -> ResetInstances ( INSTANCE_RESET_ALL , false );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleSetDungeonDifficultyOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "MSG_SET_DUNGEON_DIFFICULTY" );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 mode ;
2012-10-24 13:29:34 +02:00
recvData >> mode ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( mode >= MAX_DUNGEON_DIFFICULTY )
2008-10-11 14:16:25 -05:00
{
2012-11-15 13:42:24 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!" , _player -> GetGUIDLow (), mode );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( Difficulty ( mode ) == _player -> GetDungeonDifficulty ())
2009-12-17 14:06:20 +01:00
return ;
2008-10-11 14:16:25 -05:00
// cannot reset while in an instance
2012-02-10 12:51:56 +01:00
Map * map = _player -> FindMap ();
2010-04-07 19:14:10 +02:00
if ( map && map -> IsDungeon ())
2008-10-11 14:16:25 -05:00
{
2012-11-15 13:42:24 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, GUID: %u) tried to reset the instance while player is inside!" ,
2012-10-24 13:29:34 +02:00
_player -> GetName (). c_str (), _player -> GetGUIDLow ());
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-10-07 10:54:53 -05:00
Group * group = _player -> GetGroup ();
if ( group )
2008-10-11 14:16:25 -05:00
{
2011-10-07 10:54:53 -05:00
if ( group -> IsLeader ( _player -> GetGUID ()))
2008-10-11 14:16:25 -05:00
{
2011-10-07 10:54:53 -05:00
for ( GroupReference * itr = group -> GetFirstMember (); itr != NULL ; itr = itr -> next ())
2010-02-14 19:13:14 -07:00
{
2012-02-27 14:58:47 +01:00
Player * groupGuy = itr -> getSource ();
if ( ! groupGuy )
2010-02-14 19:13:14 -07:00
continue ;
2012-02-27 14:58:47 +01:00
if ( ! groupGuy -> IsInMap ( groupGuy ))
2010-02-14 19:13:14 -07:00
return ;
2012-02-27 14:58:47 +01:00
if ( groupGuy -> GetMap () -> IsNonRaidDungeon ())
2010-02-14 19:13:14 -07:00
{
2012-11-15 13:42:24 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!" ,
2012-10-24 13:29:34 +02:00
_player -> GetGUIDLow (), groupGuy -> GetName (). c_str (), groupGuy -> GetGUIDLow ());
2010-02-14 19:13:14 -07:00
return ;
}
}
2008-10-11 14:16:25 -05:00
// the difficulty is set even if the instances can't be reset
//_player->SendDungeonDifficulty(true);
2011-10-07 10:54:53 -05:00
group -> ResetInstances ( INSTANCE_RESET_CHANGE_DIFFICULTY , false , _player );
group -> SetDungeonDifficulty ( Difficulty ( mode ));
2008-10-11 14:16:25 -05:00
}
}
else
{
2009-12-17 14:06:20 +01:00
_player -> ResetInstances ( INSTANCE_RESET_CHANGE_DIFFICULTY , false );
_player -> SetDungeonDifficulty ( Difficulty ( mode ));
}
}
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleSetRaidDifficultyOpcode ( WorldPacket & recvData )
2009-12-17 14:06:20 +01:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "MSG_SET_RAID_DIFFICULTY" );
2009-12-17 14:06:20 +01:00
uint32 mode ;
2012-10-24 13:29:34 +02:00
recvData >> mode ;
2009-12-17 14:06:20 +01:00
2010-04-07 19:14:10 +02:00
if ( mode >= MAX_RAID_DIFFICULTY )
2009-12-17 14:06:20 +01:00
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_NETWORKIO , "WorldSession::HandleSetRaidDifficultyOpcode: player %d sent an invalid instance mode %d!" , _player -> GetGUIDLow (), mode );
2009-12-17 14:06:20 +01:00
return ;
}
// cannot reset while in an instance
2012-02-10 12:51:56 +01:00
Map * map = _player -> FindMap ();
2010-04-07 19:14:10 +02:00
if ( map && map -> IsDungeon ())
2009-12-17 14:06:20 +01:00
{
2012-11-15 13:42:24 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!" , _player -> GetGUIDLow ());
2009-12-17 14:06:20 +01:00
return ;
2008-10-11 14:16:25 -05:00
}
2009-12-17 14:06:20 +01:00
2010-04-07 19:14:10 +02:00
if ( Difficulty ( mode ) == _player -> GetRaidDifficulty ())
2009-12-17 14:06:20 +01:00
return ;
2011-10-07 10:54:53 -05:00
Group * group = _player -> GetGroup ();
if ( group )
2009-12-17 14:06:20 +01:00
{
2011-10-07 10:54:53 -05:00
if ( group -> IsLeader ( _player -> GetGUID ()))
2009-12-17 14:06:20 +01:00
{
2011-10-07 10:54:53 -05:00
for ( GroupReference * itr = group -> GetFirstMember (); itr != NULL ; itr = itr -> next ())
2010-02-14 19:13:14 -07:00
{
2012-02-27 14:58:47 +01:00
Player * groupGuy = itr -> getSource ();
if ( ! groupGuy )
2010-02-14 19:13:14 -07:00
continue ;
2012-02-27 14:58:47 +01:00
if ( ! groupGuy -> IsInMap ( groupGuy ))
2010-02-14 19:13:14 -07:00
return ;
2012-02-27 14:58:47 +01:00
if ( groupGuy -> GetMap () -> IsRaid ())
2010-02-14 19:13:14 -07:00
{
2012-11-15 13:42:24 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!" , _player -> GetGUIDLow ());
2010-02-14 19:13:14 -07:00
return ;
}
}
2009-12-17 14:06:20 +01:00
// the difficulty is set even if the instances can't be reset
//_player->SendDungeonDifficulty(true);
2011-10-07 10:54:53 -05:00
group -> ResetInstances ( INSTANCE_RESET_CHANGE_DIFFICULTY , true , _player );
group -> SetRaidDifficulty ( Difficulty ( mode ));
2009-12-17 14:06:20 +01:00
}
}
else
{
_player -> ResetInstances ( INSTANCE_RESET_CHANGE_DIFFICULTY , true );
_player -> SetRaidDifficulty ( Difficulty ( mode ));
2010-07-29 18:11:41 +02:00
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleCancelMountAuraOpcode ( WorldPacket & /*recvData*/ )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_CANCEL_MOUNT_AURA" );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
//If player is not mounted, so go out :)
if ( ! _player -> IsMounted ()) // not blizz like; no any messages on blizz
{
ChatHandler ( this ). SendSysMessage ( LANG_CHAR_NON_MOUNTED );
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( _player -> isInFlight ()) // not blizz like; no any messages on blizz
2008-10-11 14:16:25 -05:00
{
ChatHandler ( this ). SendSysMessage ( LANG_YOU_IN_FLIGHT );
return ;
}
2009-10-17 15:51:44 -07:00
2013-02-18 00:39:58 +01:00
_player -> RemoveAurasByType ( SPELL_AURA_MOUNTED ); // Calls Dismount()
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleMoveSetCanFlyAckOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
// fly mode on/off
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_MOVE_SET_CAN_FLY_ACK" );
2009-10-17 15:51:44 -07:00
2009-12-17 14:06:20 +01:00
uint64 guid ; // guid - unused
2012-10-24 13:29:34 +02:00
recvData . readPackGUID ( guid );
2010-08-08 20:32:14 +02:00
2012-10-24 13:29:34 +02:00
recvData . read_skip < uint32 > (); // unk
2009-10-17 15:51:44 -07:00
2009-08-27 19:51:14 -05:00
MovementInfo movementInfo ;
2010-02-14 19:13:14 -07:00
movementInfo . guid = guid ;
2012-10-24 13:29:34 +02:00
ReadMovementInfo ( recvData , & movementInfo );
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
recvData . read_skip < float > (); // unk2
2009-10-17 15:51:44 -07:00
2009-08-27 19:51:14 -05:00
_player -> m_mover -> m_movementInfo . flags = movementInfo . GetMovementFlags ();
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleRequestPetInfoOpcode ( WorldPacket & /*recvData */ )
2008-10-11 14:16:25 -05:00
{
/*
2011-02-20 20:16:34 +01:00
sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_REQUEST_PET_INFO");
2012-10-24 13:29:34 +02:00
recvData.hexlike();
2008-10-11 14:16:25 -05:00
*/
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleSetTaxiBenchmarkOpcode ( WorldPacket & recvData )
2008-10-11 14:16:25 -05:00
{
uint8 mode ;
2012-10-24 13:29:34 +02:00
recvData >> mode ;
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Client used \" /timetest %d \" command" , mode );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleQueryInspectAchievements ( WorldPacket & recvData )
2008-12-24 09:58:26 -06:00
{
uint64 guid ;
2012-10-24 13:29:34 +02:00
recvData . readPackGUID ( guid );
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "CMSG_QUERY_INSPECT_ACHIEVEMENTS [" UI64FMTD "] Inspected Player [" UI64FMTD "]" , _player -> GetGUID (), guid );
2011-07-27 12:14:27 +02:00
Player * player = ObjectAccessor :: FindPlayer ( guid );
2010-04-07 19:14:10 +02:00
if ( ! player )
2008-12-24 09:58:26 -06:00
return ;
2009-10-17 15:51:44 -07:00
2012-09-18 14:29:53 +02:00
player -> SendRespondInspectAchievements ( _player );
2009-02-18 22:39:00 +01:00
}
2009-12-17 14:06:20 +01:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleWorldStateUITimerUpdate ( WorldPacket & /*recvData*/ )
2009-12-17 14:06:20 +01:00
{
// empty opcode
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_WORLD_STATE_UI_TIMER_UPDATE" );
2009-12-17 14:06:20 +01:00
WorldPacket data ( SMSG_WORLD_STATE_UI_TIMER_UPDATE , 4 );
2009-12-24 10:20:15 +01:00
data << uint32 ( time ( NULL ));
2009-12-17 14:06:20 +01:00
SendPacket ( & data );
}
2010-01-15 19:50:27 +01:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleReadyForAccountDataTimes ( WorldPacket & /*recvData*/ )
2010-02-14 19:13:14 -07:00
{
// empty opcode
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_READY_FOR_ACCOUNT_DATA_TIMES" );
2010-02-14 19:13:14 -07:00
SendAccountDataTimes ( GLOBAL_CACHE_MASK );
}
2010-01-15 19:50:27 +01:00
void WorldSession :: SendSetPhaseShift ( uint32 PhaseShift )
{
WorldPacket data ( SMSG_SET_PHASE_SHIFT , 4 );
data << uint32 ( PhaseShift );
SendPacket ( & data );
}
2012-08-21 23:01:24 +02:00
// Battlefield and Battleground
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleAreaSpiritHealerQueryOpcode ( WorldPacket & recvData )
2012-08-21 23:01:24 +02:00
{
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_AREA_SPIRIT_HEALER_QUERY" );
Battleground * bg = _player -> GetBattleground ();
uint64 guid ;
2012-10-24 13:29:34 +02:00
recvData >> guid ;
2012-08-21 23:01:24 +02:00
Creature * unit = GetPlayer () -> GetMap () -> GetCreature ( guid );
if ( ! unit )
return ;
if ( ! unit -> isSpiritService ()) // it's not spirit service
return ;
if ( bg )
sBattlegroundMgr -> SendAreaSpiritHealerQueryOpcode ( _player , bg , guid );
if ( Battlefield * bf = sBattlefieldMgr -> GetBattlefieldToZoneId ( _player -> GetZoneId ()))
2013-01-14 09:50:59 +01:00
bf -> SendAreaSpiritHealerQueryOpcode ( _player , guid );
2012-08-21 23:01:24 +02:00
}
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleAreaSpiritHealerQueueOpcode ( WorldPacket & recvData )
2012-08-21 23:01:24 +02:00
{
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_AREA_SPIRIT_HEALER_QUEUE" );
Battleground * bg = _player -> GetBattleground ();
uint64 guid ;
2012-10-24 13:29:34 +02:00
recvData >> guid ;
2012-08-21 23:01:24 +02:00
Creature * unit = GetPlayer () -> GetMap () -> GetCreature ( guid );
if ( ! unit )
return ;
if ( ! unit -> isSpiritService ()) // it's not spirit service
return ;
if ( bg )
bg -> AddPlayerToResurrectQueue ( guid , _player -> GetGUID ());
if ( Battlefield * bf = sBattlefieldMgr -> GetBattlefieldToZoneId ( _player -> GetZoneId ()))
bf -> AddPlayerToResurrectQueue ( guid , _player -> GetGUID ());
}
2010-10-16 16:40:25 -07:00
2012-10-24 13:29:34 +02:00
void WorldSession :: HandleHearthAndResurrect ( WorldPacket & /*recvData*/ )
2010-10-16 16:40:25 -07:00
{
if ( _player -> isInFlight ())
return ;
2012-09-10 13:03:38 +02:00
if ( /*Battlefield* bf = */ sBattlefieldMgr -> GetBattlefieldToZoneId ( _player -> GetZoneId ()))
2012-03-02 22:00:26 -03:00
{
// bf->PlayerAskToLeave(_player); FIXME
return ;
}
2011-09-15 14:08:17 +02:00
AreaTableEntry const * atEntry = GetAreaEntryByAreaID ( _player -> GetAreaId ());
2011-05-27 00:58:18 +02:00
if ( ! atEntry || ! ( atEntry -> flags & AREA_FLAG_WINTERGRASP_2 ))
2010-10-16 16:40:25 -07:00
return ;
_player -> BuildPlayerRepop ();
_player -> ResurrectPlayer ( 100 );
_player -> TeleportTo ( _player -> m_homebindMapId , _player -> m_homebindX , _player -> m_homebindY , _player -> m_homebindZ , _player -> GetOrientation ());
}
2011-01-24 11:38:59 +01:00
void WorldSession :: HandleInstanceLockResponse ( WorldPacket & recvPacket )
{
uint8 accept ;
recvPacket >> accept ;
if ( ! _player -> HasPendingBind ())
{
2012-10-24 13:29:34 +02:00
sLog -> outInfo ( LOG_FILTER_NETWORKIO , "InstanceLockResponse: Player %s (guid %u) tried to bind himself/teleport to graveyard without a pending bind!" ,
_player -> GetName (). c_str (), _player -> GetGUIDLow ());
2011-01-24 11:38:59 +01:00
return ;
}
if ( accept )
_player -> BindToInstance ();
else
_player -> RepopAtGraveyard ();
2011-09-16 10:53:24 +02:00
_player -> SetPendingBind ( 0 , 0 );
2011-01-24 11:38:59 +01:00
}
2012-05-23 14:24:28 +02:00
void WorldSession :: HandleUpdateMissileTrajectory ( WorldPacket & recvPacket )
{
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: CMSG_UPDATE_MISSILE_TRAJECTORY" );
uint64 guid ;
uint32 spellId ;
float elevation , speed ;
float curX , curY , curZ ;
float targetX , targetY , targetZ ;
uint8 moveStop ;
recvPacket >> guid >> spellId >> elevation >> speed ;
recvPacket >> curX >> curY >> curZ ;
recvPacket >> targetX >> targetY >> targetZ ;
recvPacket >> moveStop ;
Unit * caster = ObjectAccessor :: GetUnit ( * _player , guid );
2012-05-23 16:37:22 +02:00
Spell * spell = caster ? caster -> GetCurrentSpell ( CURRENT_GENERIC_SPELL ) : NULL ;
if ( ! spell || spell -> m_spellInfo -> Id != spellId || ! spell -> m_targets . HasDst () || ! spell -> m_targets . HasSrc ())
2012-05-23 14:24:28 +02:00
{
recvPacket . rfinish ();
return ;
}
Position pos = * spell -> m_targets . GetSrcPos ();
pos . Relocate ( curX , curY , curZ );
spell -> m_targets . ModSrc ( pos );
pos = * spell -> m_targets . GetDstPos ();
pos . Relocate ( targetX , targetY , targetZ );
spell -> m_targets . ModDst ( pos );
spell -> m_targets . SetElevation ( elevation );
spell -> m_targets . SetSpeed ( speed );
if ( moveStop )
{
uint32 opcode ;
recvPacket >> opcode ;
recvPacket . SetOpcode ( opcode );
HandleMovementOpcodes ( recvPacket );
}
}