2008-10-11 14:16:25 -05:00
/*
2009-02-04 12:42:26 +01:00
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
2008-10-14 11:57:03 -05:00
*
2009-02-04 12:04:12 +01:00
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
2008-10-11 14:16:25 -05:00
*
* 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
2008-12-19 16:05:13 -06:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2008-10-11 14:16:25 -05:00
* 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, write to the Free Software
2008-12-19 16:05:13 -06:00
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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"
2009-06-04 21:41:07 +02:00
#include "WorldPacket.h"
2008-10-11 14:16:25 -05:00
#include "WorldSession.h"
2009-06-04 21:41:07 +02:00
#include "ArenaTeam.h"
2008-10-11 14:16:25 -05:00
#include "BattleGroundMgr.h"
#include "BattleGroundWS.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"
2008-10-11 14:16:25 -05:00
2009-05-31 15:56:51 -05:00
void WorldSession :: HandleBattlemasterHelloOpcode ( WorldPacket & recv_data )
2008-10-11 14:16:25 -05:00
{
uint64 guid ;
recv_data >> guid ;
2009-05-31 16:15:12 -05:00
sLog . outDebug ( "WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from (GUID: %u TypeId:%u)" , GUID_LOPART ( guid ), GuidHigh2TypeId ( GUID_HIPART ( guid )));
2008-10-11 14:16:25 -05:00
2009-04-20 20:28:19 -05:00
Creature * unit = GetPlayer () -> GetMap () -> GetCreature ( guid );
2009-04-08 16:33:46 -05:00
if ( ! unit )
2008-10-11 14:16:25 -05:00
return ;
if ( ! unit -> isBattleMaster ()) // it's not battlemaster
return ;
// Stop the npc if moving
unit -> StopMoving ();
2009-02-09 22:08:06 -06:00
BattleGroundTypeId bgTypeId = sBattleGroundMgr . GetBattleMasterBG ( unit -> GetEntry ());
2008-10-11 14:16:25 -05: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 ;
}
SendBattlegGroundList ( guid , bgTypeId );
}
2009-02-09 22:08:06 -06:00
void WorldSession :: SendBattlegGroundList ( uint64 guid , BattleGroundTypeId bgTypeId )
2008-10-11 14:16:25 -05:00
{
WorldPacket data ;
2009-06-11 00:45:59 -05:00
sBattleGroundMgr . BuildBattleGroundListPacket ( & data , guid , _player , bgTypeId , 0 );
2008-10-11 14:16:25 -05:00
SendPacket ( & data );
}
2009-05-31 15:56:51 -05:00
void WorldSession :: HandleBattlemasterJoinOpcode ( WorldPacket & recv_data )
2008-10-11 14:16:25 -05:00
{
uint64 guid ;
2009-02-09 22:08:06 -06:00
uint32 bgTypeId_ ;
2008-10-11 14:16:25 -05:00
uint32 instanceId ;
uint8 joinAsGroup ;
2009-02-27 12:13:59 -06:00
bool isPremade = false ;
2008-10-11 14:16:25 -05:00
Group * grp ;
recv_data >> guid ; // battlemaster guid
2009-02-09 22:08:06 -06:00
recv_data >> bgTypeId_ ; // battleground type id (DBC id)
2008-10-11 14:16:25 -05:00
recv_data >> instanceId ; // instance id, 0 if First Available selected
recv_data >> joinAsGroup ; // join as group
2009-04-08 16:33:46 -05:00
if ( ! sBattlemasterListStore . LookupEntry ( bgTypeId_ ))
2008-10-11 14:16:25 -05:00
{
2009-02-09 22:08:06 -06:00
sLog . outError ( "Battleground: invalid bgtype (%u) received. possible cheater? player guid %u" , bgTypeId_ , _player -> GetGUIDLow ());
2008-10-11 14:16:25 -05:00
return ;
}
2009-02-09 22:08:06 -06:00
BattleGroundTypeId bgTypeId = BattleGroundTypeId ( bgTypeId_ );
2009-05-31 16:15:12 -05:00
sLog . outDebug ( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from (GUID: %u TypeId:%u)" , GUID_LOPART ( guid ), GuidHigh2TypeId ( GUID_HIPART ( guid )));
2008-10-11 14:16:25 -05:00
// can do this, since it's battleground, not arena
2009-02-13 19:56:22 -06:00
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr :: BGQueueTypeId ( bgTypeId , 0 );
2008-10-11 14:16:25 -05:00
2008-12-19 16:05:13 -06:00
// ignore if player is already in BG
2009-04-08 16:33:46 -05:00
if ( _player -> InBattleGround ())
2008-10-11 14:16:25 -05:00
return ;
// get bg instance or bg template if instance not found
2009-04-27 18:42:35 -05:00
BattleGround * bg = NULL ;
2009-04-08 16:33:46 -05:00
if ( instanceId )
2009-04-29 00:31:03 -05:00
bg = sBattleGroundMgr . GetBattleGroundThroughClientInstance ( instanceId , bgTypeId );
2008-10-11 14:16:25 -05:00
2009-04-08 16:33:46 -05:00
if ( ! bg && ! ( bg = sBattleGroundMgr . GetBattleGroundTemplate ( bgTypeId )))
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "Battleground: no available bg / template found" );
return ;
}
// check queueing conditions
2009-04-08 16:33:46 -05:00
if ( ! joinAsGroup )
2008-10-11 14:16:25 -05:00
{
// check Deserter debuff
2009-04-08 16:33:46 -05:00
if ( ! _player -> CanJoinToBattleground ())
2008-10-11 14:16:25 -05:00
{
WorldPacket data ( SMSG_GROUP_JOINED_BATTLEGROUND , 4 );
2009-03-12 14:50:59 -06:00
data << uint32 ( 0xFFFFFFFE );
2008-10-11 14:16:25 -05:00
_player -> GetSession () -> SendPacket ( & data );
return ;
}
// check if already in queue
if ( _player -> GetBattleGroundQueueIndex ( bgQueueTypeId ) < PLAYER_MAX_BATTLEGROUND_QUEUES )
//player is already in this queue
return ;
// check if has free queue slots
2009-04-08 16:33:46 -05:00
if ( ! _player -> HasFreeBattleGroundQueueId ())
2008-10-11 14:16:25 -05:00
return ;
}
else
{
grp = _player -> GetGroup ();
// no group found, error
2009-04-08 16:33:46 -05:00
if ( ! grp )
2008-10-11 14:16:25 -05:00
return ;
uint32 err = grp -> CanJoinBattleGroundQueue ( bgTypeId , bgQueueTypeId , 0 , bg -> GetMaxPlayersPerTeam (), false , 0 );
2009-02-27 12:13:59 -06:00
isPremade = ( grp -> GetMembersCount () >= bg -> GetMinPlayersPerTeam ());
2008-12-19 16:05:13 -06:00
if ( err != BG_JOIN_ERR_OK )
2008-10-11 14:16:25 -05:00
{
2008-12-19 16:05:13 -06:00
SendBattleGroundOrArenaJoinError ( err );
2008-10-11 14:16:25 -05:00
return ;
2008-12-19 16:05:13 -06:00
}
2008-10-11 14:16:25 -05:00
}
// if we're here, then the conditions to join a bg are met. We can proceed in joining.
// _player->GetGroup() was already checked, grp is already initialized
2009-03-10 15:29:50 -06:00
GroupQueueInfo * ginfo = sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. AddGroup ( _player , bgTypeId , 0 , false , isPremade , 0 );
uint32 avgTime = sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. GetAverageQueueWaitTime ( ginfo , _player -> GetBattleGroundQueueIdFromLevel ( bgTypeId ));
2009-04-08 16:33:46 -05:00
if ( joinAsGroup /* && _player->GetGroup()*/ )
2008-10-11 14:16:25 -05:00
{
sLog . outDebug ( "Battleground: the following players are joining as group:" );
for ( GroupReference * itr = grp -> GetFirstMember (); itr != NULL ; itr = itr -> next ())
{
Player * member = itr -> getSource ();
if ( ! member ) continue ; // this should never happen
uint32 queueSlot = member -> AddBattleGroundQueueId ( bgQueueTypeId ); // add to queue
WorldPacket data ;
// send status packet (in queue)
2009-03-13 18:06:36 -06:00
sBattleGroundMgr . BuildBattleGroundStatusPacket ( & data , bg , queueSlot , STATUS_WAIT_QUEUE , avgTime , 0 , ginfo -> ArenaType );
2008-10-11 14:16:25 -05:00
member -> GetSession () -> SendPacket ( & data );
sBattleGroundMgr . BuildGroupJoinedBattlegroundPacket ( & data , bgTypeId );
member -> GetSession () -> SendPacket ( & data );
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. AddPlayer ( member , ginfo );
sLog . outDebug ( "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s" , bgQueueTypeId , bgTypeId , member -> GetGUIDLow (), member -> GetName ());
}
sLog . outDebug ( "Battleground: group end" );
}
else
{
// already checked if queueSlot is valid, now just get it
uint32 queueSlot = _player -> AddBattleGroundQueueId ( bgQueueTypeId );
WorldPacket data ;
// send status packet (in queue)
2009-03-13 18:06:36 -06:00
sBattleGroundMgr . BuildBattleGroundStatusPacket ( & data , bg , queueSlot , STATUS_WAIT_QUEUE , avgTime , 0 , ginfo -> ArenaType );
2008-10-11 14:16:25 -05:00
SendPacket ( & data );
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. AddPlayer ( _player , ginfo );
sLog . outDebug ( "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s" , bgQueueTypeId , bgTypeId , _player -> GetGUIDLow (), _player -> GetName ());
}
2009-03-10 15:29:50 -06:00
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. Update ( bgTypeId , _player -> GetBattleGroundQueueIdFromLevel ( bgTypeId ));
2009-04-08 16:33:46 -05:00
if ( ! ginfo -> IsInvitedToBGInstanceGUID )
2009-03-10 15:29:50 -06:00
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. AnnounceWorld ( ginfo , _player -> GetGUID (), true );
2008-10-11 14:16:25 -05:00
}
void WorldSession :: HandleBattleGroundPlayerPositionsOpcode ( WorldPacket & /*recv_data*/ )
{
// empty opcode
sLog . outDebug ( "WORLD: Recvd MSG_BATTLEGROUND_PLAYER_POSITIONS Message" );
BattleGround * bg = _player -> GetBattleGround ();
if ( ! bg ) // can't be received if player not in battleground
return ;
2009-04-08 16:28:58 -05:00
switch ( bg -> GetTypeID () )
2008-10-11 14:16:25 -05:00
{
2009-04-08 16:28:58 -05:00
case BATTLEGROUND_WS :
{
uint32 count1 = 0 ; //always constant zero?
uint32 count2 = 0 ; //count of next fields
Player * ali_plr = objmgr . GetPlayer ((( BattleGroundWS * ) bg ) -> GetAllianceFlagPickerGUID ());
2009-04-08 16:33:46 -05:00
if ( ali_plr )
2009-04-08 16:28:58 -05:00
++ count2 ;
Player * horde_plr = objmgr . GetPlayer ((( BattleGroundWS * ) bg ) -> GetHordeFlagPickerGUID ());
2009-04-08 16:33:46 -05:00
if ( horde_plr )
2009-04-08 16:28:58 -05:00
++ count2 ;
WorldPacket data ( MSG_BATTLEGROUND_PLAYER_POSITIONS , ( 4 + 4 + 16 * count1 + 16 * count2 ));
data << count1 ; // alliance flag holders count - obsolete, now always 0
2009-04-29 00:26:07 -05:00
/*for(uint8 i = 0; i < count1; ++i)
2009-04-08 16:28:58 -05:00
{
data << uint64(0); // guid
data << (float)0; // x
data << (float)0; // y
}*/
data << count2 ; // horde flag holders count - obsolete, now count of next fields
2009-04-08 16:33:46 -05:00
if ( ali_plr )
2009-04-08 16:28:58 -05:00
{
data << ( uint64 ) ali_plr -> GetGUID ();
data << ( float ) ali_plr -> GetPositionX ();
data << ( float ) ali_plr -> GetPositionY ();
}
2009-04-08 16:33:46 -05:00
if ( horde_plr )
2009-04-08 16:28:58 -05:00
{
data << ( uint64 ) horde_plr -> GetGUID ();
data << ( float ) horde_plr -> GetPositionX ();
data << ( float ) horde_plr -> GetPositionY ();
}
SendPacket ( & data );
}
break ;
case BATTLEGROUND_EY :
//TODO : fix me!
break ;
case BATTLEGROUND_AB :
case BATTLEGROUND_AV :
{
//for other BG types - send default
WorldPacket data ( MSG_BATTLEGROUND_PLAYER_POSITIONS , ( 4 + 4 ));
data << uint32 ( 0 );
data << uint32 ( 0 );
SendPacket ( & data );
}
break ;
default :
//maybe it is sent also in arena - do nothing
break ;
2008-10-11 14:16:25 -05:00
}
}
2009-05-31 15:56:51 -05:00
void WorldSession :: HandlePVPLogDataOpcode ( WorldPacket & /*recv_data*/ )
2008-10-11 14:16:25 -05:00
{
sLog . outDebug ( "WORLD: Recvd MSG_PVP_LOG_DATA Message" );
BattleGround * bg = _player -> GetBattleGround ();
2009-04-08 16:33:46 -05:00
if ( ! bg )
2008-10-11 14:16:25 -05:00
return ;
WorldPacket data ;
sBattleGroundMgr . BuildPvpLogDataPacket ( & data , bg );
SendPacket ( & data );
sLog . outDebug ( "WORLD: Sent MSG_PVP_LOG_DATA Message" );
}
2009-05-31 15:56:51 -05:00
void WorldSession :: HandleBattlefieldListOpcode ( WorldPacket & recv_data )
2008-10-11 14:16:25 -05:00
{
sLog . outDebug ( "WORLD: Recvd CMSG_BATTLEFIELD_LIST Message" );
uint32 bgTypeId ;
recv_data >> bgTypeId ; // id from DBC
2009-06-11 00:45:59 -05:00
uint8 fromWhere ;
recv_data >> fromWhere ; // 0 - battlemaster, 1 - UI
2009-02-09 22:08:06 -06:00
BattlemasterListEntry const * bl = sBattlemasterListStore . LookupEntry ( bgTypeId );
2009-04-08 16:33:46 -05:00
if ( ! bl )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "Battleground: invalid bgtype received." );
return ;
}
WorldPacket data ;
2009-06-11 00:45:59 -05:00
sBattleGroundMgr . BuildBattleGroundListPacket ( & data , 0 , _player , BattleGroundTypeId ( bgTypeId ), fromWhere );
2008-10-11 14:16:25 -05:00
SendPacket ( & data );
}
2009-05-31 15:56:51 -05:00
void WorldSession :: HandleBattleFieldPortOpcode ( WorldPacket & recv_data )
2008-10-11 14:16:25 -05:00
{
sLog . outDebug ( "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message" );
uint8 type ; // arenatype if arena
uint8 unk2 ; // unk, can be 0x0 (may be if was invited?) and 0x1
2008-12-19 16:05:13 -06:00
uint32 instanceId ;
2009-02-09 22:08:06 -06:00
uint32 bgTypeId_ ; // type id from dbc
2008-10-11 14:16:25 -05:00
uint16 unk ; // 0x1F90 constant?
uint8 action ; // enter battle 0x1, leave queue 0x0
2009-02-09 22:08:06 -06:00
recv_data >> type >> unk2 >> bgTypeId_ >> unk >> action ;
2008-10-11 14:16:25 -05:00
2009-04-08 16:33:46 -05:00
if ( ! sBattlemasterListStore . LookupEntry ( bgTypeId_ ))
2008-10-11 14:16:25 -05:00
{
2009-03-12 14:50:59 -06:00
sLog . outError ( "Battleground: invalid bgtype (%u) received." , bgTypeId_ );
2008-10-11 14:16:25 -05:00
// update battleground slots for the player to fix his UI and sent data.
// this is a HACK, I don't know why the client starts sending invalid packets in the first place.
// it usually happens with extremely high latency (if debugging / stepping in the code for example)
2009-04-08 16:33:46 -05:00
if ( _player -> InBattleGroundQueue ())
2008-10-11 14:16:25 -05:00
{
// update all queues, send invitation info if player is invited, queue info if queued
2009-04-29 00:26:07 -05:00
for ( uint32 i = 0 ; i < PLAYER_MAX_BATTLEGROUND_QUEUES ; ++ i )
2008-10-11 14:16:25 -05:00
{
2009-02-13 19:56:22 -06:00
BattleGroundQueueTypeId bgQueueTypeId = _player -> GetBattleGroundQueueTypeId ( i );
2009-04-08 16:33:46 -05:00
if ( ! bgQueueTypeId )
2008-10-11 14:16:25 -05:00
continue ;
2009-02-13 20:07:49 -06:00
BattleGroundTypeId bgTypeId = BattleGroundMgr :: BGTemplateId ( bgQueueTypeId );
2009-02-27 12:13:59 -06:00
BattleGroundQueue :: QueuedPlayersMap & qpMap = sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. m_QueuedPlayers ;
2009-02-13 20:07:49 -06:00
BattleGroundQueue :: QueuedPlayersMap :: iterator itrPlayerStatus = qpMap . find ( _player -> GetGUID ());
2009-03-10 15:29:50 -06:00
// if the player is not in queue, continue or no group information - this should never happen
2009-04-08 16:33:46 -05:00
if ( itrPlayerStatus == qpMap . end () || ! itrPlayerStatus -> second . GroupInfo )
2008-10-11 14:16:25 -05:00
continue ;
BattleGround * bg = NULL ;
// get possibly needed data from groupinfo
uint8 arenatype = itrPlayerStatus -> second . GroupInfo -> ArenaType ;
uint8 status = 0 ;
2009-04-08 16:33:46 -05:00
if ( ! itrPlayerStatus -> second . GroupInfo -> IsInvitedToBGInstanceGUID )
2008-10-11 14:16:25 -05:00
{
// not invited to bg, get template
bg = sBattleGroundMgr . GetBattleGroundTemplate ( bgTypeId );
status = STATUS_WAIT_QUEUE ;
}
else
{
// get the bg we're invited to
2009-04-27 18:42:35 -05:00
bg = sBattleGroundMgr . GetBattleGround ( itrPlayerStatus -> second . GroupInfo -> IsInvitedToBGInstanceGUID , bgTypeId );
2008-10-11 14:16:25 -05:00
status = STATUS_WAIT_JOIN ;
}
2009-03-12 14:50:59 -06:00
// if bg not found, then continue, don't invite if already in the instance
2009-04-08 16:33:46 -05:00
if ( ! bg || ( _player -> InBattleGround () && _player -> GetBattleGround () && _player -> GetBattleGround () -> GetInstanceID () == bg -> GetInstanceID ()))
2008-10-11 14:16:25 -05:00
continue ;
// re - invite player with proper data
WorldPacket data ;
2009-03-09 17:08:07 -06:00
sBattleGroundMgr . BuildBattleGroundStatusPacket ( & data , bg , i , status , INVITE_ACCEPT_WAIT_TIME , 0 , arenatype );
2008-10-11 14:16:25 -05:00
SendPacket ( & data );
}
}
return ;
}
2009-03-12 14:50:59 -06:00
//get GroupQueueInfo from BattleGroundQueue
2009-02-09 22:08:06 -06:00
BattleGroundTypeId bgTypeId = BattleGroundTypeId ( bgTypeId_ );
2009-03-12 14:50:59 -06:00
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr :: BGQueueTypeId ( bgTypeId , type );
2009-02-27 12:13:59 -06:00
BattleGroundQueue :: QueuedPlayersMap & qpMap = sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. m_QueuedPlayers ;
2009-02-13 20:07:49 -06:00
BattleGroundQueue :: QueuedPlayersMap :: iterator itrPlayerStatus = qpMap . find ( _player -> GetGUID ());
2009-04-08 16:33:46 -05:00
if ( itrPlayerStatus == qpMap . end ())
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "Battleground: itrplayerstatus not found." );
return ;
}
2009-03-12 14:50:59 -06:00
instanceId = itrPlayerStatus -> second . GroupInfo -> IsInvitedToBGInstanceGUID ;
// if action == 1, then instanceId is required
2009-04-08 16:33:46 -05:00
if ( ! instanceId && action == 1 )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "Battleground: instance not found." );
return ;
}
2009-02-27 12:57:33 -06:00
BattleGround * bg = sBattleGroundMgr . GetBattleGround ( instanceId , bgTypeId );
2008-10-11 14:16:25 -05:00
// bg template might and must be used in case of leaving queue, when instance is not created yet
2009-04-08 16:33:46 -05:00
if ( ! bg && action == 0 )
2008-10-11 14:16:25 -05:00
bg = sBattleGroundMgr . GetBattleGroundTemplate ( bgTypeId );
2009-04-08 16:33:46 -05:00
if ( ! bg )
2008-10-11 14:16:25 -05:00
{
2009-03-12 14:50:59 -06:00
sLog . outError ( "Battleground: bg_template not found for type id %u." , bgTypeId );
2008-10-11 14:16:25 -05:00
return ;
}
2009-04-08 16:33:46 -05:00
if ( _player -> InBattleGroundQueue ())
2008-10-11 14:16:25 -05:00
{
2009-03-12 14:50:59 -06:00
//we must use temporary variables, because GroupQueueInfo pointer can be deleted in BattleGroundQueue::RemovePlayer() function!
uint32 team = itrPlayerStatus -> second . GroupInfo -> Team ;
uint32 arenaType = itrPlayerStatus -> second . GroupInfo -> ArenaType ;
uint32 isRated = itrPlayerStatus -> second . GroupInfo -> IsRated ;
uint32 rating = itrPlayerStatus -> second . GroupInfo -> ArenaTeamRating ;
uint32 opponentsRating = itrPlayerStatus -> second . GroupInfo -> OpponentsTeamRating ;
//some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it
2009-04-08 16:33:46 -05:00
if ( action == 1 && arenaType == 0 )
2008-10-11 14:16:25 -05:00
{
2009-03-12 14:50:59 -06:00
//if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue
2009-04-08 16:33:46 -05:00
if ( ! _player -> CanJoinToBattleground ())
2009-03-12 14:50:59 -06:00
{
//send bg command result to show nice message
WorldPacket data2 ( SMSG_GROUP_JOINED_BATTLEGROUND , 4 );
data2 << uint32 ( 0xFFFFFFFE );
_player -> GetSession () -> SendPacket ( & data2 );
action = 0 ;
sLog . outDebug ( "Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!" , _player -> GetName (), _player -> GetGUIDLow ());
}
//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
2009-04-08 16:33:46 -05:00
if ( _player -> getLevel () > bg -> GetMaxLevel ())
2009-03-12 14:50:59 -06:00
{
sLog . outError ( "Battleground: Player %s (%u) has level higher than maxlevel of battleground! Do not port him to battleground!" , _player -> GetName (), _player -> GetGUIDLow ());
action = 0 ;
}
2009-03-09 17:01:18 -06:00
}
2009-03-12 14:50:59 -06:00
uint32 queueSlot = _player -> GetBattleGroundQueueIndex ( bgQueueTypeId );
2008-10-11 14:16:25 -05:00
WorldPacket data ;
2009-03-12 14:50:59 -06:00
switch ( action )
2008-10-11 14:16:25 -05:00
{
2009-03-12 14:50:59 -06:00
case 1 : // port to battleground
2009-04-08 16:33:46 -05:00
if ( ! _player -> IsInvitedForBattleGroundQueueType ( bgQueueTypeId ))
2009-03-12 14:50:59 -06:00
return ; // cheating?
2009-08-12 20:27:00 -05:00
_player -> SetBattleGroundEntryPoint ();
2008-10-11 14:16:25 -05:00
// resurrect the player
2009-04-08 16:33:46 -05:00
if ( ! _player -> isAlive ())
2008-10-11 14:16:25 -05:00
{
2008-12-19 16:05:13 -06:00
_player -> ResurrectPlayer ( 1.0f );
2008-10-11 14:16:25 -05:00
_player -> SpawnCorpseBones ();
}
// stop taxi flight at port
2009-04-08 16:33:46 -05:00
if ( _player -> isInFlight ())
2008-10-11 14:16:25 -05:00
{
_player -> GetMotionMaster () -> MovementExpired ();
2009-07-01 16:18:37 +02:00
_player -> CleanupAfterTaxiFlight ();
2008-10-11 14:16:25 -05:00
}
2009-03-12 14:50:59 -06:00
2009-03-13 18:06:36 -06:00
sBattleGroundMgr . BuildBattleGroundStatusPacket ( & data , bg , queueSlot , STATUS_IN_PROGRESS , 0 , bg -> GetStartTime (), bg -> GetArenaType ());
2008-10-11 14:16:25 -05:00
_player -> GetSession () -> SendPacket ( & data );
// remove battleground queue status from BGmgr
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. RemovePlayer ( _player -> GetGUID (), false );
// this is still needed here if battleground "jumping" shouldn't add deserter debuff
2009-03-12 14:50:59 -06:00
// also this is required to prevent stuck at old battleground after SetBattleGroundId set to new
2009-04-08 16:33:46 -05:00
if ( BattleGround * currentBg = _player -> GetBattleGround ())
2008-10-11 14:16:25 -05:00
currentBg -> RemovePlayerAtLeave ( _player -> GetGUID (), false , true );
// set the destination instance id
2009-02-27 12:57:33 -06:00
_player -> SetBattleGroundId ( bg -> GetInstanceID (), bgTypeId );
2008-10-11 14:16:25 -05:00
// set the destination team
_player -> SetBGTeam ( team );
2009-05-18 00:11:39 +02:00
// clear AFK
if ( _player -> isAFK ())
_player -> ToggleAFK ();
2008-10-11 14:16:25 -05:00
// bg->HandleBeforeTeleportToBattleGround(_player);
2009-02-27 12:57:33 -06:00
sBattleGroundMgr . SendToBattleGround ( _player , instanceId , bgTypeId );
2008-10-11 14:16:25 -05:00
// add only in HandleMoveWorldPortAck()
// bg->AddPlayer(_player,team);
2009-03-12 14:50:59 -06:00
sLog . outDebug ( "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u." , _player -> GetName (), _player -> GetGUIDLow (), bg -> GetInstanceID (), bg -> GetTypeID (), bgQueueTypeId );
2008-10-11 14:16:25 -05:00
break ;
2009-02-10 01:06:39 -06:00
case 0 : // leave queue
2009-03-12 14:50:59 -06:00
// if player leaves rated arena match before match start, it is counted as he played but he lost
2009-04-08 16:33:46 -05:00
if ( isRated )
2008-12-19 16:05:13 -06:00
{
ArenaTeam * at = objmgr . GetArenaTeamById ( team );
2009-04-08 16:33:46 -05:00
if ( at )
2008-12-19 16:05:13 -06:00
{
sLog . outDebug ( "UPDATING memberLost's personal arena rating for %u by opponents rating: %u, because he has left queue!" , GUID_LOPART ( _player -> GetGUID ()), opponentsRating );
at -> MemberLost ( _player , opponentsRating );
at -> SaveToDB ();
}
}
2009-03-12 14:50:59 -06:00
_player -> RemoveBattleGroundQueueId ( bgQueueTypeId ); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs
2009-03-13 18:06:36 -06:00
sBattleGroundMgr . BuildBattleGroundStatusPacket ( & data , bg , queueSlot , STATUS_NONE , 0 , 0 , 0 );
2008-10-11 14:16:25 -05:00
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. RemovePlayer ( _player -> GetGUID (), true );
2009-03-12 14:50:59 -06:00
// player left queue, we should update it - do not update Arena Queue
2009-04-08 16:33:46 -05:00
if ( ! arenaType )
2009-03-12 14:50:59 -06:00
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. Update ( bgTypeId , _player -> GetBattleGroundQueueIdFromLevel ( bgTypeId ), arenaType , isRated , rating );
2008-10-11 14:16:25 -05:00
SendPacket ( & data );
2009-03-12 14:50:59 -06:00
sLog . outDebug ( "Battleground: player %s (%u) left queue for bgtype %u, queue type %u." , _player -> GetName (), _player -> GetGUIDLow (), bg -> GetTypeID (), bgQueueTypeId );
2008-10-11 14:16:25 -05:00
break ;
default :
sLog . outError ( "Battleground port: unknown action %u" , action );
break ;
}
}
}
2009-05-31 15:56:51 -05:00
void WorldSession :: HandleLeaveBattlefieldOpcode ( WorldPacket & /*recv_data*/ )
2008-10-11 14:16:25 -05:00
{
sLog . outDebug ( "WORLD: Recvd CMSG_LEAVE_BATTLEFIELD Message" );
//uint8 unk1, unk2;
//uint32 bgTypeId; // id from DBC
//uint16 unk3;
//recv_data >> unk1 >> unk2 >> bgTypeId >> unk3; - no used currently
//if(bgTypeId >= MAX_BATTLEGROUND_TYPES) // cheating? but not important in this case
// return;
// not allow leave battleground in combat
2009-04-08 16:33:46 -05:00
if ( _player -> isInCombat ())
if ( BattleGround * bg = _player -> GetBattleGround ())
if ( bg -> GetStatus () != STATUS_WAIT_LEAVE )
2008-10-11 14:16:25 -05:00
return ;
_player -> LeaveBattleground ();
}
void WorldSession :: HandleBattlefieldStatusOpcode ( WorldPacket & /*recv_data*/ )
{
// empty opcode
sLog . outDebug ( "WORLD: Battleground status" );
WorldPacket data ;
2009-03-13 18:06:36 -06:00
// we must update all queues here
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
{
2009-03-10 15:29:50 -06: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 ;
BattleGroundTypeId bgTypeId = BattleGroundMgr :: BGTemplateId ( bgQueueTypeId );
2009-03-13 18:06:36 -06:00
uint8 arenaType = BattleGroundMgr :: BGArenaType ( bgQueueTypeId );
2009-04-08 16:33:46 -05:00
if ( bgTypeId == _player -> GetBattleGroundTypeId ())
2009-03-13 18:06:36 -06:00
{
bg = _player -> GetBattleGround ();
//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
{
// this line is checked, i only don't know if GetStartTime is changing itself after bg end!
// send status in BattleGround
sBattleGroundMgr . BuildBattleGroundStatusPacket ( & data , bg , i , STATUS_IN_PROGRESS , bg -> GetEndTime (), bg -> GetStartTime (), arenaType );
SendPacket ( & data );
continue ;
}
}
//we are sending update to player about queue - he can be invited there!
//get GroupQueueInfo for queue status
2009-03-10 15:29:50 -06:00
BattleGroundQueue :: QueuedPlayersMap & qpMap = sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. m_QueuedPlayers ;
BattleGroundQueue :: QueuedPlayersMap :: iterator itrPlayerStatus = qpMap . find ( _player -> GetGUID ());
2009-04-08 16:33:46 -05:00
if ( itrPlayerStatus == qpMap . end ())
2009-03-10 15:29:50 -06:00
continue ;
2009-04-08 16:33:46 -05:00
if ( itrPlayerStatus -> second . GroupInfo -> IsInvitedToBGInstanceGUID )
2009-03-13 18:06:36 -06:00
{
bg = sBattleGroundMgr . GetBattleGround ( itrPlayerStatus -> second . GroupInfo -> IsInvitedToBGInstanceGUID , bgTypeId );
2009-04-08 16:33:46 -05:00
if ( ! bg )
2009-03-13 18:06:36 -06:00
continue ;
uint32 remainingTime = getMSTimeDiff ( getMSTime (), itrPlayerStatus -> second . GroupInfo -> RemoveInviteTime );
// send status invited to BattleGround
sBattleGroundMgr . BuildBattleGroundStatusPacket ( & data , bg , i , STATUS_WAIT_JOIN , remainingTime , 0 , arenaType );
SendPacket ( & data );
}
else
{
2009-04-27 18:42:35 -05:00
bg = sBattleGroundMgr . GetBattleGroundTemplate ( bgTypeId );
2009-04-08 16:33:46 -05:00
if ( ! bg )
2009-03-13 18:06:36 -06:00
continue ;
uint32 avgTime = sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. GetAverageQueueWaitTime ( itrPlayerStatus -> second . GroupInfo , _player -> GetBattleGroundQueueIdFromLevel ( bgTypeId ));
// send status in BattleGround Queue
sBattleGroundMgr . BuildBattleGroundStatusPacket ( & data , bg , i , STATUS_WAIT_QUEUE , avgTime , getMSTimeDiff ( itrPlayerStatus -> second . GroupInfo -> JoinTime , getMSTime ()), arenaType );
SendPacket ( & data );
}
2008-10-11 14:16:25 -05:00
}
}
void WorldSession :: HandleAreaSpiritHealerQueryOpcode ( WorldPacket & recv_data )
{
sLog . outDebug ( "WORLD: CMSG_AREA_SPIRIT_HEALER_QUERY" );
BattleGround * bg = _player -> GetBattleGround ();
2009-04-08 16:33:46 -05:00
if ( ! bg )
2008-10-11 14:16:25 -05:00
return ;
uint64 guid ;
recv_data >> guid ;
2009-04-20 20:28:19 -05:00
Creature * unit = GetPlayer () -> GetMap () -> GetCreature ( guid );
2009-04-08 16:33:46 -05:00
if ( ! unit )
2008-10-11 14:16:25 -05:00
return ;
if ( ! unit -> isSpiritService ()) // it's not spirit service
return ;
sBattleGroundMgr . SendAreaSpiritHealerQueryOpcode ( _player , bg , guid );
}
void WorldSession :: HandleAreaSpiritHealerQueueOpcode ( WorldPacket & recv_data )
{
sLog . outDebug ( "WORLD: CMSG_AREA_SPIRIT_HEALER_QUEUE" );
BattleGround * bg = _player -> GetBattleGround ();
2009-04-08 16:33:46 -05:00
if ( ! bg )
2008-10-11 14:16:25 -05:00
return ;
uint64 guid ;
recv_data >> guid ;
2009-04-20 20:28:19 -05:00
Creature * unit = GetPlayer () -> GetMap () -> GetCreature ( guid );
2009-04-08 16:33:46 -05:00
if ( ! unit )
2008-10-11 14:16:25 -05:00
return ;
if ( ! unit -> isSpiritService ()) // it's not spirit service
return ;
bg -> AddPlayerToResurrectQueue ( guid , _player -> GetGUID ());
}
2009-05-31 15:56:51 -05:00
void WorldSession :: HandleBattlemasterJoinArena ( WorldPacket & recv_data )
2008-10-11 14:16:25 -05:00
{
sLog . outDebug ( "WORLD: CMSG_BATTLEMASTER_JOIN_ARENA" );
2009-08-19 16:54:52 -05:00
//recv_data.hexlike();
2008-10-11 14:16:25 -05:00
uint64 guid ; // arena Battlemaster guid
2009-02-13 19:56:22 -06:00
uint8 arenaslot ; // 2v2, 3v3 or 5v5
2008-10-11 14:16:25 -05:00
uint8 asGroup ; // asGroup
uint8 isRated ; // isRated
Group * grp ;
2009-02-13 19:56:22 -06:00
recv_data >> guid >> arenaslot >> asGroup >> isRated ;
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
if ( _player -> InBattleGround ())
return ;
2009-04-20 20:28:19 -05:00
Creature * unit = GetPlayer () -> GetMap () -> GetCreature ( guid );
2009-04-08 16:33:46 -05:00
if ( ! unit )
2008-10-11 14:16:25 -05:00
return ;
if ( ! unit -> isBattleMaster ()) // it's not battle master
return ;
uint8 arenatype = 0 ;
uint32 arenaRating = 0 ;
2009-02-13 19:56:22 -06:00
switch ( arenaslot )
2008-10-11 14:16:25 -05:00
{
case 0 :
arenatype = ARENA_TYPE_2v2 ;
break ;
case 1 :
arenatype = ARENA_TYPE_3v3 ;
break ;
case 2 :
arenatype = ARENA_TYPE_5v5 ;
break ;
default :
2009-05-31 15:56:51 -05:00
sLog . outError ( "Unknown arena slot %u at HandleBattlemasterJoinArena()" , arenaslot );
2008-10-11 14:16:25 -05:00
return ;
}
//check existance
BattleGround * bg = NULL ;
2009-04-08 16:33:46 -05:00
if ( ! ( bg = sBattleGroundMgr . GetBattleGroundTemplate ( BATTLEGROUND_AA )))
2008-10-11 14:16:25 -05:00
{
2008-12-19 16:05:13 -06:00
sLog . outError ( "Battleground: template bg (all arenas) not found" );
2008-10-11 14:16:25 -05:00
return ;
}
2009-02-09 22:08:06 -06:00
BattleGroundTypeId bgTypeId = bg -> GetTypeID ();
2009-02-13 19:56:22 -06:00
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr :: BGQueueTypeId ( bgTypeId , arenatype );
2008-10-11 14:16:25 -05:00
// check queueing conditions
2009-04-08 16:33:46 -05:00
if ( ! asGroup )
2008-10-11 14:16:25 -05:00
{
// check if already in queue
if ( _player -> GetBattleGroundQueueIndex ( bgQueueTypeId ) < PLAYER_MAX_BATTLEGROUND_QUEUES )
//player is already in this queue
return ;
// check if has free queue slots
2009-04-08 16:33:46 -05:00
if ( ! _player -> HasFreeBattleGroundQueueId ())
2008-10-11 14:16:25 -05:00
return ;
}
else
{
grp = _player -> GetGroup ();
// no group found, error
2009-04-08 16:33:46 -05:00
if ( ! grp )
2008-10-11 14:16:25 -05:00
return ;
2009-02-13 19:56:22 -06:00
uint32 err = grp -> CanJoinBattleGroundQueue ( bgTypeId , bgQueueTypeId , arenatype , arenatype , ( bool ) isRated , arenaslot );
2008-12-19 16:05:13 -06:00
if ( err != BG_JOIN_ERR_OK )
2008-10-11 14:16:25 -05:00
{
2008-12-19 16:05:13 -06:00
SendBattleGroundOrArenaJoinError ( err );
2008-10-11 14:16:25 -05:00
return ;
2008-12-19 16:05:13 -06:00
}
2008-10-11 14:16:25 -05:00
}
uint32 ateamId = 0 ;
2009-04-08 16:33:46 -05:00
if ( isRated )
2008-10-11 14:16:25 -05:00
{
2009-02-13 19:56:22 -06:00
ateamId = _player -> GetArenaTeamId ( arenaslot );
2008-10-11 14:16:25 -05:00
// check real arenateam existence only here (if it was moved to group->CanJoin .. () then we would ahve to get it twice)
ArenaTeam * at = objmgr . GetArenaTeamById ( ateamId );
2009-04-08 16:33:46 -05:00
if ( ! at )
2008-10-11 14:16:25 -05:00
{
_player -> GetSession () -> SendNotInArenaTeamPacket ( arenatype );
return ;
}
// get the team rating for queueing
arenaRating = at -> GetRating ();
// the arenateam id must match for everyone in the group
// get the personal ratings for queueing
uint32 avg_pers_rating = 0 ;
for ( GroupReference * itr = grp -> GetFirstMember (); itr != NULL ; itr = itr -> next ())
{
Player * member = itr -> getSource ();
// calc avg personal rating
2009-02-13 19:56:22 -06:00
avg_pers_rating += member -> GetUInt32Value ( PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + ( arenaslot * 6 ) + 5 );
2008-10-11 14:16:25 -05:00
}
2009-04-08 16:33:46 -05:00
if ( arenatype )
2008-10-11 14:16:25 -05:00
avg_pers_rating /= arenatype ;
2008-12-19 16:05:13 -06:00
// if avg personal rating is more than 150 points below the teams rating, the team will be queued against an opponent matching or similar to the average personal rating
2009-04-08 16:33:46 -05:00
if ( avg_pers_rating + 150 < arenaRating )
2008-10-11 14:16:25 -05:00
arenaRating = avg_pers_rating ;
}
2009-03-10 15:29:50 -06:00
GroupQueueInfo * ginfo = sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. AddGroup ( _player , bgTypeId , arenatype , isRated , false , arenaRating , ateamId );
uint32 avgTime = sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. GetAverageQueueWaitTime ( ginfo , _player -> GetBattleGroundQueueIdFromLevel ( bgTypeId ));
2009-04-08 16:33:46 -05:00
if ( asGroup )
2008-10-11 14:16:25 -05:00
{
sLog . outDebug ( "Battleground: arena join as group start" );
2009-04-08 16:33:46 -05:00
if ( isRated )
2009-08-28 05:01:53 +02:00
{
2009-02-13 19:56:22 -06:00
sLog . outDebug ( "Battleground: arena team id %u, leader %s queued with rating %u for type %u" , _player -> GetArenaTeamId ( arenaslot ), _player -> GetName (), arenaRating , arenatype );
2009-08-28 05:01:53 +02:00
bg -> SetRated ( true );
}
else
bg -> SetRated ( false );
2008-10-11 14:16:25 -05:00
for ( GroupReference * itr = grp -> GetFirstMember (); itr != NULL ; itr = itr -> next ())
{
Player * member = itr -> getSource ();
if ( ! member ) continue ;
uint32 queueSlot = member -> AddBattleGroundQueueId ( bgQueueTypeId ); // add to queue
WorldPacket data ;
// send status packet (in queue)
2009-03-10 15:29:50 -06:00
sBattleGroundMgr . BuildBattleGroundStatusPacket ( & data , bg , queueSlot , STATUS_WAIT_QUEUE , avgTime , 0 , arenatype );
2008-10-11 14:16:25 -05:00
member -> GetSession () -> SendPacket ( & data );
sBattleGroundMgr . BuildGroupJoinedBattlegroundPacket ( & data , bgTypeId );
member -> GetSession () -> SendPacket ( & data );
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. AddPlayer ( member , ginfo );
sLog . outDebug ( "Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s" , bgQueueTypeId , bgTypeId , member -> GetGUIDLow (), member -> GetName ());
}
sLog . outDebug ( "Battleground: arena join as group end" );
2009-04-08 16:33:46 -05:00
if ( isRated )
2008-12-26 17:08:59 -06:00
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. AnnounceWorld ( ginfo , _player -> GetGUID (), true );
2008-10-11 14:16:25 -05:00
}
else
{
uint32 queueSlot = _player -> AddBattleGroundQueueId ( bgQueueTypeId );
WorldPacket data ;
// send status packet (in queue)
2009-03-10 15:29:50 -06:00
sBattleGroundMgr . BuildBattleGroundStatusPacket ( & data , bg , queueSlot , STATUS_WAIT_QUEUE , avgTime , 0 , arenatype );
2008-10-11 14:16:25 -05:00
SendPacket ( & data );
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. AddPlayer ( _player , ginfo );
sLog . outDebug ( "Battleground: player joined queue for arena, skirmish, bg queue type %u bg type %u: GUID %u, NAME %s" , bgQueueTypeId , bgTypeId , _player -> GetGUIDLow (), _player -> GetName ());
}
2009-03-10 15:29:50 -06:00
sBattleGroundMgr . m_BattleGroundQueues [ bgQueueTypeId ]. Update ( bgTypeId , _player -> GetBattleGroundQueueIdFromLevel ( bgTypeId ), arenatype , isRated , arenaRating );
2008-10-11 14:16:25 -05:00
}
2009-05-31 15:56:51 -05:00
void WorldSession :: HandleReportPvPAFK ( WorldPacket & recv_data )
2008-10-11 14:16:25 -05:00
{
uint64 playerGuid ;
recv_data >> playerGuid ;
Player * reportedPlayer = objmgr . GetPlayer ( playerGuid );
2009-04-08 16:33:46 -05:00
if ( ! reportedPlayer )
2008-10-11 14:16:25 -05:00
{
2009-05-31 15:56:51 -05:00
sLog . outDebug ( "WorldSession::HandleReportPvPAFK: player not found" );
2008-10-11 14:16:25 -05:00
return ;
}
2009-05-31 15:56:51 -05:00
sLog . outDebug ( "WorldSession::HandleReportPvPAFK: %s reported %s" , _player -> GetName (), reportedPlayer -> GetName ());
2008-10-11 14:16:25 -05:00
reportedPlayer -> ReportedAfkBy ( _player );
}
2008-12-19 16:05:13 -06:00
void WorldSession :: SendBattleGroundOrArenaJoinError ( uint8 err )
{
WorldPacket data ;
int32 msg ;
switch ( err )
{
case BG_JOIN_ERR_OFFLINE_MEMBER :
msg = LANG_BG_GROUP_OFFLINE_MEMBER ;
break ;
case BG_JOIN_ERR_GROUP_TOO_MANY :
msg = LANG_BG_GROUP_TOO_LARGE ;
break ;
case BG_JOIN_ERR_MIXED_FACTION :
msg = LANG_BG_GROUP_MIXED_FACTION ;
break ;
case BG_JOIN_ERR_MIXED_LEVELS :
msg = LANG_BG_GROUP_MIXED_LEVELS ;
break ;
case BG_JOIN_ERR_GROUP_MEMBER_ALREADY_IN_QUEUE :
msg = LANG_BG_GROUP_MEMBER_ALREADY_IN_QUEUE ;
break ;
case BG_JOIN_ERR_GROUP_DESERTER :
msg = LANG_BG_GROUP_MEMBER_DESERTER ;
break ;
case BG_JOIN_ERR_ALL_QUEUES_USED :
msg = LANG_BG_GROUP_MEMBER_NO_FREE_QUEUE_SLOTS ;
break ;
case BG_JOIN_ERR_GROUP_NOT_ENOUGH :
case BG_JOIN_ERR_MIXED_ARENATEAM :
default :
return ;
break ;
}
ChatHandler :: FillMessageData ( & data , NULL , CHAT_MSG_BG_SYSTEM_NEUTRAL , LANG_UNIVERSAL , NULL , 0 , GetTrinityString ( msg ), NULL );
SendPacket ( & data );
return ;
}
2009-02-17 20:07:49 -06:00