mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
Core/PacketIO: CMSG_BATTLEMASTER_JOIN_ARENA
This commit is contained in:
@@ -487,22 +487,15 @@ void WorldSession::HandleRequestBattlefieldStatusOpcode(WorldPackets::Battlegrou
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData)
|
||||
void WorldSession::HandleBattlemasterJoinArena(WorldPackets::Battleground::BattlemasterJoinArena& packet)
|
||||
{
|
||||
uint8 arenaslot; // 2v2, 3v3 or 5v5
|
||||
|
||||
recvData >> arenaslot;
|
||||
|
||||
// ignore if we already in BG or BG queue
|
||||
if (_player->InBattleground())
|
||||
return;
|
||||
|
||||
uint32 arenaRating = 0;
|
||||
uint32 matchmakerRating = 0;
|
||||
uint8 arenatype = ArenaTeam::GetTypeBySlot(packet.TeamSizeIndex);
|
||||
|
||||
uint8 arenatype = ArenaTeam::GetTypeBySlot(arenaslot);
|
||||
|
||||
//check existance
|
||||
//check existence
|
||||
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BATTLEGROUND_AA);
|
||||
if (!bg)
|
||||
{
|
||||
@@ -510,7 +503,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, NULL))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, nullptr))
|
||||
{
|
||||
ChatHandler(this).PSendSysMessage(LANG_ARENA_DISABLED);
|
||||
return;
|
||||
@@ -522,8 +515,6 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData)
|
||||
if (!bracketEntry)
|
||||
return;
|
||||
|
||||
GroupJoinBattlegroundResult err = ERR_BATTLEGROUND_NONE;
|
||||
|
||||
Group* grp = _player->GetGroup();
|
||||
// no group found, error
|
||||
if (!grp)
|
||||
@@ -531,7 +522,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData)
|
||||
if (grp->GetLeaderGUID() != _player->GetGUID())
|
||||
return;
|
||||
|
||||
uint32 ateamId = _player->GetArenaTeamId(arenaslot);
|
||||
uint32 ateamId = _player->GetArenaTeamId(packet.TeamSizeIndex);
|
||||
// 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)
|
||||
@@ -540,30 +531,30 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
// get the team rating for queueing
|
||||
arenaRating = at->GetRating();
|
||||
matchmakerRating = at->GetAverageMMR(grp);
|
||||
// get the team rating for queuing
|
||||
uint32 arenaRating = at->GetRating();
|
||||
uint32 matchmakerRating = at->GetAverageMMR(grp);
|
||||
// the arenateam id must match for everyone in the group
|
||||
|
||||
if (arenaRating <= 0)
|
||||
arenaRating = 1;
|
||||
|
||||
BattlegroundQueue &bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
|
||||
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
|
||||
|
||||
uint32 avgTime = 0;
|
||||
GroupQueueInfo* ginfo = NULL;
|
||||
GroupQueueInfo* ginfo = nullptr;
|
||||
|
||||
ObjectGuid errorGuid;
|
||||
err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, arenatype, arenatype, true, arenaslot, errorGuid);
|
||||
GroupJoinBattlegroundResult err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, arenatype, arenatype, true, packet.TeamSizeIndex, errorGuid);
|
||||
if (!err)
|
||||
{
|
||||
TC_LOG_DEBUG("bg.battleground", "Battleground: arena team id %u, leader %s queued with matchmaker rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName().c_str(), matchmakerRating, arenatype);
|
||||
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);
|
||||
|
||||
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, true, false, arenaRating, matchmakerRating, ateamId);
|
||||
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
|
||||
}
|
||||
|
||||
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
|
||||
{
|
||||
Player* member = itr->GetSource();
|
||||
if (!member)
|
||||
|
||||
@@ -120,6 +120,11 @@ void WorldPackets::Battleground::BattlemasterJoin::Read()
|
||||
JoinAsGroup = _worldPacket.ReadBit();
|
||||
}
|
||||
|
||||
void WorldPackets::Battleground::BattlemasterJoinArena::Read()
|
||||
{
|
||||
_worldPacket >> TeamSizeIndex;
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Battleground::BattlefieldStatusHeader const& header)
|
||||
{
|
||||
data << header.Ticket;
|
||||
|
||||
@@ -212,6 +212,16 @@ namespace WorldPackets
|
||||
int32 BlacklistMap[2] = { };
|
||||
};
|
||||
|
||||
class BattlemasterJoinArena final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
BattlemasterJoinArena(WorldPacket&& packet) : ClientPacket(CMSG_BATTLEMASTER_JOIN_ARENA, std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 TeamSizeIndex = 0;
|
||||
};
|
||||
|
||||
class BattlefieldLeave final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -156,7 +156,7 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_HANDLER(CMSG_BATTLEFIELD_PORT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Battleground::BattlefieldPort, &WorldSession::HandleBattleFieldPortOpcode);
|
||||
DEFINE_HANDLER(CMSG_BATTLEMASTER_HELLO, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::NPC::Hello, &WorldSession::HandleBattlemasterHelloOpcode);
|
||||
DEFINE_HANDLER(CMSG_BATTLEMASTER_JOIN, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Battleground::BattlemasterJoin, &WorldSession::HandleBattlemasterJoinOpcode);
|
||||
DEFINE_OPCODE_HANDLER_OLD(CMSG_BATTLEMASTER_JOIN_ARENA, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleBattlemasterJoinArena );
|
||||
DEFINE_HANDLER(CMSG_BATTLEMASTER_JOIN_ARENA, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Battleground::BattlemasterJoinArena, &WorldSession::HandleBattlemasterJoinArena);
|
||||
DEFINE_HANDLER(CMSG_BATTLEMASTER_JOIN_SKIRMISH, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
|
||||
DEFINE_HANDLER(CMSG_BATTLENET_CHALLENGE_RESPONSE, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
|
||||
DEFINE_HANDLER(CMSG_BATTLE_PAY_ACK_FAILED_RESPONSE, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
|
||||
|
||||
@@ -118,6 +118,7 @@ namespace WorldPackets
|
||||
class HearthAndResurrect;
|
||||
class PVPLogDataRequest;
|
||||
class BattlemasterJoin;
|
||||
class BattlemasterJoinArena;
|
||||
class BattlefieldLeave;
|
||||
class BattlefieldPort;
|
||||
class BattlefieldListRequest;
|
||||
@@ -1457,7 +1458,7 @@ class WorldSession
|
||||
void HandleBattleFieldPortOpcode(WorldPackets::Battleground::BattlefieldPort& battlefieldPort);
|
||||
void HandleBattlefieldListOpcode(WorldPackets::Battleground::BattlefieldListRequest& battlefieldList);
|
||||
void HandleBattlefieldLeaveOpcode(WorldPackets::Battleground::BattlefieldLeave& battlefieldLeave);
|
||||
void HandleBattlemasterJoinArena(WorldPacket& recvData);
|
||||
void HandleBattlemasterJoinArena(WorldPackets::Battleground::BattlemasterJoinArena& packet);
|
||||
void HandleReportPvPAFK(WorldPackets::Battleground::ReportPvPPlayerAFK& reportPvPPlayerAFK);
|
||||
void HandleRequestRatedBattlefieldInfo(WorldPacket& recvData);
|
||||
void HandleGetPVPOptionsEnabled(WorldPackets::Battleground::GetPVPOptionsEnabled& getPvPOptionsEnabled);
|
||||
|
||||
Reference in New Issue
Block a user