2010-10-07 15:35:36 +02:00
/*
2016-01-01 00:34:25 +01:00
* Copyright (C) 2008-2016 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"
2009-06-04 21:41:07 +02:00
#include "ObjectAccessor.h"
2008-10-11 14:16:25 -05:00
#include "ObjectMgr.h"
2011-05-03 15:01:10 +02:00
#include "ArenaTeamMgr.h"
2009-06-04 21:41:07 +02:00
#include "WorldPacket.h"
2008-10-11 14:16:25 -05:00
#include "WorldSession.h"
2009-10-17 15:51:44 -07:00
2009-06-04 21:41:07 +02:00
#include "ArenaTeam.h"
2010-08-08 04:37:24 +02:00
#include "BattlegroundMgr.h"
#include "Battleground.h"
2009-06-04 21:41:07 +02:00
#include "Chat.h"
2008-12-19 16:05:13 -06:00
#include "Language.h"
2009-06-04 21:41:07 +02:00
#include "Log.h"
#include "Player.h"
#include "Object.h"
#include "Opcodes.h"
2010-07-21 12:14:23 +02:00
#include "DisableMgr.h"
2010-11-29 07:50:31 +01:00
#include "Group.h"
2015-04-08 19:34:04 +02:00
#include "Battlefield.h"
#include "BattlefieldMgr.h"
2015-04-17 00:06:24 +02:00
#include "NPCPackets.h"
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
void WorldSession :: HandleBattlemasterHelloOpcode ( WorldPackets :: NPC :: Hello & hello )
2008-10-11 14:16:25 -05:00
{
2015-04-17 00:06:24 +02:00
Creature * unit = GetPlayer () -> GetMap () -> GetCreature ( hello . Unit );
2009-04-08 16:33:46 -05:00
if ( ! unit )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2013-06-11 19:54:27 -02:30
if ( ! unit -> IsBattleMaster ()) // it's not battlemaster
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
// Stop the npc if moving
unit -> StopMoving ();
2009-10-17 15:51:44 -07:00
2010-12-22 21:25:23 +01:00
BattlegroundTypeId bgTypeId = sBattlegroundMgr -> GetBattleMasterBG ( unit -> GetEntry ());
2009-10-17 15:51:44 -07:00
2009-04-08 16:33:46 -05:00
if ( ! _player -> GetBGAccessByLevel ( bgTypeId ))
2008-10-11 14:16:25 -05:00
{
// temp, must be gossip message...
SendNotification ( LANG_YOUR_BG_LEVEL_REQ_ERROR );
return ;
}
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
sBattlegroundMgr -> SendBattlegroundList ( _player , hello . Unit , bgTypeId );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
void WorldSession :: HandleBattlemasterJoinOpcode ( WorldPackets :: Battleground :: BattlemasterJoin & battlemasterJoin )
2008-10-11 14:16:25 -05:00
{
2009-02-27 12:13:59 -06:00
bool isPremade = false ;
2011-09-15 14:08:17 +02:00
Group * grp = NULL ;
2015-04-17 00:06:24 +02:00
uint32 bgTypeId_ = battlemasterJoin . QueueID & 0xFFFF ;
2009-04-08 16:33:46 -05:00
if ( ! sBattlemasterListStore . LookupEntry ( bgTypeId_ ))
2008-10-11 14:16:25 -05:00
{
2014-10-22 17:33:55 +02:00
TC_LOG_ERROR ( "network" , "Battleground: invalid bgtype (%u) received. possible cheater? %s" , bgTypeId_ , _player -> GetGUID (). ToString (). c_str ());
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-09 14:27:23 +02:00
if ( DisableMgr :: IsDisabledFor ( DISABLE_TYPE_BATTLEGROUND , bgTypeId_ , NULL ))
2010-07-21 12:14:23 +02:00
{
ChatHandler ( this ). PSendSysMessage ( LANG_BG_DISABLED );
return ;
}
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
BattlegroundTypeId bgTypeId = BattlegroundTypeId ( bgTypeId_ );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// can do this, since it's battleground, not arena
2010-08-08 04:37:24 +02:00
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr :: BGQueueTypeId ( bgTypeId , 0 );
BattlegroundQueueTypeId bgQueueTypeIdRandom = BattlegroundMgr :: BGQueueTypeId ( BATTLEGROUND_RB , 0 );
2009-10-17 15:51:44 -07:00
2008-12-19 16:05:13 -06:00
// ignore if player is already in BG
2010-08-08 04:37:24 +02:00
if ( _player -> InBattleground ())
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
// get bg instance or bg template if instance not found
2015-04-17 00:06:24 +02:00
Battleground * bg = sBattlegroundMgr -> GetBattlegroundTemplate ( bgTypeId );
2010-04-19 17:03:10 +02:00
if ( ! bg )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-02-15 15:31:27 +01:00
// expected bracket entry
2011-04-29 20:47:02 +02:00
PvPDifficultyEntry const * bracketEntry = GetBattlegroundBracketByLevel ( bg -> GetMapId (), _player -> getLevel ());
2010-02-15 15:31:27 +01:00
if ( ! bracketEntry )
return ;
2012-10-12 00:26:05 +02:00
GroupJoinBattlegroundResult err = ERR_BATTLEGROUND_NONE ;
2010-04-11 11:22:29 +04:00
// check queue conditions
2015-04-17 00:06:24 +02:00
if ( ! battlemasterJoin . JoinAsGroup )
2008-10-11 14:16:25 -05:00
{
2010-11-24 15:37:22 +01:00
if ( GetPlayer () -> isUsingLfg ())
{
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusFailed battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusFailed ( & battlefieldStatus , bg , _player , 0 , 0 , ERR_LFG_CANT_USE_BATTLEGROUND );
SendPacket ( battlefieldStatus . Write ());
2010-11-24 15:37:22 +01:00
return ;
}
2008-10-11 14:16:25 -05:00
// check Deserter debuff
2013-01-17 17:35:47 +01:00
if ( ! _player -> CanJoinToBattleground ( bg ))
2008-10-11 14:16:25 -05:00
{
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusFailed battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusFailed ( & battlefieldStatus , bg , _player , 0 , 0 , ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS );
SendPacket ( battlefieldStatus . Write ());
2008-10-11 14:16:25 -05:00
return ;
}
2010-05-26 11:34:37 +02:00
2010-08-08 04:37:24 +02:00
if ( _player -> GetBattlegroundQueueIndex ( bgQueueTypeIdRandom ) < PLAYER_MAX_BATTLEGROUND_QUEUES )
2010-05-26 11:34:37 +02:00
{
2012-10-04 10:39:37 +02:00
// player is already in random queue
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusFailed battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusFailed ( & battlefieldStatus , bg , _player , 0 , 0 , ERR_IN_RANDOM_BG );
SendPacket ( battlefieldStatus . Write ());
2010-05-26 11:34:37 +02:00
return ;
}
2010-08-08 19:45:53 +02:00
2010-08-08 04:37:24 +02:00
if ( _player -> InBattlegroundQueue () && bgTypeId == BATTLEGROUND_RB )
2010-05-26 11:34:37 +02:00
{
2012-10-04 10:39:37 +02:00
// player is already in queue, can't start random queue
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusFailed battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusFailed ( & battlefieldStatus , bg , _player , 0 , 0 , ERR_IN_NON_RANDOM_BG );
SendPacket ( battlefieldStatus . Write ());
2010-05-26 11:34:37 +02:00
return ;
}
2008-10-11 14:16:25 -05:00
// check if already in queue
2010-08-08 04:37:24 +02:00
if ( _player -> GetBattlegroundQueueIndex ( bgQueueTypeId ) < PLAYER_MAX_BATTLEGROUND_QUEUES )
2012-10-04 10:39:37 +02:00
// player is already in this queue
2008-10-11 14:16:25 -05:00
return ;
2010-05-26 11:34:37 +02:00
2008-10-11 14:16:25 -05:00
// check if has free queue slots
2010-08-08 04:37:24 +02:00
if ( ! _player -> HasFreeBattlegroundQueueId ())
2010-05-26 11:34:37 +02:00
{
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusFailed battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusFailed ( & battlefieldStatus , bg , _player , 0 , 0 , ERR_BATTLEGROUND_TOO_MANY_QUEUES );
SendPacket ( battlefieldStatus . Write ());
2008-10-11 14:16:25 -05:00
return ;
2010-05-26 11:34:37 +02:00
}
2015-06-03 22:08:01 +02:00
// check Freeze debuff
if ( _player -> HasAura ( 9454 ))
return ;
2012-10-04 10:39:37 +02:00
BattlegroundQueue & bgQueue = sBattlegroundMgr -> GetBattlegroundQueue ( bgQueueTypeId );
2011-09-15 14:08:17 +02:00
GroupQueueInfo * ginfo = bgQueue . AddGroup ( _player , NULL , bgTypeId , bracketEntry , 0 , false , isPremade , 0 , 0 );
2012-10-12 00:26:05 +02:00
2010-04-19 09:26:37 +02:00
uint32 avgTime = bgQueue . GetAverageQueueWaitTime ( ginfo , bracketEntry -> GetBracketId ());
2010-08-08 04:37:24 +02:00
uint32 queueSlot = _player -> AddBattlegroundQueueId ( bgQueueTypeId );
2010-04-19 09:26:37 +02:00
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusQueued battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusQueued ( & battlefieldStatus , bg , _player , queueSlot , ginfo -> JoinTime , avgTime , ginfo -> ArenaType , false );
SendPacket ( battlefieldStatus . Write ());
2012-10-12 00:26:05 +02:00
2014-10-22 17:33:55 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "Battleground: player joined queue for bg queue type %u bg type %u, %s, NAME %s" ,
bgQueueTypeId , bgTypeId , _player -> GetGUID (). ToString (). c_str (), _player -> GetName (). c_str ());
2008-10-11 14:16:25 -05:00
}
else
{
grp = _player -> GetGroup ();
2012-10-12 00:26:05 +02:00
2009-04-08 16:33:46 -05:00
if ( ! grp )
2008-10-11 14:16:25 -05:00
return ;
2012-10-12 00:26:05 +02:00
2010-04-11 11:22:29 +04:00
if ( grp -> GetLeaderGUID () != _player -> GetGUID ())
2008-10-11 14:16:25 -05:00
return ;
2012-11-07 23:21:19 +01:00
2015-04-17 00:06:24 +02:00
ObjectGuid errorGuid ;
err = grp -> CanJoinBattlegroundQueue ( bg , bgQueueTypeId , 0 , bg -> GetMaxPlayersPerTeam (), false , 0 , errorGuid );
2010-04-11 11:22:29 +04:00
isPremade = ( grp -> GetMembersCount () >= bg -> GetMinPlayersPerTeam ());
2009-10-17 15:51:44 -07:00
2012-10-04 10:39:37 +02:00
BattlegroundQueue & bgQueue = sBattlegroundMgr -> GetBattlegroundQueue ( bgQueueTypeId );
2011-09-15 14:08:17 +02:00
GroupQueueInfo * ginfo = NULL ;
2010-05-01 22:25:14 +02:00
uint32 avgTime = 0 ;
2010-04-11 11:22:29 +04:00
2012-10-12 00:26:05 +02:00
if ( ! err )
2010-04-11 11:22:29 +04:00
{
2013-11-08 10:50:51 +01:00
TC_LOG_DEBUG ( "bg.battleground" , "Battleground: the following players are joining as group:" );
2010-08-27 18:18:26 +02:00
ginfo = bgQueue . AddGroup ( _player , grp , bgTypeId , bracketEntry , 0 , false , isPremade , 0 , 0 );
2010-04-11 20:20:38 +02:00
avgTime = bgQueue . GetAverageQueueWaitTime ( ginfo , bracketEntry -> GetBracketId ());
}
2010-04-11 11:22:29 +04:00
2011-09-15 14:08:17 +02:00
for ( GroupReference * itr = grp -> GetFirstMember (); itr != NULL ; itr = itr -> next ())
2008-10-11 14:16:25 -05:00
{
2013-06-11 21:25:12 -02:30
Player * member = itr -> GetSource ();
2012-05-30 08:01:02 +02:00
if ( ! member )
continue ; // this should never happen
2009-10-17 15:51:44 -07:00
2012-10-12 00:26:05 +02:00
if ( err )
2010-04-11 20:20:38 +02:00
{
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusFailed battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusFailed ( & battlefieldStatus , bg , _player , 0 , 0 , err , & errorGuid );
member -> SendDirectMessage ( battlefieldStatus . Write ());
2010-04-11 20:20:38 +02:00
continue ;
2010-04-11 11:22:29 +04:00
}
2010-04-11 20:20:38 +02:00
// add to queue
2010-08-08 04:37:24 +02:00
uint32 queueSlot = member -> AddBattlegroundQueueId ( bgQueueTypeId );
2010-04-11 11:22:29 +04:00
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusQueued battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusQueued ( & battlefieldStatus , bg , member , queueSlot , ginfo -> JoinTime , avgTime , ginfo -> ArenaType , true );
member -> SendDirectMessage ( battlefieldStatus . Write ());
2014-10-22 17:33:55 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "Battleground: player joined queue for bg queue type %u bg type %u, %s, NAME %s" ,
bgQueueTypeId , bgTypeId , member -> GetGUID (). ToString (). c_str (), member -> GetName (). c_str ());
2008-10-11 14:16:25 -05:00
}
2013-11-08 10:50:51 +01:00
TC_LOG_DEBUG ( "bg.battleground" , "Battleground: group end" );
2008-10-11 14:16:25 -05:00
}
2012-10-12 00:26:05 +02:00
2010-12-22 21:25:23 +01:00
sBattlegroundMgr -> ScheduleQueueUpdate ( 0 , 0 , bgQueueTypeId , bgTypeId , bracketEntry -> GetBracketId ());
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2015-04-12 15:34:00 +02:00
void WorldSession :: HandlePVPLogDataOpcode ( WorldPackets :: Battleground :: PVPLogDataRequest & /*pvpLogDataRequest*/ )
2008-10-11 14:16:25 -05:00
{
2011-06-27 02:50:00 +02:00
Battleground * bg = _player -> GetBattleground ();
2009-04-08 16:33:46 -05:00
if ( ! bg )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-06-27 02:50:00 +02:00
// Prevent players from sending BuildPvpLogDataPacket in an arena except for when sent in BattleGround::EndBattleGround.
if ( bg -> isArena ())
return ;
2015-04-12 15:34:00 +02:00
WorldPackets :: Battleground :: PVPLogData pvpLogData ;
bg -> BuildPvPLogDataPacket ( pvpLogData );
SendPacket ( pvpLogData . Write ());
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
void WorldSession :: HandleBattlefieldListOpcode ( WorldPackets :: Battleground :: BattlefieldListRequest & battlefieldList )
2008-10-11 14:16:25 -05:00
{
2015-04-17 00:06:24 +02:00
BattlemasterListEntry const * battlemasterListEntry = sBattlemasterListStore . LookupEntry ( battlefieldList . ListID );
if ( ! battlemasterListEntry )
2008-10-11 14:16:25 -05:00
{
2015-04-17 00:06:24 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, %s) received." , battlefieldList . ListID , _player -> GetName (). c_str (), _player -> GetGUID (). ToString (). c_str ());
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
sBattlegroundMgr -> SendBattlegroundList ( _player , ObjectGuid :: Empty , BattlegroundTypeId ( battlefieldList . ListID ));
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
void WorldSession :: HandleBattleFieldPortOpcode ( WorldPackets :: Battleground :: BattlefieldPort & battlefieldPort )
2008-10-11 14:16:25 -05:00
{
2012-10-12 00:26:05 +02:00
if ( ! _player -> InBattlegroundQueue ())
2008-10-11 14:16:25 -05:00
{
2015-04-17 00:06:24 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u. Player not in queue!" ,
GetPlayerInfo (). c_str (), battlefieldPort . Ticket . Id , battlefieldPort . Ticket . Type , battlefieldPort . Ticket . Time , uint32 ( battlefieldPort . AcceptedInvite ));
2010-02-15 15:31:27 +01:00
return ;
}
2011-09-26 09:52:17 +02:00
2015-04-17 00:06:24 +02:00
BattlegroundQueueTypeId bgQueueTypeId = _player -> GetBattlegroundQueueTypeId ( battlefieldPort . Ticket . Id );
2012-10-12 00:26:05 +02:00
if ( bgQueueTypeId == BATTLEGROUND_QUEUE_NONE )
2010-02-15 15:31:27 +01:00
{
2015-04-17 00:06:24 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u. Invalid queueSlot!" ,
GetPlayerInfo (). c_str (), battlefieldPort . Ticket . Id , battlefieldPort . Ticket . Type , battlefieldPort . Ticket . Time , uint32 ( battlefieldPort . AcceptedInvite ));
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2012-10-04 10:39:37 +02:00
BattlegroundQueue & bgQueue = sBattlegroundMgr -> GetBattlegroundQueue ( bgQueueTypeId );
2012-10-12 00:26:05 +02:00
2010-08-08 04:37:24 +02:00
//we must use temporary variable, because GroupQueueInfo pointer can be deleted in BattlegroundQueue::RemovePlayer() function
2010-02-15 15:31:27 +01:00
GroupQueueInfo ginfo ;
if ( ! bgQueue . GetPlayerGroupInfoData ( _player -> GetGUID (), & ginfo ))
2008-10-11 14:16:25 -05:00
{
2015-04-17 00:06:24 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u. Player not in queue (No player Group Info)!" ,
GetPlayerInfo (). c_str (), battlefieldPort . Ticket . Id , battlefieldPort . Ticket . Type , battlefieldPort . Ticket . Time , uint32 ( battlefieldPort . AcceptedInvite ));
2008-10-11 14:16:25 -05:00
return ;
}
2015-04-17 00:06:24 +02:00
// if action == 1, then player must have been invited to join
if ( ! ginfo . IsInvitedToBGInstanceGUID && battlefieldPort . AcceptedInvite )
2008-10-11 14:16:25 -05:00
{
2015-04-17 00:06:24 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u. Player is not invited to any bg!" ,
GetPlayerInfo (). c_str (), battlefieldPort . Ticket . Id , battlefieldPort . Ticket . Type , battlefieldPort . Ticket . Time , uint32 ( battlefieldPort . AcceptedInvite ));
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2012-11-20 10:37:25 +01:00
BattlegroundTypeId bgTypeId = BattlegroundMgr :: BGTemplateId ( bgQueueTypeId );
// BGTemplateId returns BATTLEGROUND_AA when it is arena queue.
// Do instance id search as there is no AA bg instances.
Battleground * bg = sBattlegroundMgr -> GetBattleground ( ginfo . IsInvitedToBGInstanceGUID , bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : bgTypeId );
2009-04-08 16:33:46 -05:00
if ( ! bg )
2008-10-11 14:16:25 -05:00
{
2015-04-17 00:06:24 +02:00
if ( battlefieldPort . AcceptedInvite )
2012-11-14 19:33:21 +01:00
{
2015-04-17 00:06:24 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u. Cant find BG with id %u!" ,
GetPlayerInfo (). c_str (), battlefieldPort . Ticket . Id , battlefieldPort . Ticket . Type , battlefieldPort . Ticket . Time , uint32 ( battlefieldPort . AcceptedInvite ), ginfo . IsInvitedToBGInstanceGUID );
2012-11-14 19:33:21 +01:00
return ;
}
bg = sBattlegroundMgr -> GetBattlegroundTemplate ( bgTypeId );
if ( ! bg )
{
2013-11-08 10:50:51 +01:00
TC_LOG_ERROR ( "network" , "BattlegroundHandler: bg_template not found for type id %u." , bgTypeId );
2012-11-14 19:33:21 +01:00
return ;
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u." ,
GetPlayerInfo (). c_str (), battlefieldPort . Ticket . Id , battlefieldPort . Ticket . Type , battlefieldPort . Ticket . Time , uint32 ( battlefieldPort . AcceptedInvite ));
2012-11-14 19:33:21 +01:00
2012-11-20 10:37:25 +01:00
// get real bg type
bgTypeId = bg -> GetTypeID ();
2010-02-15 15:31:27 +01:00
// expected bracket entry
2011-04-29 20:47:02 +02:00
PvPDifficultyEntry const * bracketEntry = GetBattlegroundBracketByLevel ( bg -> GetMapId (), _player -> getLevel ());
2010-02-15 15:31:27 +01:00
if ( ! bracketEntry )
return ;
//some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it
2015-04-17 00:06:24 +02:00
if ( battlefieldPort . AcceptedInvite && ginfo . ArenaType == 0 )
2008-10-11 14:16:25 -05:00
{
2010-02-15 15:31:27 +01:00
//if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue
2013-01-17 17:35:47 +01:00
if ( ! _player -> CanJoinToBattleground ( bg ))
2008-10-11 14:16:25 -05:00
{
2010-02-15 15:31:27 +01:00
//send bg command result to show nice message
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusFailed battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusFailed ( & battlefieldStatus , bg , _player , battlefieldPort . Ticket . Id , 0 , ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS );
SendPacket ( battlefieldPort . Write ());
battlefieldPort . AcceptedInvite = false ;
2014-10-22 17:33:55 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "Player %s (%s) has a deserter debuff, do not port him to battleground!" , _player -> GetName (). c_str (), _player -> GetGUID (). ToString (). c_str ());
2009-03-09 17:01:18 -06:00
}
2010-02-15 15:31:27 +01:00
//if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue
if ( _player -> getLevel () > bg -> GetMaxLevel ())
2008-10-11 14:16:25 -05:00
{
2014-10-22 17:33:55 +02:00
TC_LOG_DEBUG ( "network" , "Player %s (%s) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!" ,
_player -> GetName (). c_str (), _player -> GetGUID (). ToString (). c_str (), _player -> getLevel (), bg -> GetMaxLevel (), bg -> GetTypeID ());
2015-04-17 00:06:24 +02:00
battlefieldPort . AcceptedInvite = false ;
2010-02-15 15:31:27 +01:00
}
}
2012-10-12 00:26:05 +02:00
2015-04-17 00:06:24 +02:00
if ( battlefieldPort . AcceptedInvite )
2010-02-15 15:31:27 +01:00
{
2015-06-03 22:08:01 +02:00
// check Freeze debuff
if ( _player -> HasAura ( 9454 ))
return ;
2012-11-14 19:33:21 +01:00
if ( ! _player -> IsInvitedForBattlegroundQueueType ( bgQueueTypeId ))
return ; // cheating?
2009-10-17 15:51:44 -07:00
2012-11-14 19:33:21 +01:00
if ( ! _player -> InBattleground ())
_player -> SetBattlegroundEntryPoint ();
2009-10-17 15:51:44 -07:00
2012-11-14 19:33:21 +01:00
// resurrect the player
2013-06-11 19:54:27 -02:30
if ( ! _player -> IsAlive ())
2012-11-14 19:33:21 +01:00
{
_player -> ResurrectPlayer ( 1.0f );
_player -> SpawnCorpseBones ();
}
// stop taxi flight at port
2013-06-11 19:54:27 -02:30
if ( _player -> IsInFlight ())
2012-11-14 19:33:21 +01:00
{
_player -> GetMotionMaster () -> MovementExpired ();
_player -> CleanupAfterTaxiFlight ();
}
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusActive battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusActive ( & battlefieldStatus , bg , _player , battlefieldPort . Ticket . Id , _player -> GetBattlegroundQueueJoinTime ( bgQueueTypeId ), bg -> GetArenaType ());
SendPacket ( battlefieldStatus . Write ());
2013-01-20 19:44:38 +01:00
2012-11-14 19:33:21 +01:00
// remove battleground queue status from BGmgr
bgQueue . RemovePlayer ( _player -> GetGUID (), false );
// this is still needed here if battleground "jumping" shouldn't add deserter debuff
// also this is required to prevent stuck at old battleground after SetBattlegroundId set to new
if ( Battleground * currentBg = _player -> GetBattleground ())
currentBg -> RemovePlayerAtLeave ( _player -> GetGUID (), false , true );
// set the destination instance id
_player -> SetBattlegroundId ( bg -> GetInstanceID (), bgTypeId );
// set the destination team
_player -> SetBGTeam ( ginfo . Team );
2013-01-20 19:44:38 +01:00
2012-11-14 19:33:21 +01:00
// bg->HandleBeforeTeleportToBattleground(_player);
sBattlegroundMgr -> SendToBattleground ( _player , ginfo . IsInvitedToBGInstanceGUID , bgTypeId );
// add only in HandleMoveWorldPortAck()
// bg->AddPlayer(_player, team);
2014-10-22 17:33:55 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "Battleground: player %s (%s) joined battle for bg %u, bgtype %u, queue type %u." , _player -> GetName (). c_str (), _player -> GetGUID (). ToString (). c_str (), bg -> GetInstanceID (), bg -> GetTypeID (), bgQueueTypeId );
2012-11-14 19:33:21 +01:00
}
else // leave queue
{
// if player leaves rated arena match before match start, it is counted as he played but he lost
if ( ginfo . IsRated && ginfo . IsInvitedToBGInstanceGUID )
{
ArenaTeam * at = sArenaTeamMgr -> GetArenaTeamById ( ginfo . Team );
if ( at )
2010-02-15 15:31:27 +01:00
{
2014-09-14 16:14:12 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "UPDATING memberLost's personal arena rating for %s by opponents rating: %u, because he has left queue!" , _player -> GetGUID (). ToString (). c_str (), ginfo . OpponentsTeamRating );
2012-11-14 19:33:21 +01:00
at -> MemberLost ( _player , ginfo . OpponentsMatchmakerRating );
at -> SaveToDB ();
2010-02-15 15:31:27 +01:00
}
2012-11-14 19:33:21 +01:00
}
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusNone battlefieldStatus ;
battlefieldStatus . Ticket = battlefieldPort . Ticket ;
SendPacket ( battlefieldStatus . Write ());
2012-11-16 08:51:15 +01:00
2012-11-20 10:37:25 +01:00
_player -> RemoveBattlegroundQueueId ( bgQueueTypeId ); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs
2012-11-14 19:33:21 +01:00
bgQueue . RemovePlayer ( _player -> GetGUID (), true );
// player left queue, we should update it - do not update Arena Queue
if ( ! ginfo . ArenaType )
sBattlegroundMgr -> ScheduleQueueUpdate ( ginfo . ArenaMatchmakerRating , ginfo . ArenaType , bgQueueTypeId , bgTypeId , bracketEntry -> GetBracketId ());
2012-11-20 10:37:25 +01:00
2014-10-22 17:33:55 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "Battleground: player %s (%s) left queue for bgtype %u, queue type %u." , _player -> GetName (). c_str (), _player -> GetGUID (). ToString (). c_str (), bg -> GetTypeID (), bgQueueTypeId );
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
void WorldSession :: HandleBattlefieldLeaveOpcode ( WorldPackets :: Battleground :: BattlefieldLeave & /*battlefieldLeave*/ )
2008-10-11 14:16:25 -05:00
{
// not allow leave battleground in combat
2013-06-11 19:54:27 -02:30
if ( _player -> IsInCombat ())
2010-08-08 04:37:24 +02:00
if ( Battleground * bg = _player -> GetBattleground ())
2009-04-08 16:33:46 -05:00
if ( bg -> GetStatus () != STATUS_WAIT_LEAVE )
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
_player -> LeaveBattleground ();
}
2009-10-17 15:51:44 -07:00
2015-04-17 00:06:24 +02:00
void WorldSession :: HandleRequestBattlefieldStatusOpcode ( WorldPackets :: Battleground :: RequestBattlefieldStatus & /*requestBattlefieldStatus*/ )
2008-10-11 14:16:25 -05:00
{
2009-03-13 18:06:36 -06:00
// we must update all queues here
2011-09-15 14:08:17 +02:00
Battleground * bg = NULL ;
2009-04-29 00:26:07 -05:00
for ( uint8 i = 0 ; i < PLAYER_MAX_BATTLEGROUND_QUEUES ; ++ i )
2008-10-11 14:16:25 -05:00
{
2010-08-08 04:37:24 +02:00
BattlegroundQueueTypeId bgQueueTypeId = _player -> GetBattlegroundQueueTypeId ( i );
2009-04-08 16:33:46 -05:00
if ( ! bgQueueTypeId )
2009-03-10 15:29:50 -06:00
continue ;
2010-08-08 04:37:24 +02:00
BattlegroundTypeId bgTypeId = BattlegroundMgr :: BGTemplateId ( bgQueueTypeId );
uint8 arenaType = BattlegroundMgr :: BGArenaType ( bgQueueTypeId );
if ( bgTypeId == _player -> GetBattlegroundTypeId ())
2009-03-13 18:06:36 -06:00
{
2010-08-08 04:37:24 +02:00
bg = _player -> GetBattleground ();
2009-03-13 18:06:36 -06:00
//i cannot check any variable from player class because player class doesn't know if player is in 2v2 / 3v3 or 5v5 arena
//so i must use bg pointer to get that information
2009-04-08 16:33:46 -05:00
if ( bg && bg -> GetArenaType () == arenaType )
2009-03-13 18:06:36 -06:00
{
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusActive battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusActive ( & battlefieldStatus , bg , _player , i , _player -> GetBattlegroundQueueJoinTime ( bgQueueTypeId ), arenaType );
SendPacket ( battlefieldStatus . Write ());
2009-03-13 18:06:36 -06:00
continue ;
}
}
2012-10-12 00:26:05 +02:00
2009-03-13 18:06:36 -06:00
//we are sending update to player about queue - he can be invited there!
//get GroupQueueInfo for queue status
2012-10-04 10:39:37 +02:00
BattlegroundQueue & bgQueue = sBattlegroundMgr -> GetBattlegroundQueue ( bgQueueTypeId );
2010-02-15 15:31:27 +01:00
GroupQueueInfo ginfo ;
if ( ! bgQueue . GetPlayerGroupInfoData ( _player -> GetGUID (), & ginfo ))
2009-03-10 15:29:50 -06:00
continue ;
2010-02-15 15:31:27 +01:00
if ( ginfo . IsInvitedToBGInstanceGUID )
2009-03-13 18:06:36 -06:00
{
2010-12-22 21:25:23 +01:00
bg = sBattlegroundMgr -> GetBattleground ( ginfo . IsInvitedToBGInstanceGUID , bgTypeId );
2009-04-08 16:33:46 -05:00
if ( ! bg )
2009-03-13 18:06:36 -06:00
continue ;
2012-10-12 00:26:05 +02:00
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusNeedConfirmation battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusNeedConfirmation ( & battlefieldStatus , bg , _player , i , _player -> GetBattlegroundQueueJoinTime ( bgQueueTypeId ), getMSTimeDiff ( getMSTime (), ginfo . RemoveInviteTime ), arenaType );
SendPacket ( battlefieldStatus . Write ());
2009-03-13 18:06:36 -06:00
}
else
{
2010-12-22 21:25:23 +01:00
bg = sBattlegroundMgr -> GetBattlegroundTemplate ( bgTypeId );
2009-04-08 16:33:46 -05:00
if ( ! bg )
2009-03-13 18:06:36 -06:00
continue ;
2010-02-15 15:31:27 +01:00
// expected bracket entry
2011-04-29 20:47:02 +02:00
PvPDifficultyEntry const * bracketEntry = GetBattlegroundBracketByLevel ( bg -> GetMapId (), _player -> getLevel ());
2010-02-15 15:31:27 +01:00
if ( ! bracketEntry )
continue ;
uint32 avgTime = bgQueue . GetAverageQueueWaitTime ( & ginfo , bracketEntry -> GetBracketId ());
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusQueued battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusQueued ( & battlefieldStatus , bg , _player , i , _player -> GetBattlegroundQueueJoinTime ( bgQueueTypeId ), avgTime , arenaType , ginfo . Players . size () > 1 );
SendPacket ( battlefieldStatus . Write ());
2009-03-13 18:06:36 -06:00
}
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2016-01-20 22:51:06 +01:00
void WorldSession :: HandleBattlemasterJoinArena ( WorldPackets :: Battleground :: BattlemasterJoinArena & packet )
2008-10-11 14:16:25 -05:00
{
2009-08-19 16:54:52 -05:00
// ignore if we already in BG or BG queue
2010-08-08 04:37:24 +02:00
if ( _player -> InBattleground ())
2009-08-19 16:54:52 -05:00
return ;
2009-10-17 15:51:44 -07:00
2016-01-20 22:51:06 +01:00
uint8 arenatype = ArenaTeam :: GetTypeBySlot ( packet . TeamSizeIndex );
2009-10-17 15:51:44 -07:00
2016-01-20 22:51:06 +01:00
//check existence
2010-12-22 21:25:23 +01:00
Battleground * bg = sBattlegroundMgr -> GetBattlegroundTemplate ( BATTLEGROUND_AA );
2010-02-15 15:31:27 +01:00
if ( ! bg )
2008-10-11 14:16:25 -05:00
{
2013-11-08 10:50:51 +01:00
TC_LOG_ERROR ( "network" , "Battleground: template bg (all arenas) not found" );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2016-01-20 22:51:06 +01:00
if ( DisableMgr :: IsDisabledFor ( DISABLE_TYPE_BATTLEGROUND , BATTLEGROUND_AA , nullptr ))
2010-07-21 12:14:23 +02:00
{
ChatHandler ( this ). PSendSysMessage ( LANG_ARENA_DISABLED );
return ;
}
2010-08-08 04:37:24 +02:00
BattlegroundTypeId bgTypeId = bg -> GetTypeID ();
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr :: BGQueueTypeId ( bgTypeId , arenatype );
2011-04-29 20:47:02 +02:00
PvPDifficultyEntry const * bracketEntry = GetBattlegroundBracketByLevel ( bg -> GetMapId (), _player -> getLevel ());
2010-02-15 15:31:27 +01:00
if ( ! bracketEntry )
return ;
2009-10-17 15:51:44 -07:00
2012-11-20 10:37:25 +01:00
Group * grp = _player -> GetGroup ();
// no group found, error
if ( ! grp )
return ;
if ( grp -> GetLeaderGUID () != _player -> GetGUID ())
return ;
2012-11-21 18:26:28 +01:00
2016-01-20 22:51:06 +01:00
uint32 ateamId = _player -> GetArenaTeamId ( packet . TeamSizeIndex );
2012-11-20 10:37:25 +01:00
// check real arenateam existence only here (if it was moved to group->CanJoin .. () then we would ahve to get it twice)
ArenaTeam * at = sArenaTeamMgr -> GetArenaTeamById ( ateamId );
if ( ! at )
2008-10-11 14:16:25 -05:00
{
2012-11-20 10:37:25 +01:00
_player -> GetSession () -> SendNotInArenaTeamPacket ( arenatype );
return ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2016-01-20 22:51:06 +01:00
// get the team rating for queuing
uint32 arenaRating = at -> GetRating ();
uint32 matchmakerRating = at -> GetAverageMMR ( grp );
2012-11-20 10:37:25 +01:00
// the arenateam id must match for everyone in the group
2012-11-21 18:26:28 +01:00
2012-11-20 10:37:25 +01:00
if ( arenaRating <= 0 )
arenaRating = 1 ;
2012-11-21 18:26:28 +01:00
2016-01-20 22:51:06 +01:00
BattlegroundQueue & bgQueue = sBattlegroundMgr -> GetBattlegroundQueue ( bgQueueTypeId );
2012-11-21 18:26:28 +01:00
2012-11-20 10:37:25 +01:00
uint32 avgTime = 0 ;
2016-01-20 22:51:06 +01:00
GroupQueueInfo * ginfo = nullptr ;
2012-11-21 18:26:28 +01:00
2015-04-17 00:06:24 +02:00
ObjectGuid errorGuid ;
2016-01-20 22:51:06 +01:00
GroupJoinBattlegroundResult err = grp -> CanJoinBattlegroundQueue ( bg , bgQueueTypeId , arenatype , arenatype , true , packet . TeamSizeIndex , errorGuid );
2012-11-20 10:37:25 +01:00
if ( ! err )
2008-10-11 14:16:25 -05:00
{
2016-01-20 22:51:06 +01:00
TC_LOG_DEBUG ( "bg.battleground" , "Battleground: arena team id %u, leader %s queued with matchmaker rating %u for type %u" , _player -> GetArenaTeamId ( packet . TeamSizeIndex ), _player -> GetName (). c_str (), matchmakerRating , arenatype );
2012-11-21 18:26:28 +01:00
2012-11-20 10:37:25 +01:00
ginfo = bgQueue . AddGroup ( _player , grp , bgTypeId , bracketEntry , arenatype , true , false , arenaRating , matchmakerRating , ateamId );
avgTime = bgQueue . GetAverageQueueWaitTime ( ginfo , bracketEntry -> GetBracketId ());
2010-04-21 18:49:57 +02:00
}
2012-11-21 18:26:28 +01:00
2016-01-20 22:51:06 +01:00
for ( GroupReference * itr = grp -> GetFirstMember (); itr != nullptr ; itr = itr -> next ())
2008-10-11 14:16:25 -05:00
{
2013-06-13 19:35:01 +02:00
Player * member = itr -> GetSource ();
2012-11-20 10:37:25 +01:00
if ( ! member )
continue ;
2012-11-21 18:26:28 +01:00
2012-11-20 10:37:25 +01:00
if ( err )
2008-10-11 14:16:25 -05:00
{
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusFailed battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusFailed ( & battlefieldStatus , bg , _player , 0 , arenatype , err , & errorGuid );
member -> SendDirectMessage ( battlefieldStatus . Write ());
2012-11-20 10:37:25 +01:00
continue ;
2008-10-11 14:16:25 -05:00
}
2012-11-21 18:26:28 +01:00
2012-11-20 10:37:25 +01:00
// add to queue
uint32 queueSlot = member -> AddBattlegroundQueueId ( bgQueueTypeId );
2012-11-21 18:26:28 +01:00
2015-04-17 00:06:24 +02:00
WorldPackets :: Battleground :: BattlefieldStatusQueued battlefieldStatus ;
sBattlegroundMgr -> BuildBattlegroundStatusQueued ( & battlefieldStatus , bg , member , queueSlot , ginfo -> JoinTime , avgTime , arenatype , true );
member -> SendDirectMessage ( battlefieldStatus . Write ());
2012-11-21 18:26:28 +01:00
2014-10-22 17:33:55 +02:00
TC_LOG_DEBUG ( "bg.battleground" , "Battleground: player joined queue for arena as group bg queue type %u bg type %u, %s, NAME %s" , bgQueueTypeId , bgTypeId , member -> GetGUID (). ToString (). c_str (), member -> GetName (). c_str ());
2008-10-11 14:16:25 -05:00
}
2012-11-21 18:26:28 +01:00
2010-12-22 21:25:23 +01:00
sBattlegroundMgr -> ScheduleQueueUpdate ( matchmakerRating , arenatype , bgQueueTypeId , bgTypeId , bracketEntry -> GetBracketId ());
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2015-04-18 00:04:56 +02:00
void WorldSession :: HandleReportPvPAFK ( WorldPackets :: Battleground :: ReportPvPPlayerAFK & reportPvPPlayerAFK )
2008-10-11 14:16:25 -05:00
{
2015-04-18 00:04:56 +02:00
Player * reportedPlayer = ObjectAccessor :: FindPlayer ( reportPvPPlayerAFK . Offender );
2009-04-08 16:33:46 -05:00
if ( ! reportedPlayer )
2008-10-11 14:16:25 -05:00
{
2013-11-08 10:50:51 +01:00
TC_LOG_DEBUG ( "bg.battleground" , "WorldSession::HandleReportPvPAFK: player not found" );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2013-11-08 10:50:51 +01:00
TC_LOG_DEBUG ( "bg.battleground" , "WorldSession::HandleReportPvPAFK: %s reported %s" , _player -> GetName (). c_str (), reportedPlayer -> GetName (). c_str ());
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
reportedPlayer -> ReportedAfkBy ( _player );
}
2012-11-21 18:25:23 +01:00
2015-02-01 20:52:05 +01:00
void WorldSession :: HandleRequestRatedBattlefieldInfo ( WorldPacket & recvData )
2012-11-21 18:25:23 +01:00
{
uint8 unk ;
recvData >> unk ;
2015-02-01 20:52:05 +01:00
TC_LOG_DEBUG ( "bg.battleground" , "WorldSession::HandleRequestRatedBattlefieldInfo: unk = %u" , unk );
2012-11-21 18:25:23 +01:00
/// @Todo: perfome research in this case
/// The unk fields are related to arenas
2015-03-27 22:21:24 +01:00
WorldPacket data ( SMSG_RATED_BATTLEFIELD_INFO , 72 );
2012-11-21 18:25:23 +01:00
data << uint32 ( 0 ); // BgWeeklyWins20vs20
data << uint32 ( 0 ); // BgWeeklyPlayed20vs20
data << uint32 ( 0 ); // BgWeeklyPlayed15vs15
data << uint32 ( 0 );
data << uint32 ( 0 ); // BgWeeklyWins10vs10
data << uint32 ( 0 );
data << uint32 ( 0 );
data << uint32 ( 0 );
data << uint32 ( 0 ); // BgWeeklyWins15vs15
data << uint32 ( 0 );
data << uint32 ( 0 );
data << uint32 ( 0 );
data << uint32 ( 0 );
data << uint32 ( 0 );
data << uint32 ( 0 );
data << uint32 ( 0 ); // BgWeeklyPlayed10vs10
data << uint32 ( 0 );
data << uint32 ( 0 );
SendPacket ( & data );
}
2015-04-17 00:06:24 +02:00
void WorldSession :: HandleGetPVPOptionsEnabled ( WorldPackets :: Battleground :: GetPVPOptionsEnabled & /*getPvPOptionsEnabled*/ )
2012-11-21 18:25:23 +01:00
{
2015-04-17 00:06:24 +02:00
// This packet is completely irrelevant, it triggers PVP_TYPES_ENABLED lua event but that is not handled in interface code as of 6.1.2
WorldPackets :: Battleground :: PVPOptionsEnabled pvpOptionsEnabled ;
pvpOptionsEnabled . WargameArenas = false ;
pvpOptionsEnabled . RatedArenas = false ;
pvpOptionsEnabled . WargameBattlegrounds = false ;
pvpOptionsEnabled . ArenaSkirmish = false ;
pvpOptionsEnabled . PugBattlegrounds = true ;
pvpOptionsEnabled . RatedBattlegrounds = false ;
SendPacket ( pvpOptionsEnabled . Write ());
2012-11-21 18:25:23 +01:00
}
2016-02-02 18:30:34 +01:00
void WorldSession :: HandleRequestPvpReward ( WorldPackets :: Battleground :: RequestPVPRewards & /*packet*/ )
2012-11-21 18:25:23 +01:00
{
_player -> SendPvpRewards ();
}
2015-04-08 19:34:04 +02:00
void WorldSession :: HandleAreaSpiritHealerQueryOpcode ( WorldPackets :: Battleground :: AreaSpiritHealerQuery & areaSpiritHealerQuery )
{
Creature * unit = GetPlayer () -> GetMap () -> GetCreature ( areaSpiritHealerQuery . HealerGuid );
if ( ! unit )
return ;
if ( ! unit -> IsSpiritService ()) // it's not spirit service
return ;
if ( Battleground * bg = _player -> GetBattleground ())
sBattlegroundMgr -> SendAreaSpiritHealerQueryOpcode ( _player , bg , areaSpiritHealerQuery . HealerGuid );
if ( Battlefield * bf = sBattlefieldMgr -> GetBattlefieldToZoneId ( _player -> GetZoneId ()))
bf -> SendAreaSpiritHealerQueryOpcode ( _player , areaSpiritHealerQuery . HealerGuid );
}
void WorldSession :: HandleAreaSpiritHealerQueueOpcode ( WorldPackets :: Battleground :: AreaSpiritHealerQueue & areaSpiritHealerQueue )
{
Creature * unit = GetPlayer () -> GetMap () -> GetCreature ( areaSpiritHealerQueue . HealerGuid );
if ( ! unit )
return ;
if ( ! unit -> IsSpiritService ()) // it's not spirit service
return ;
if ( Battleground * bg = _player -> GetBattleground ())
bg -> AddPlayerToResurrectQueue ( areaSpiritHealerQueue . HealerGuid , _player -> GetGUID ());
if ( Battlefield * bf = sBattlefieldMgr -> GetBattlefieldToZoneId ( _player -> GetZoneId ()))
bf -> AddPlayerToResurrectQueue ( areaSpiritHealerQueue . HealerGuid , _player -> GetGUID ());
}
void WorldSession :: HandleHearthAndResurrect ( WorldPackets :: Battleground :: HearthAndResurrect & /*hearthAndResurrect*/ )
{
if ( _player -> IsInFlight ())
return ;
if ( /*Battlefield* bf = */ sBattlefieldMgr -> GetBattlefieldToZoneId ( _player -> GetZoneId ()))
{
// bf->PlayerAskToLeave(_player); FIXME
return ;
}
2016-02-02 19:13:04 +01:00
AreaTableEntry const * atEntry = sAreaTableStore . LookupEntry ( _player -> GetAreaId ());
2015-04-08 19:34:04 +02:00
if ( ! atEntry || ! ( atEntry -> Flags [ 0 ] & AREA_FLAG_CAN_HEARTH_AND_RESURRECT ))
return ;
_player -> BuildPlayerRepop ();
_player -> ResurrectPlayer ( 1.0f );
_player -> TeleportTo ( _player -> m_homebindMapId , _player -> m_homebindX , _player -> m_homebindY , _player -> m_homebindZ , _player -> GetOrientation ());
}