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
+23 -8
View File
@@ -16,6 +16,7 @@
*/ */
#include "LFGMgr.h" #include "LFGMgr.h"
#include "BattlegroundMgr.h"
#include "CharacterCache.h" #include "CharacterCache.h"
#include "Common.h" #include "Common.h"
#include "DBCStores.h" #include "DBCStores.h"
@@ -605,15 +606,18 @@ namespace lfg
if (!isRaid && joinData.result == LFG_JOIN_OK) if (!isRaid && joinData.result == LFG_JOIN_OK)
{ {
// Check player or group member restrictions // 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)) else if (player->HasAura(LFG_SPELL_DUNGEON_DESERTER))
{
joinData.result = LFG_JOIN_DESERTER; joinData.result = LFG_JOIN_DESERTER;
}
else if (dungeons.empty()) else if (dungeons.empty())
{
joinData.result = LFG_JOIN_NOT_MEET_REQS; joinData.result = LFG_JOIN_NOT_MEET_REQS;
}
else if (grp) else if (grp)
{ {
if (grp->GetMembersCount() > MAXGROUPSIZE) if (grp->GetMembersCount() > MAXGROUPSIZE)
@@ -629,10 +633,9 @@ namespace lfg
{ {
joinData.result = LFG_JOIN_PARTY_DESERTER; 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; ++memberCount;
@@ -1684,8 +1687,7 @@ namespace lfg
bool leaderTeleportIncluded = false; bool leaderTeleportIncluded = false;
for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next()) for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
{ {
Player* plr = itr->GetSource(); if (Player* plr = itr->GetSource())
if (plr)
{ {
if (grp->IsLeader(plr->GetGUID()) && playersToTeleport.find(plr->GetGUID()) != playersToTeleport.end()) if (grp->IsLeader(plr->GetGUID()) && playersToTeleport.find(plr->GetGUID()) != playersToTeleport.end())
{ {
@@ -1697,6 +1699,19 @@ namespace lfg
teleportLocation = plr; teleportLocation = plr;
break; 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);
}
}
}
} }
} }
+4 -1
View File
@@ -1930,8 +1930,11 @@ GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue(Battleground const*
return ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS; return ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS;
// check if someone in party is using dungeon system // check if someone in party is using dungeon system
if (member->isUsingLfg()) lfg::LfgState lfgState = sLFGMgr->GetState(member->GetGUID());
if (lfgState > lfg::LFG_STATE_NONE && (lfgState != lfg::LFG_STATE_QUEUED || !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
{
return ERR_LFG_CANT_USE_BATTLEGROUND; return ERR_LFG_CANT_USE_BATTLEGROUND;
}
// pussywizard: prevent joining when any member is in bg/arena // pussywizard: prevent joining when any member is in bg/arena
if (member->InBattleground()) if (member->InBattleground())
@@ -152,26 +152,38 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recvData)
// check if player can queue: // check if player can queue:
if (!joinAsGroup) if (!joinAsGroup)
{ {
lfg::LfgState lfgState = sLFGMgr->GetState(GetPlayer()->GetGUID());
if (GetPlayer()->InBattleground()) // currently in battleground if (GetPlayer()->InBattleground()) // currently in battleground
err = ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND;
else if (!sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG))
{ {
if (GetPlayer()->isUsingLfg()) // using lfg system err = ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND;
err = ERR_LFG_CANT_USE_BATTLEGROUND; }
else if (lfgState > lfg::LFG_STATE_NONE && (lfgState != lfg::LFG_STATE_QUEUED || !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG))) // using lfg system
{
err = ERR_LFG_CANT_USE_BATTLEGROUND;
} }
else if (!_player->CanJoinToBattleground()) // has deserter debuff else if (!_player->CanJoinToBattleground()) // has deserter debuff
{
err = ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS; err = ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS;
}
else if (_player->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom)) // queued for random bg, so can't queue for anything else else if (_player->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom)) // queued for random bg, so can't queue for anything else
{
err = ERR_IN_RANDOM_BG; err = ERR_IN_RANDOM_BG;
}
else if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB) // already in queue, so can't queue for random else if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB) // already in queue, so can't queue for random
{
err = ERR_IN_NON_RANDOM_BG; err = ERR_IN_NON_RANDOM_BG;
}
else if (_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_2v2) || else if (_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_2v2) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_3v3) || _player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_3v3) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_5v5)) // can't be already queued for arenas _player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_5v5)) // can't be already queued for arenas
{
err = ERR_BATTLEGROUND_QUEUED_FOR_RATED; err = ERR_BATTLEGROUND_QUEUED_FOR_RATED;
}
// don't let Death Knights join BG queues when they are not allowed to be teleported yet // don't let Death Knights join BG queues when they are not allowed to be teleported yet
else if (_player->getClass() == CLASS_DEATH_KNIGHT && _player->GetMapId() == 609 && !_player->IsGameMaster() && !_player->HasSpell(50977)) else if (_player->getClass() == CLASS_DEATH_KNIGHT && _player->GetMapId() == 609 && !_player->IsGameMaster() && !_player->HasSpell(50977))
{
err = ERR_BATTLEGROUND_NONE; err = ERR_BATTLEGROUND_NONE;
}
if (err <= 0) if (err <= 0)
{ {
@@ -467,8 +479,10 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recvData)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), teamId); sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), teamId);
SendPacket(&data); SendPacket(&data);
_player->SetBattlegroundId(bg->GetInstanceID(), bg->GetBgTypeID(), queueSlot, true, bgTypeId == BATTLEGROUND_RB, teamId); // Remove from LFG queues
sLFGMgr->LeaveAllLfgQueues(_player->GetGUID(), false);
_player->SetBattlegroundId(bg->GetInstanceID(), bg->GetBgTypeID(), queueSlot, true, bgTypeId == BATTLEGROUND_RB, teamId);
sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId); sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
} }
break; break;
@@ -673,12 +687,14 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData)
// check if player can queue: // check if player can queue:
if (!asGroup) if (!asGroup)
{ {
lfg::LfgState lfgState = sLFGMgr->GetState(GetPlayer()->GetGUID());
if (GetPlayer()->InBattleground()) // currently in battleground if (GetPlayer()->InBattleground()) // currently in battleground
err = ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND;
else if (!sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG))
{ {
if (GetPlayer()->isUsingLfg()) // using lfg system err = ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND;
err = ERR_LFG_CANT_USE_BATTLEGROUND; }
else if (lfgState > lfg::LFG_STATE_NONE && (lfgState != lfg::LFG_STATE_QUEUED || !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG))) // using lfg system
{
err = ERR_LFG_CANT_USE_BATTLEGROUND;
} }
if (err <= 0) if (err <= 0)
+3
View File
@@ -438,6 +438,9 @@ public:
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), teamId); sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), teamId);
player->GetSession()->SendPacket(&data); player->GetSession()->SendPacket(&data);
// Remove from LFG queues
sLFGMgr->LeaveAllLfgQueues(player->GetGUID(), false);
player->SetBattlegroundId(bg->GetInstanceID(), bgTypeId, queueSlot, true, false, teamId); player->SetBattlegroundId(bg->GetInstanceID(), bgTypeId, queueSlot, true, false, teamId);
sBattlegroundMgr->SendToBattleground(player, bg->GetInstanceID(), bgTypeId); sBattlegroundMgr->SendToBattleground(player, bg->GetInstanceID(), bgTypeId);
} }