mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
fix(Core/ArenaTeam): Arena team queue protections (#3803)
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "WorldSession.h"
|
||||
#include "Opcodes.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
|
||||
ArenaTeam::ArenaTeam()
|
||||
: TeamId(0), Type(0), TeamName(), CaptainGuid(0), BackgroundColor(0), EmblemStyle(0), EmblemColor(0),
|
||||
@@ -308,17 +309,46 @@ void ArenaTeam::SetCaptain(uint64 guid)
|
||||
|
||||
void ArenaTeam::DelMember(uint64 guid, bool cleanDb)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid);
|
||||
Group* group = (player && player->GetGroup()) ? player->GetGroup() : nullptr;
|
||||
|
||||
// Remove member from team
|
||||
for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
|
||||
{
|
||||
// Remove queues of members
|
||||
if (Player* playerMember = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid))
|
||||
{
|
||||
if (group && playerMember->GetGroup() && group->GetGUID() == playerMember->GetGroup()->GetGUID())
|
||||
{
|
||||
if (BattlegroundQueueTypeId bgQueue = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_AA, GetType()))
|
||||
{
|
||||
GroupQueueInfo ginfo;
|
||||
BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueue);
|
||||
if (queue.GetPlayerGroupInfoData(playerMember->GetGUID(), &ginfo))
|
||||
{
|
||||
if (!ginfo.IsInvitedToBGInstanceGUID)
|
||||
{
|
||||
WorldPacket data;
|
||||
playerMember->RemoveBattlegroundQueueId(bgQueue);
|
||||
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, nullptr, playerMember->GetBattlegroundQueueIndex(bgQueue), STATUS_NONE, 0, 0, 0, TEAM_NEUTRAL);
|
||||
queue.RemovePlayer(playerMember->GetGUID(), true, 0);
|
||||
playerMember->GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (itr->Guid == guid)
|
||||
{
|
||||
Members.erase(itr);
|
||||
sWorld->UpdateGlobalPlayerArenaTeam(GUID_LOPART(guid), GetSlot(), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Inform player and remove arena team info from player data
|
||||
if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid))
|
||||
if (player)
|
||||
{
|
||||
player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, GetName(), "", 0);
|
||||
// delete all info regarding this team
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user