fix(Core/Misc): Remove from LFG/batleground queues when teleported to battleground/LFG dungeon. (#10740)

Players cannot queue up for battleground during LFG dungeon.
Players cannot queue up for LFG dungeon during battleground/arena match.
Fixes #10635
This commit is contained in:
UltraNix
2022-02-20 16:33:04 +01:00
committed by GitHub
parent 3e6424151a
commit 9d12652c3e
4 changed files with 57 additions and 20 deletions

View File

@@ -16,6 +16,7 @@
*/
#include "LFGMgr.h"
#include "BattlegroundMgr.h"
#include "CharacterCache.h"
#include "Common.h"
#include "DBCStores.h"
@@ -605,15 +606,18 @@ namespace lfg
if (!isRaid && joinData.result == LFG_JOIN_OK)
{
// Check player or group member restrictions
if (!sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG))
if (player->InBattleground() || (player->InBattlegroundQueue() && !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
{
if (player->InBattleground() || player->InArena() || player->InBattlegroundQueue())
joinData.result = LFG_JOIN_USING_BG_SYSTEM;
joinData.result = LFG_JOIN_USING_BG_SYSTEM;
}
else if (player->HasAura(LFG_SPELL_DUNGEON_DESERTER))
{
joinData.result = LFG_JOIN_DESERTER;
}
else if (dungeons.empty())
{
joinData.result = LFG_JOIN_NOT_MEET_REQS;
}
else if (grp)
{
if (grp->GetMembersCount() > MAXGROUPSIZE)
@@ -629,10 +633,9 @@ namespace lfg
{
joinData.result = LFG_JOIN_PARTY_DESERTER;
}
else if (!sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG))
else if (plrg->InBattleground() || (plrg->InBattlegroundQueue() && !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
{
if (plrg->InBattleground() || plrg->InArena() || plrg->InBattlegroundQueue())
joinData.result = LFG_JOIN_USING_BG_SYSTEM;
joinData.result = LFG_JOIN_USING_BG_SYSTEM;
}
++memberCount;
@@ -1684,8 +1687,7 @@ namespace lfg
bool leaderTeleportIncluded = false;
for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* plr = itr->GetSource();
if (plr)
if (Player* plr = itr->GetSource())
{
if (grp->IsLeader(plr->GetGUID()) && playersToTeleport.find(plr->GetGUID()) != playersToTeleport.end())
{
@@ -1697,6 +1699,19 @@ namespace lfg
teleportLocation = plr;
break;
}
// Remove from battleground queues
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
{
if (BattlegroundQueueTypeId bgQueueTypeId = plr->GetBattlegroundQueueTypeId(i))
{
if (bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
{
plr->RemoveBattlegroundQueueId(bgQueueTypeId);
sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId).RemovePlayer(plr->GetGUID(), false, i);
}
}
}
}
}