2010-10-07 15:35:36 +02:00
/*
2012-01-01 00:32:13 +01:00
* Copyright (C) 2008-2012 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-02 16:23:55 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#include "Common.h"
2010-06-08 17:01:03 -06:00
#include "DatabaseEnv.h"
2008-10-02 16:23:55 -05:00
#include "Opcodes.h"
#include "Log.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "World.h"
#include "ObjectMgr.h"
2011-05-05 10:23:00 +02:00
#include "GroupMgr.h"
2008-10-02 16:23:55 -05:00
#include "Player.h"
#include "Group.h"
#include "SocialMgr.h"
#include "Util.h"
2009-04-06 13:31:14 +02:00
#include "SpellAuras.h"
2010-01-13 11:16:38 +01:00
#include "Vehicle.h"
2009-10-17 15:51:44 -07:00
2009-04-06 13:31:14 +02:00
class Aura ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/* differeces from off:
-you can uninvite yourself - is is useful
-you can accept invitation even if leader went offline
*/
/* todo:
-group_destroyed msg is sent but not shown
-reduce xp gaining when in raid group
-quest sharing has to be corrected
-FIX sending PartyMemberStats
*/
2009-10-17 15:51:44 -07:00
2010-09-10 13:45:21 +02:00
void WorldSession :: SendPartyResult ( PartyOperation operation , const std :: string & member , PartyResult res , uint32 val /* = 0 */ )
2008-10-02 16:23:55 -05:00
{
2010-09-10 13:45:21 +02:00
WorldPacket data ( SMSG_PARTY_COMMAND_RESULT , 4 + member . size () + 1 + 4 + 4 );
data << uint32 ( operation );
2008-10-02 16:23:55 -05:00
data << member ;
2010-09-10 13:45:21 +02:00
data << uint32 ( res );
data << uint32 ( val ); // LFD cooldown related (used with ERR_PARTY_LFG_BOOT_COOLDOWN_S and ERR_PARTY_LFG_BOOT_NOT_ELIGIBLE_S)
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
SendPacket ( & data );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleGroupInviteOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_GROUP_INVITE" );
2011-02-18 18:35:52 +01:00
2008-10-02 16:23:55 -05:00
std :: string membername ;
recv_data >> membername ;
2010-11-26 01:24:31 +01:00
recv_data . read_skip < uint32 > ();
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// attempt add selected player
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// cheating
2010-04-07 19:14:10 +02:00
if ( ! normalizePlayerName ( membername ))
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , membername , ERR_BAD_PLAYER_NAME_S );
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-07-27 12:14:27 +02:00
Player * player = sObjectAccessor -> FindPlayerByName ( membername . c_str ());
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// no player
2010-04-07 19:14:10 +02:00
if ( ! player )
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , membername , ERR_BAD_PLAYER_NAME_S );
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-05-14 23:07:17 +02:00
// restrict invite to GMs
2010-12-23 23:25:44 +01:00
if ( ! sWorld -> getBoolConfig ( CONFIG_ALLOW_GM_GROUP ) && ! GetPlayer () -> isGameMaster () && player -> isGameMaster ())
2009-05-14 23:07:17 +02:00
return ;
2010-04-11 11:24:59 +04:00
2008-10-02 16:23:55 -05:00
// can't group with
2011-03-26 05:10:18 +02:00
if ( ! GetPlayer () -> isGameMaster () && ! sWorld -> getBoolConfig ( CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP ) && GetPlayer () -> GetTeam () != player -> GetTeam ())
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , membername , ERR_PLAYER_WRONG_FACTION );
2008-10-02 16:23:55 -05:00
return ;
}
2010-04-07 19:14:10 +02:00
if ( GetPlayer () -> GetInstanceId () != 0 && player -> GetInstanceId () != 0 && GetPlayer () -> GetInstanceId () != player -> GetInstanceId () && GetPlayer () -> GetMapId () == player -> GetMapId ())
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , membername , ERR_TARGET_NOT_IN_INSTANCE_S );
2008-10-02 16:23:55 -05:00
return ;
}
// just ignore us
2010-04-07 19:14:10 +02:00
if ( player -> GetInstanceId () != 0 && player -> GetDungeonDifficulty () != GetPlayer () -> GetDungeonDifficulty ())
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , membername , ERR_IGNORING_YOU_S );
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( player -> GetSocial () -> HasIgnore ( GetPlayer () -> GetGUIDLow ()))
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:24:59 +04:00
SendPartyResult ( PARTY_OP_INVITE , membername , ERR_IGNORING_YOU_S );
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-06-12 01:47:45 +02:00
Group * group = GetPlayer () -> GetGroup ();
2010-04-07 22:59:46 +02:00
if ( group && group -> isBGGroup ())
2009-03-14 20:00:02 -06:00
group = GetPlayer () -> GetOriginalGroup ();
2009-10-17 15:51:44 -07:00
2011-06-12 01:47:45 +02:00
Group * group2 = player -> GetGroup ();
2010-04-07 22:59:46 +02:00
if ( group2 && group2 -> isBGGroup ())
2009-03-14 20:00:02 -06:00
group2 = player -> GetOriginalGroup ();
2008-10-02 16:23:55 -05:00
// player already in another group or invited
2010-04-07 22:59:46 +02:00
if ( group2 || player -> GetGroupInvite ())
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , membername , ERR_ALREADY_IN_GROUP_S );
2010-07-28 12:20:42 -07:00
if ( group2 )
{
// tell the player that they were invited but it failed as they were already in a group
WorldPacket data ( SMSG_GROUP_INVITE , 10 ); // guess size
data << uint8 ( 0 ); // invited/already in group flag
data << GetPlayer () -> GetName (); // max len 48
data << uint32 ( 0 ); // unk
data << uint8 ( 0 ); // count
data << uint32 ( 0 ); // unk
player -> GetSession () -> SendPacket ( & data );
}
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( group )
2008-10-02 16:23:55 -05:00
{
// not have permissions for invite
2010-06-24 10:20:34 +02:00
if ( ! group -> IsLeader ( GetPlayer () -> GetGUID ()) && ! group -> IsAssistant ( GetPlayer () -> GetGUID ()))
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , "" , ERR_NOT_LEADER );
2008-10-02 16:23:55 -05:00
return ;
}
// not have place
2010-04-07 19:14:10 +02:00
if ( group -> IsFull ())
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , "" , ERR_GROUP_FULL );
2008-10-02 16:23:55 -05:00
return ;
}
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// ok, but group not exist, start a new group
// but don't create and save the group to the DB until
// at least one person joins
2010-04-07 19:14:10 +02:00
if ( ! group )
2008-10-02 16:23:55 -05:00
{
group = new Group ;
// new group: if can't add then delete
2010-04-07 19:14:10 +02:00
if ( ! group -> AddLeaderInvite ( GetPlayer ()))
2008-10-02 16:23:55 -05:00
{
delete group ;
return ;
}
2010-04-07 19:14:10 +02:00
if ( ! group -> AddInvite ( player ))
2008-10-02 16:23:55 -05:00
{
delete group ;
return ;
}
}
else
{
// already existed group: if can't add then just leave
2010-04-07 19:14:10 +02:00
if ( ! group -> AddInvite ( player ))
2008-10-02 16:23:55 -05:00
{
return ;
}
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// ok, we do it
WorldPacket data ( SMSG_GROUP_INVITE , 10 ); // guess size
2010-04-11 20:20:38 +02:00
data << uint8 ( 1 ); // invited/already in group flag
data << GetPlayer () -> GetName (); // max len 48
data << uint32 ( 0 ); // unk
data << uint8 ( 0 ); // count
2010-04-11 11:18:20 +04:00
data << uint32 ( 0 ); // unk
2008-10-02 16:23:55 -05:00
player -> GetSession () -> SendPacket ( & data );
2009-10-17 15:51:44 -07:00
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , membername , ERR_PARTY_RESULT_OK );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2010-11-26 01:24:31 +01:00
void WorldSession :: HandleGroupAcceptOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_GROUP_ACCEPT" );
2011-02-18 18:35:52 +01:00
2010-11-26 01:24:31 +01:00
recv_data . read_skip < uint32 > ();
2011-06-12 01:47:45 +02:00
Group * group = GetPlayer () -> GetGroupInvite ();
2011-02-18 18:35:52 +01:00
if ( ! group )
return ;
// Remove player from invitees in any case
group -> RemoveInvite ( GetPlayer ());
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( group -> GetLeaderGUID () == GetPlayer () -> GetGUID ())
2008-10-02 16:23:55 -05:00
{
2010-12-23 23:25:44 +01:00
sLog -> outError ( "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group" , GetPlayer () -> GetName (), GetPlayer () -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-02-18 18:35:52 +01:00
// Group is full
2010-04-07 19:14:10 +02:00
if ( group -> IsFull ())
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , "" , ERR_GROUP_FULL );
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-07-27 12:14:27 +02:00
Player * leader = ObjectAccessor :: FindPlayer ( group -> GetLeaderGUID ());
2009-10-17 15:51:44 -07:00
2011-02-18 18:35:52 +01:00
// Forming a new group, create it
2010-04-07 19:14:10 +02:00
if ( ! group -> IsCreated ())
2008-10-02 16:23:55 -05:00
{
2011-02-18 18:35:52 +01:00
// This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented
if ( ! leader )
{
group -> RemoveAllInvites ();
return ;
}
// If we're about to create a group there really should be a leader present
ASSERT ( leader );
group -> RemoveInvite ( leader );
group -> Create ( leader );
2011-05-05 10:23:00 +02:00
sGroupMgr -> AddGroup ( group );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2011-02-18 18:35:52 +01:00
// Everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
if ( ! group -> AddMember ( GetPlayer ()))
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-01-15 21:29:32 -05:00
group -> BroadcastGroupUpdate ();
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleGroupDeclineOpcode ( WorldPacket & /*recv_data*/ )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_GROUP_DECLINE" );
2011-02-18 18:35:52 +01:00
2012-03-28 20:00:29 +08:00
Group * group = GetPlayer () -> GetGroupInvite ();
if ( ! group )
return ;
2009-10-17 15:51:44 -07:00
2011-02-13 21:15:52 +01:00
// Remember leader if online (group pointer will be invalid if group gets disbanded)
2011-09-15 14:08:17 +02:00
Player * leader = ObjectAccessor :: FindPlayer ( group -> GetLeaderGUID ());
2011-02-13 21:15:52 +01:00
2009-03-07 10:42:13 -06:00
// uninvite, group can be deleted
GetPlayer () -> UninviteFromGroup ();
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! leader || ! leader -> GetSession ())
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-03-07 10:42:13 -06:00
// report
2010-10-29 14:09:25 +02:00
std :: string name = std :: string ( GetPlayer () -> GetName ());
WorldPacket data ( SMSG_GROUP_DECLINE , name . length ());
data << name . c_str ();
2010-04-07 22:59:46 +02:00
leader -> GetSession () -> SendPacket ( & data );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
void WorldSession :: HandleGroupUninviteGuidOpcode ( WorldPacket & recv_data )
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_GROUP_UNINVITE_GUID" );
2011-02-18 18:35:52 +01:00
2008-10-02 16:23:55 -05:00
uint64 guid ;
2010-08-11 15:20:20 +02:00
std :: string reason ;
2008-10-02 16:23:55 -05:00
recv_data >> guid ;
2010-08-11 15:20:20 +02:00
recv_data >> reason ;
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
//can't uninvite yourself
2010-04-07 19:14:10 +02:00
if ( guid == GetPlayer () -> GetGUID ())
2008-10-02 16:23:55 -05:00
{
2010-12-23 23:25:44 +01:00
sLog -> outError ( "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group." , GetPlayer () -> GetName (), GetPlayer () -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
PartyResult res = GetPlayer () -> CanUninviteFromGroup ();
2010-04-11 11:18:20 +04:00
if ( res != ERR_PARTY_RESULT_OK )
2008-10-02 16:23:55 -05:00
{
2010-05-15 06:23:56 +02:00
SendPartyResult ( PARTY_OP_UNINVITE , "" , res );
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
Group * grp = GetPlayer () -> GetGroup ();
2010-04-07 19:14:10 +02:00
if ( ! grp )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-12-29 22:08:33 +02:00
if ( grp -> IsLeader ( guid ))
{
SendPartyResult ( PARTY_OP_UNINVITE , "" , ERR_NOT_LEADER );
return ;
}
2010-04-07 19:14:10 +02:00
if ( grp -> IsMember ( guid ))
2008-12-12 11:21:28 -06:00
{
2010-11-23 20:49:57 +01:00
Player :: RemoveFromGroup ( grp , guid , GROUP_REMOVEMETHOD_KICK , GetPlayer () -> GetGUID (), reason . c_str ());
2008-12-12 11:21:28 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
if ( Player * player = grp -> GetInvited ( guid ))
2008-12-12 11:21:28 -06:00
{
2011-11-07 11:06:39 -06:00
player -> UninviteFromGroup ();
2008-10-02 16:23:55 -05:00
return ;
2008-12-12 11:21:28 -06:00
}
2009-10-17 15:51:44 -07:00
2010-05-15 06:23:56 +02:00
SendPartyResult ( PARTY_OP_UNINVITE , "" , ERR_TARGET_NOT_IN_GROUP_S );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
void WorldSession :: HandleGroupUninviteOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_GROUP_UNINVITE" );
2011-02-18 18:35:52 +01:00
2008-12-12 11:21:28 -06:00
std :: string membername ;
recv_data >> membername ;
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
// player not found
2010-04-07 19:14:10 +02:00
if ( ! normalizePlayerName ( membername ))
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
// can't uninvite yourself
2010-04-07 19:14:10 +02:00
if ( GetPlayer () -> GetName () == membername )
2008-10-02 16:23:55 -05:00
{
2010-12-23 23:25:44 +01:00
sLog -> outError ( "WorldSession::HandleGroupUninviteOpcode: leader %s(%d) tried to uninvite himself from the group." , GetPlayer () -> GetName (), GetPlayer () -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
PartyResult res = GetPlayer () -> CanUninviteFromGroup ();
2010-04-11 11:18:20 +04:00
if ( res != ERR_PARTY_RESULT_OK )
2008-10-02 16:23:55 -05:00
{
2010-05-15 06:23:56 +02:00
SendPartyResult ( PARTY_OP_UNINVITE , "" , res );
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
Group * grp = GetPlayer () -> GetGroup ();
2010-04-07 19:14:10 +02:00
if ( ! grp )
2008-12-12 11:21:28 -06:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( uint64 guid = grp -> GetMemberGUID ( membername ))
2008-10-02 16:23:55 -05:00
{
2010-11-23 20:49:57 +01:00
Player :: RemoveFromGroup ( grp , guid , GROUP_REMOVEMETHOD_KICK , GetPlayer () -> GetGUID ());
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
if ( Player * player = grp -> GetInvited ( membername ))
2008-10-02 16:23:55 -05:00
{
2011-11-07 11:06:39 -06:00
player -> UninviteFromGroup ();
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-05-15 06:23:56 +02:00
SendPartyResult ( PARTY_OP_UNINVITE , membername , ERR_TARGET_NOT_IN_GROUP_S );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleGroupSetLeaderOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_GROUP_SET_LEADER" );
2011-02-18 18:35:52 +01:00
2008-10-02 16:23:55 -05:00
uint64 guid ;
recv_data >> guid ;
2009-10-17 15:51:44 -07:00
2011-07-27 12:14:27 +02:00
Player * player = ObjectAccessor :: FindPlayer ( guid );
2011-09-05 14:54:19 +02:00
Group * group = GetPlayer () -> GetGroup ();
2009-10-17 15:51:44 -07:00
2011-09-05 14:54:19 +02:00
if ( ! group || ! player )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-05 14:54:19 +02:00
if ( ! group -> IsLeader ( GetPlayer () -> GetGUID ()) || player -> GetGroup () != group )
return ;
2011-02-18 18:35:52 +01:00
2011-09-05 14:54:19 +02:00
// Everything's fine, accepted.
group -> ChangeLeader ( guid );
2011-02-18 18:35:52 +01:00
group -> SendUpdate ();
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleGroupDisbandOpcode ( WorldPacket & /*recv_data*/ )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_GROUP_DISBAND" );
2011-02-18 18:35:52 +01:00
2011-09-15 14:08:17 +02:00
Group * grp = GetPlayer () -> GetGroup ();
2010-08-11 15:20:20 +02:00
if ( ! grp )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
if ( _player -> InBattleground ())
2008-10-02 16:23:55 -05:00
{
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , "" , ERR_INVITE_RESTRICTED );
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/** error handling **/
/********************/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// everything's fine, do it
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_LEAVE , GetPlayer () -> GetName (), ERR_PARTY_RESULT_OK );
2009-10-17 15:51:44 -07:00
2010-10-19 18:32:04 +02:00
GetPlayer () -> RemoveFromGroup ( GROUP_REMOVEMETHOD_LEAVE );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleLootMethodOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_LOOT_METHOD" );
2011-02-18 18:35:52 +01:00
2008-10-02 16:23:55 -05:00
uint32 lootMethod ;
uint64 lootMaster ;
uint32 lootThreshold ;
recv_data >> lootMethod >> lootMaster >> lootThreshold ;
2009-10-17 15:51:44 -07:00
2011-09-05 14:54:19 +02:00
Group * group = GetPlayer () -> GetGroup ();
if ( ! group )
return ;
2008-10-02 16:23:55 -05:00
/** error handling **/
2010-04-07 19:14:10 +02:00
if ( ! group -> IsLeader ( GetPlayer () -> GetGUID ()))
2008-10-02 16:23:55 -05:00
return ;
/********************/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// everything's fine, do it
group -> SetLootMethod (( LootMethod ) lootMethod );
group -> SetLooterGuid ( lootMaster );
group -> SetLootThreshold (( ItemQualities ) lootThreshold );
group -> SendUpdate ();
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleLootRoll ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2012-03-27 02:52:47 +03:00
Group * group = GetPlayer () -> GetGroup ();
if ( ! group )
2011-09-05 14:54:19 +02:00
{
recv_data . rfinish ();
2008-10-02 16:23:55 -05:00
return ;
2011-09-05 14:54:19 +02:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint64 Guid ;
uint32 NumberOfPlayers ;
2009-12-17 11:11:54 +01:00
uint8 rollType ;
2008-10-02 16:23:55 -05:00
recv_data >> Guid ; //guid of the item rolled
recv_data >> NumberOfPlayers ;
2009-12-17 11:11:54 +01:00
recv_data >> rollType ; //0: pass, 1: need, 2: greed
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// everything's fine, do it
2009-12-17 11:11:54 +01:00
group -> CountRollVote ( GetPlayer () -> GetGUID (), Guid , NumberOfPlayers , rollType );
2009-10-17 15:51:44 -07:00
2009-12-17 11:11:54 +01:00
switch ( rollType )
2009-05-31 16:26:39 -05:00
{
2009-12-17 11:11:54 +01:00
case ROLL_NEED :
2009-05-31 16:26:39 -05:00
GetPlayer () -> GetAchievementMgr (). UpdateAchievementCriteria ( ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED , 1 );
break ;
2009-12-17 11:11:54 +01:00
case ROLL_GREED :
2009-05-31 16:26:39 -05:00
GetPlayer () -> GetAchievementMgr (). UpdateAchievementCriteria ( ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED , 1 );
break ;
}
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
void WorldSession :: HandleMinimapPingOpcode ( WorldPacket & recv_data )
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received MSG_MINIMAP_PING" );
2011-02-18 18:35:52 +01:00
2010-04-07 19:14:10 +02:00
if ( ! GetPlayer () -> GetGroup ())
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
float x , y ;
recv_data >> x ;
recv_data >> y ;
2009-10-17 15:51:44 -07:00
2010-12-23 23:25:44 +01:00
//sLog->outDebug("Received opcode MSG_MINIMAP_PING X: %f, Y: %f", x, y);
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/** error handling **/
/********************/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// everything's fine, do it
WorldPacket data ( MSG_MINIMAP_PING , ( 8 + 4 + 4 ));
2010-02-14 19:13:14 -07:00
data << uint64 ( GetPlayer () -> GetGUID ());
data << float ( x );
data << float ( y );
2009-03-14 20:00:02 -06:00
GetPlayer () -> GetGroup () -> BroadcastPacket ( & data , true , - 1 , GetPlayer () -> GetGUID ());
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
void WorldSession :: HandleRandomRollOpcode ( WorldPacket & recv_data )
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received MSG_RANDOM_ROLL" );
2011-02-18 18:35:52 +01:00
2008-10-02 16:23:55 -05:00
uint32 minimum , maximum , roll ;
recv_data >> minimum ;
recv_data >> maximum ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/** error handling **/
2010-04-07 19:14:10 +02:00
if ( minimum > maximum || maximum > 10000 ) // < 32768 for urand call
2008-10-02 16:23:55 -05:00
return ;
/********************/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// everything's fine, do it
roll = urand ( minimum , maximum );
2009-10-17 15:51:44 -07:00
2010-12-23 23:25:44 +01:00
//sLog->outDebug("ROLL: MIN: %u, MAX: %u, ROLL: %u", minimum, maximum, roll);
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
WorldPacket data ( MSG_RANDOM_ROLL , 4 + 4 + 4 + 8 );
2010-02-14 19:13:14 -07:00
data << uint32 ( minimum );
data << uint32 ( maximum );
data << uint32 ( roll );
data << uint64 ( GetPlayer () -> GetGUID ());
2010-04-07 19:14:10 +02:00
if ( GetPlayer () -> GetGroup ())
2009-03-14 20:00:02 -06:00
GetPlayer () -> GetGroup () -> BroadcastPacket ( & data , false );
2008-10-02 16:23:55 -05:00
else
SendPacket ( & data );
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleRaidTargetUpdateOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received MSG_RAID_TARGET_UPDATE" );
2011-02-18 18:35:52 +01:00
2011-06-12 01:47:45 +02:00
Group * group = GetPlayer () -> GetGroup ();
2010-04-07 19:14:10 +02:00
if ( ! group )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint8 x ;
recv_data >> x ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/** error handling **/
/********************/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// everything's fine, do it
2010-04-07 19:14:10 +02:00
if ( x == 0xFF ) // target icon request
2008-10-02 16:23:55 -05:00
{
group -> SendTargetIconList ( this );
}
else // target icon update
{
2010-04-07 19:14:10 +02:00
if ( ! group -> IsLeader ( GetPlayer () -> GetGUID ()) && ! group -> IsAssistant ( GetPlayer () -> GetGUID ()))
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint64 guid ;
recv_data >> guid ;
2010-02-14 19:13:14 -07:00
group -> SetTargetIcon ( x , _player -> GetGUID (), guid );
2008-10-02 16:23:55 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleGroupRaidConvertOpcode ( WorldPacket & /*recv_data*/ )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_GROUP_RAID_CONVERT" );
2011-02-18 18:35:52 +01:00
2011-06-12 01:47:45 +02:00
Group * group = GetPlayer () -> GetGroup ();
2010-04-07 19:14:10 +02:00
if ( ! group )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
if ( _player -> InBattleground ())
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/** error handling **/
2010-04-07 19:14:10 +02:00
if ( ! group -> IsLeader ( GetPlayer () -> GetGUID ()) || group -> GetMembersCount () < 2 )
2008-10-02 16:23:55 -05:00
return ;
/********************/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// everything's fine, do it (is it 0 (PARTY_OP_INVITE) correct code)
2010-04-11 11:18:20 +04:00
SendPartyResult ( PARTY_OP_INVITE , "" , ERR_PARTY_RESULT_OK );
2008-10-02 16:23:55 -05:00
group -> ConvertToRaid ();
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleGroupChangeSubGroupOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_GROUP_CHANGE_SUB_GROUP" );
2011-02-18 18:35:52 +01:00
2009-03-14 20:00:02 -06:00
// we will get correct pointer for group here, so we don't have to check if group is BG raid
2011-06-12 01:47:45 +02:00
Group * group = GetPlayer () -> GetGroup ();
2010-04-07 19:14:10 +02:00
if ( ! group )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
std :: string name ;
uint8 groupNr ;
recv_data >> name ;
recv_data >> groupNr ;
2010-08-08 19:45:53 +02:00
2010-06-22 00:42:31 +02:00
if ( groupNr >= MAX_RAID_SUBGROUPS )
return ;
2009-10-17 15:51:44 -07:00
2010-03-09 20:33:59 +01:00
uint64 senderGuid = GetPlayer () -> GetGUID ();
if ( ! group -> IsLeader ( senderGuid ) && ! group -> IsAssistant ( senderGuid ))
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-29 17:09:32 -05:00
if ( ! group -> HasFreeSlotSubGroup ( groupNr ))
return ;
2009-10-17 15:51:44 -07:00
2011-07-27 12:14:27 +02:00
Player * movedPlayer = sObjectAccessor -> FindPlayerByName ( name . c_str ());
2011-02-18 18:35:52 +01:00
uint64 guid ;
2010-06-22 00:42:31 +02:00
if ( movedPlayer )
2010-08-08 19:45:53 +02:00
{
2011-02-18 18:35:52 +01:00
guid = movedPlayer -> GetGUID ();
2010-06-22 00:42:31 +02:00
}
else
2011-02-18 18:35:52 +01:00
{
2011-06-30 14:52:44 +02:00
CharacterDatabase . EscapeString ( name );
2011-02-18 18:35:52 +01:00
guid = sObjectMgr -> GetPlayerGUIDByName ( name . c_str ());
}
group -> ChangeMembersGroup ( guid , groupNr );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleGroupAssistantLeaderOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_GROUP_ASSISTANT_LEADER" );
2011-02-18 18:35:52 +01:00
2011-06-12 01:47:45 +02:00
Group * group = GetPlayer () -> GetGroup ();
2010-04-07 19:14:10 +02:00
if ( ! group )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-02-18 18:35:52 +01:00
if ( ! group -> IsLeader ( GetPlayer () -> GetGUID ()))
return ;
2008-10-02 16:23:55 -05:00
uint64 guid ;
2011-02-18 18:35:52 +01:00
bool apply ;
2008-10-02 16:23:55 -05:00
recv_data >> guid ;
2011-02-18 18:35:52 +01:00
recv_data >> apply ;
2009-10-17 15:51:44 -07:00
2011-02-18 18:35:52 +01:00
group -> SetGroupMemberFlag ( guid , apply , MEMBER_FLAG_ASSISTANT );
2009-10-17 15:51:44 -07:00
2011-02-18 18:35:52 +01:00
group -> SendUpdate ();
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandlePartyAssignmentOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received MSG_PARTY_ASSIGNMENT" );
2009-10-17 15:51:44 -07:00
2011-06-12 01:47:45 +02:00
Group * group = GetPlayer () -> GetGroup ();
2010-03-09 20:33:59 +01:00
if ( ! group )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-03-09 20:33:59 +01:00
uint64 senderGuid = GetPlayer () -> GetGUID ();
2010-06-23 19:05:35 +02:00
if ( ! group -> IsLeader ( senderGuid ) && ! group -> IsAssistant ( senderGuid ))
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-02-18 18:35:52 +01:00
uint8 assignment ;
bool apply ;
uint64 guid ;
recv_data >> assignment >> apply ;
recv_data >> guid ;
switch ( assignment )
{
case GROUP_ASSIGN_MAINASSIST :
group -> RemoveUniqueGroupMemberFlag ( MEMBER_FLAG_MAINASSIST );
group -> SetGroupMemberFlag ( guid , apply , MEMBER_FLAG_MAINASSIST );
break ;
case GROUP_ASSIGN_MAINTANK :
group -> RemoveUniqueGroupMemberFlag ( MEMBER_FLAG_MAINTANK ); // Remove main assist flag from current if any.
group -> SetGroupMemberFlag ( guid , apply , MEMBER_FLAG_MAINTANK );
default :
break ;
}
2010-02-14 19:13:14 -07:00
2011-02-18 18:35:52 +01:00
group -> SendUpdate ();
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleRaidReadyCheckOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received MSG_RAID_READY_CHECK" );
2011-02-18 18:35:52 +01:00
2011-06-12 01:47:45 +02:00
Group * group = GetPlayer () -> GetGroup ();
2010-04-07 19:14:10 +02:00
if ( ! group )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( recv_data . empty ()) // request
2008-10-02 16:23:55 -05:00
{
/** error handling **/
2010-04-07 19:14:10 +02:00
if ( ! group -> IsLeader ( GetPlayer () -> GetGUID ()) && ! group -> IsAssistant ( GetPlayer () -> GetGUID ()))
2008-10-02 16:23:55 -05:00
return ;
/********************/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// everything's fine, do it
WorldPacket data ( MSG_RAID_READY_CHECK , 8 );
data << GetPlayer () -> GetGUID ();
2009-03-14 20:00:02 -06:00
group -> BroadcastPacket ( & data , false , - 1 );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
group -> OfflineReadyCheck ();
}
else // answer
{
uint8 state ;
recv_data >> state ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// everything's fine, do it
WorldPacket data ( MSG_RAID_READY_CHECK_CONFIRM , 9 );
2010-04-11 11:16:42 +04:00
data << uint64 ( GetPlayer () -> GetGUID ());
data << uint8 ( state );
2008-10-02 16:23:55 -05:00
group -> BroadcastReadyCheck ( & data );
}
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleRaidReadyCheckFinishedOpcode ( WorldPacket & /*recv_data*/ )
2008-10-02 16:23:55 -05:00
{
//Group* group = GetPlayer()->GetGroup();
2010-04-07 19:14:10 +02:00
//if (!group)
2008-10-02 16:23:55 -05:00
// return;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
//if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
2008-10-02 16:23:55 -05:00
// return;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// Is any reaction need?
}
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
void WorldSession :: BuildPartyMemberStatsChangedPacket ( Player * player , WorldPacket * data )
2008-10-02 16:23:55 -05:00
{
uint32 mask = player -> GetGroupUpdateFlag ();
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask == GROUP_UPDATE_FLAG_NONE )
return ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_POWER_TYPE ) // if update power type, update current/max power also
mask |= ( GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE ) // same for pets
mask |= ( GROUP_UPDATE_FLAG_PET_CUR_POWER | GROUP_UPDATE_FLAG_PET_MAX_POWER );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint32 byteCount = 0 ;
for ( int i = 1 ; i < GROUP_UPDATE_FLAGS_COUNT ; ++ i )
if ( mask & ( 1 << i ))
byteCount += GroupUpdateLength [ i ];
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
data -> Initialize ( SMSG_PARTY_MEMBER_STATS , 8 + 4 + byteCount );
data -> append ( player -> GetPackGUID ());
* data << ( uint32 ) mask ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_STATUS )
{
if ( player )
{
if ( player -> IsPvP ())
* data << ( uint16 ) ( MEMBER_STATUS_ONLINE | MEMBER_STATUS_PVP );
else
* data << ( uint16 ) MEMBER_STATUS_ONLINE ;
}
else
* data << ( uint16 ) MEMBER_STATUS_OFFLINE ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_CUR_HP )
2008-12-24 09:58:26 -06:00
* data << ( uint32 ) player -> GetHealth ();
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_MAX_HP )
2008-12-24 09:58:26 -06:00
* data << ( uint32 ) player -> GetMaxHealth ();
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
Powers powerType = player -> getPowerType ();
if ( mask & GROUP_UPDATE_FLAG_POWER_TYPE )
* data << ( uint8 ) powerType ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_CUR_POWER )
* data << ( uint16 ) player -> GetPower ( powerType );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_MAX_POWER )
* data << ( uint16 ) player -> GetMaxPower ( powerType );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_LEVEL )
* data << ( uint16 ) player -> getLevel ();
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_ZONE )
* data << ( uint16 ) player -> GetZoneId ();
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_POSITION )
* data << ( uint16 ) player -> GetPositionX () << ( uint16 ) player -> GetPositionY ();
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_AURAS )
{
2011-08-30 13:46:36 +02:00
uint64 auramask = player -> GetAuraUpdateMaskForRaid ();
2008-10-02 16:23:55 -05:00
* data << uint64 ( auramask );
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < MAX_AURAS ; ++ i )
2008-10-02 16:23:55 -05:00
{
2010-04-07 19:14:10 +02:00
if ( auramask & ( uint64 ( 1 ) << i ))
2008-10-02 16:23:55 -05:00
{
2011-06-11 22:35:29 +02:00
AuraApplication const * aurApp = player -> GetVisibleAura ( i );
2010-01-10 01:23:15 +01:00
* data << uint32 ( aurApp ? aurApp -> GetBase () -> GetId () : 0 );
2008-10-02 16:23:55 -05:00
* data << uint8 ( 1 );
}
}
}
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
Pet * pet = player -> GetPet ();
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_PET_GUID )
{
2010-04-07 19:14:10 +02:00
if ( pet )
2008-10-02 16:23:55 -05:00
* data << ( uint64 ) pet -> GetGUID ();
else
* data << ( uint64 ) 0 ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_PET_NAME )
{
2010-04-07 19:14:10 +02:00
if ( pet )
2008-10-02 16:23:55 -05:00
* data << pet -> GetName ();
else
* data << ( uint8 ) 0 ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_PET_MODEL_ID )
{
2010-04-07 19:14:10 +02:00
if ( pet )
2008-10-02 16:23:55 -05:00
* data << ( uint16 ) pet -> GetDisplayId ();
else
* data << ( uint16 ) 0 ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_PET_CUR_HP )
{
2010-04-07 19:14:10 +02:00
if ( pet )
2008-12-24 09:58:26 -06:00
* data << ( uint32 ) pet -> GetHealth ();
2008-10-02 16:23:55 -05:00
else
2008-12-24 09:58:26 -06:00
* data << ( uint32 ) 0 ;
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_PET_MAX_HP )
{
2010-04-07 19:14:10 +02:00
if ( pet )
2008-12-24 09:58:26 -06:00
* data << ( uint32 ) pet -> GetMaxHealth ();
2008-10-02 16:23:55 -05:00
else
2008-12-24 09:58:26 -06:00
* data << ( uint32 ) 0 ;
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE )
{
2010-04-07 19:14:10 +02:00
if ( pet )
2008-10-02 16:23:55 -05:00
* data << ( uint8 ) pet -> getPowerType ();
else
* data << ( uint8 ) 0 ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_PET_CUR_POWER )
{
2010-04-07 19:14:10 +02:00
if ( pet )
2008-10-02 16:23:55 -05:00
* data << ( uint16 ) pet -> GetPower ( pet -> getPowerType ());
else
* data << ( uint16 ) 0 ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_PET_MAX_POWER )
{
2010-04-07 19:14:10 +02:00
if ( pet )
2008-10-02 16:23:55 -05:00
* data << ( uint16 ) pet -> GetMaxPower ( pet -> getPowerType ());
else
* data << ( uint16 ) 0 ;
}
2009-10-17 15:51:44 -07:00
2010-01-13 11:16:38 +01:00
if ( mask & GROUP_UPDATE_FLAG_VEHICLE_SEAT )
{
2011-10-11 23:09:49 +02:00
if ( Vehicle * veh = player -> GetVehicle ())
* data << ( uint32 ) veh -> GetVehicleInfo () -> m_seatID [ player -> m_movementInfo . t_seat ];
2010-01-13 11:16:38 +01:00
}
2008-10-02 16:23:55 -05:00
if ( mask & GROUP_UPDATE_FLAG_PET_AURAS )
{
2010-04-07 19:14:10 +02:00
if ( pet )
2008-10-02 16:23:55 -05:00
{
2011-08-30 13:46:36 +02:00
uint64 auramask = pet -> GetAuraUpdateMaskForRaid ();
2008-10-02 16:23:55 -05:00
* data << uint64 ( auramask );
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < MAX_AURAS ; ++ i )
2008-10-02 16:23:55 -05:00
{
2010-04-07 19:14:10 +02:00
if ( auramask & ( uint64 ( 1 ) << i ))
2008-10-02 16:23:55 -05:00
{
2011-06-11 22:35:29 +02:00
AuraApplication const * aurApp = player -> GetVisibleAura ( i );
2010-01-10 01:23:15 +01:00
* data << uint32 ( aurApp ? aurApp -> GetBase () -> GetId () : 0 );
2008-10-02 16:23:55 -05:00
* data << uint8 ( 1 );
}
}
}
else
* data << ( uint64 ) 0 ;
}
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleRequestPartyMemberStatsOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS" );
2008-10-02 16:23:55 -05:00
uint64 Guid ;
recv_data >> Guid ;
2009-10-17 15:51:44 -07:00
2011-06-12 01:47:45 +02:00
Player * player = HashMapHolder < Player >:: Find ( Guid );
2010-04-07 19:14:10 +02:00
if ( ! player )
2008-10-02 16:23:55 -05:00
{
WorldPacket data ( SMSG_PARTY_MEMBER_STATS_FULL , 3 + 4 + 2 );
2008-12-24 09:58:26 -06:00
data << uint8 ( 0 ); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
2008-10-02 16:23:55 -05:00
data . appendPackGUID ( Guid );
data << ( uint32 ) GROUP_UPDATE_FLAG_STATUS ;
data << ( uint16 ) MEMBER_STATUS_OFFLINE ;
SendPacket ( & data );
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
Pet * pet = player -> GetPet ();
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
WorldPacket data ( SMSG_PARTY_MEMBER_STATS_FULL , 4 + 2 + 2 + 2 + 1 + 2 * 6 + 8 + 1 + 8 );
2008-12-24 09:58:26 -06:00
data << uint8 ( 0 ); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
2008-10-02 16:23:55 -05:00
data . append ( player -> GetPackGUID ());
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint32 mask1 = 0x00040BFF ; // common mask, real flags used 0x000040BFF
2010-04-07 19:14:10 +02:00
if ( pet )
2008-10-02 16:23:55 -05:00
mask1 = 0x7FFFFFFF ; // for hunters and other classes with pets
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
Powers powerType = player -> getPowerType ();
data << ( uint32 ) mask1 ; // group update mask
data << ( uint16 ) MEMBER_STATUS_ONLINE ; // member's online status
2008-12-24 09:58:26 -06:00
data << ( uint32 ) player -> GetHealth (); // GROUP_UPDATE_FLAG_CUR_HP
data << ( uint32 ) player -> GetMaxHealth (); // GROUP_UPDATE_FLAG_MAX_HP
2008-10-02 16:23:55 -05:00
data << ( uint8 ) powerType ; // GROUP_UPDATE_FLAG_POWER_TYPE
data << ( uint16 ) player -> GetPower ( powerType ); // GROUP_UPDATE_FLAG_CUR_POWER
data << ( uint16 ) player -> GetMaxPower ( powerType ); // GROUP_UPDATE_FLAG_MAX_POWER
data << ( uint16 ) player -> getLevel (); // GROUP_UPDATE_FLAG_LEVEL
data << ( uint16 ) player -> GetZoneId (); // GROUP_UPDATE_FLAG_ZONE
data << ( uint16 ) player -> GetPositionX (); // GROUP_UPDATE_FLAG_POSITION
data << ( uint16 ) player -> GetPositionY (); // GROUP_UPDATE_FLAG_POSITION
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint64 auramask = 0 ;
size_t maskPos = data . wpos ();
data << ( uint64 ) auramask ; // placeholder
2009-10-17 16:20:24 -07:00
for ( uint8 i = 0 ; i < MAX_AURAS ; ++ i )
2008-10-02 16:23:55 -05:00
{
2010-04-07 19:14:10 +02:00
if ( AuraApplication * aurApp = player -> GetVisibleAura ( i ))
2008-10-02 16:23:55 -05:00
{
auramask |= ( uint64 ( 1 ) << i );
2010-01-10 01:23:15 +01:00
data << ( uint32 ) aurApp -> GetBase () -> GetId ();
2008-12-24 09:58:26 -06:00
data << ( uint8 ) 1 ;
2008-10-02 16:23:55 -05:00
}
}
2011-04-29 20:47:02 +02:00
data . put < uint64 > ( maskPos , auramask ); // GROUP_UPDATE_FLAG_AURAS
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( pet )
2008-10-02 16:23:55 -05:00
{
Powers petpowertype = pet -> getPowerType ();
data << ( uint64 ) pet -> GetGUID (); // GROUP_UPDATE_FLAG_PET_GUID
data << pet -> GetName (); // GROUP_UPDATE_FLAG_PET_NAME
data << ( uint16 ) pet -> GetDisplayId (); // GROUP_UPDATE_FLAG_PET_MODEL_ID
2008-12-24 09:58:26 -06:00
data << ( uint32 ) pet -> GetHealth (); // GROUP_UPDATE_FLAG_PET_CUR_HP
data << ( uint32 ) pet -> GetMaxHealth (); // GROUP_UPDATE_FLAG_PET_MAX_HP
2008-10-02 16:23:55 -05:00
data << ( uint8 ) petpowertype ; // GROUP_UPDATE_FLAG_PET_POWER_TYPE
data << ( uint16 ) pet -> GetPower ( petpowertype ); // GROUP_UPDATE_FLAG_PET_CUR_POWER
data << ( uint16 ) pet -> GetMaxPower ( petpowertype ); // GROUP_UPDATE_FLAG_PET_MAX_POWER
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint64 petauramask = 0 ;
size_t petMaskPos = data . wpos ();
data << ( uint64 ) petauramask ; // placeholder
2009-10-17 16:20:24 -07:00
for ( uint8 i = 0 ; i < MAX_AURAS ; ++ i )
2008-10-02 16:23:55 -05:00
{
2010-04-07 19:14:10 +02:00
if ( AuraApplication * auraApp = pet -> GetVisibleAura ( i ))
2008-10-02 16:23:55 -05:00
{
petauramask |= ( uint64 ( 1 ) << i );
2010-01-10 01:23:15 +01:00
data << ( uint32 ) auraApp -> GetBase () -> GetId ();
2008-10-02 16:23:55 -05:00
data << ( uint8 ) 1 ;
}
}
2011-04-29 20:47:02 +02:00
data . put < uint64 > ( petMaskPos , petauramask ); // GROUP_UPDATE_FLAG_PET_AURAS
2008-10-02 16:23:55 -05:00
}
else
{
data << ( uint8 ) 0 ; // GROUP_UPDATE_FLAG_PET_NAME
data << ( uint64 ) 0 ; // GROUP_UPDATE_FLAG_PET_AURAS
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
SendPacket ( & data );
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
/*!*/ void WorldSession :: HandleRequestRaidInfoOpcode ( WorldPacket & /*recv_data*/ )
2008-10-02 16:23:55 -05:00
{
// every time the player checks the character screen
_player -> SendRaidInfo ();
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
/*void WorldSession::HandleGroupCancelOpcode(WorldPacket & recv_data)
2008-10-02 16:23:55 -05:00
{
2010-12-23 23:25:44 +01:00
sLog->outDebug("WORLD: got CMSG_GROUP_CANCEL.");
2008-10-02 16:23:55 -05:00
}*/
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
void WorldSession :: HandleOptOutOfLootOpcode ( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: Received CMSG_OPT_OUT_OF_LOOT" );
2009-10-17 15:51:44 -07:00
2010-04-17 18:55:17 +02:00
uint32 passOnLoot ;
recv_data >> passOnLoot ; // 1 always pass, 0 do not pass
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// ignore if player not loaded
2010-04-07 19:14:10 +02:00
if ( ! GetPlayer ()) // needed because STATUS_AUTHED
2008-10-02 16:23:55 -05:00
{
2010-04-17 18:55:17 +02:00
if ( passOnLoot != 0 )
2010-12-23 23:25:44 +01:00
sLog -> outError ( "CMSG_OPT_OUT_OF_LOOT value<>0 for not-loaded character!" );
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-17 18:55:17 +02:00
GetPlayer () -> SetPassOnGroupLoot ( passOnLoot );
2008-10-02 16:23:55 -05:00
}