fix(Core/ArenaTeam): Arena team queue protections (#3803)

This commit is contained in:
Degen
2021-01-07 21:39:09 -04:00
committed by GitHub
parent 86d582f833
commit 2dd6141afa
2 changed files with 73 additions and 2 deletions

View File

@@ -15,6 +15,7 @@
#include "ObjectMgr.h"
#include "SocialMgr.h"
#include "ArenaTeamMgr.h"
#include "BattlegroundMgr.h"
#include "Opcodes.h"
void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket& recvData)
@@ -222,7 +223,7 @@ void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket& recvData)
// Disallow leave team while in arena
if (arenaTeam->IsFighting())
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAM_INTERNAL);
SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAMS_LOCKED);
return;
}
@@ -233,6 +234,21 @@ void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket& recvData)
return;
}
// Player cannot be removed during queues
if (BattlegroundQueueTypeId bgQueue = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_AA, arenaTeam->GetType()))
{
GroupQueueInfo ginfo;
BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueue);
if (queue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
{
if (ginfo.IsInvitedToBGInstanceGUID)
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAMS_LOCKED);
return;
}
}
}
// If team consists only of the captain, disband the team
if (_player->GetGUID() == arenaTeam->GetCaptain())
{
@@ -265,6 +281,16 @@ void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket& recvData)
if (arenaTeam->GetCaptain() != _player->GetGUID())
return;
// Teams cannot be disbanded during queues
if (BattlegroundQueueTypeId bgQueue = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_AA, arenaTeam->GetType()))
{
GroupQueueInfo ginfo;
BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueue);
if (queue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
if (ginfo.IsInvitedToBGInstanceGUID)
return;
}
// Teams cannot be disbanded during fights
if (arenaTeam->IsFighting())
return;
@@ -316,6 +342,21 @@ void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket& recvData)
return;
}
// Team member cannot be removed during queues
if (BattlegroundQueueTypeId bgQueue = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_AA, arenaTeam->GetType()))
{
GroupQueueInfo ginfo;
BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueue);
if (queue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
{
if (ginfo.IsInvitedToBGInstanceGUID)
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAMS_LOCKED);
return;
}
}
}
// Player cannot be removed during fights
if (arenaTeam->IsFighting())
return;