mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Battlegrounds: Remove duplicate info from GroupQueueInfo (#26759)
- BgTypeId - ArenaType - IsRated Those are fields that are already present in the field m_queueId
This commit is contained in:
@@ -130,16 +130,13 @@ bool BattlegroundQueue::SelectionPool::AddGroup(GroupQueueInfo* ginfo, uint32 de
|
||||
/*********************************************************/
|
||||
|
||||
// add group or player (grp == NULL) to bg queue with the given leader and bg specifications
|
||||
GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, BattlegroundTypeId BgTypeId, PVPDifficultyEntry const* bracketEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 arenateamid)
|
||||
GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PVPDifficultyEntry const* bracketEntry, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 arenateamid)
|
||||
{
|
||||
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
|
||||
|
||||
// create new ginfo
|
||||
GroupQueueInfo* ginfo = new GroupQueueInfo;
|
||||
ginfo->BgTypeId = BgTypeId;
|
||||
ginfo->ArenaType = ArenaType;
|
||||
ginfo->ArenaTeamId = arenateamid;
|
||||
ginfo->IsRated = isRated;
|
||||
ginfo->IsInvitedToBGInstanceGUID = 0;
|
||||
ginfo->JoinTime = GameTime::GetGameTimeMS();
|
||||
ginfo->RemoveInviteTime = 0;
|
||||
@@ -153,20 +150,20 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
|
||||
|
||||
//compute index (if group is premade or joined a rated match) to queues
|
||||
uint32 index = 0;
|
||||
if (!isRated && !isPremade)
|
||||
if (!m_queueId.Rated && !isPremade)
|
||||
index += BG_TEAMS_COUNT;
|
||||
if (ginfo->Team == HORDE)
|
||||
index++;
|
||||
TC_LOG_DEBUG("bg.battleground", "Adding Group to BattlegroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
|
||||
TC_LOG_DEBUG("bg.battleground", "Adding Group to BattlegroundQueue bgTypeId : %u, bracket_id : %u, index : %u", m_queueId.BattlemasterListId, bracketId, index);
|
||||
|
||||
uint32 lastOnlineTime = GameTime::GetGameTimeMS();
|
||||
|
||||
//announce world (this don't need mutex)
|
||||
if (isRated && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
||||
if (m_queueId.Rated && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
||||
{
|
||||
ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(arenateamid);
|
||||
if (team)
|
||||
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, team->GetName().c_str(), ginfo->ArenaType, ginfo->ArenaType, ginfo->ArenaTeamRating);
|
||||
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, team->GetName().c_str(), m_queueId.TeamSize, m_queueId.TeamSize, ginfo->ArenaTeamRating);
|
||||
}
|
||||
|
||||
//add players from group to ginfo
|
||||
@@ -197,9 +194,9 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
|
||||
m_QueuedGroups[bracketId][index].push_back(ginfo);
|
||||
|
||||
//announce to world, this code needs mutex
|
||||
if (!isRated && !isPremade && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
|
||||
if (!m_queueId.Rated && !isPremade && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
|
||||
{
|
||||
if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(ginfo->BgTypeId))
|
||||
if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BattlegroundTypeId(m_queueId.BattlemasterListId)))
|
||||
{
|
||||
uint32 MinPlayers = bg->GetMinPlayersPerTeam();
|
||||
uint32 qHorde = 0;
|
||||
@@ -238,14 +235,14 @@ void BattlegroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* g
|
||||
{
|
||||
uint32 timeInQueue = getMSTimeDiff(ginfo->JoinTime, GameTime::GetGameTimeMS());
|
||||
uint8 team_index = TEAM_ALLIANCE; //default set to TEAM_ALLIANCE - or non rated arenas!
|
||||
if (!ginfo->ArenaType)
|
||||
if (!m_queueId.TeamSize)
|
||||
{
|
||||
if (ginfo->Team == HORDE)
|
||||
team_index = TEAM_HORDE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ginfo->IsRated)
|
||||
if (m_queueId.Rated)
|
||||
team_index = TEAM_HORDE; //for rated arenas use TEAM_HORDE
|
||||
}
|
||||
|
||||
@@ -265,14 +262,14 @@ void BattlegroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* g
|
||||
uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id) const
|
||||
{
|
||||
uint8 team_index = TEAM_ALLIANCE; //default set to TEAM_ALLIANCE - or non rated arenas!
|
||||
if (!ginfo->ArenaType)
|
||||
if (!m_queueId.TeamSize)
|
||||
{
|
||||
if (ginfo->Team == HORDE)
|
||||
team_index = TEAM_HORDE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ginfo->IsRated)
|
||||
if (m_queueId.Rated)
|
||||
team_index = TEAM_HORDE; //for rated arenas use TEAM_HORDE
|
||||
}
|
||||
//check if there is enought values(we always add values > 0)
|
||||
@@ -349,19 +346,19 @@ void BattlegroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
|
||||
|
||||
// if invited to bg, and should decrease invited count, then do it
|
||||
if (decreaseInvitedCount && group->IsInvitedToBGInstanceGUID)
|
||||
if (Battleground* bg = sBattlegroundMgr->GetBattleground(group->IsInvitedToBGInstanceGUID, group->BgTypeId))
|
||||
if (Battleground* bg = sBattlegroundMgr->GetBattleground(group->IsInvitedToBGInstanceGUID, BattlegroundTypeId(m_queueId.BattlemasterListId)))
|
||||
bg->DecreaseInvitedCount(group->Team);
|
||||
|
||||
// remove player queue info
|
||||
m_QueuedPlayers.erase(itr);
|
||||
|
||||
// announce to world if arena team left queue for rated match, show only once
|
||||
if (group->ArenaType && group->IsRated && group->Players.empty() && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
||||
if (m_queueId.TeamSize && m_queueId.Rated && group->Players.empty() && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
||||
if (ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId))
|
||||
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, team->GetName().c_str(), group->ArenaType, group->ArenaType, group->ArenaTeamRating);
|
||||
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, team->GetName().c_str(), m_queueId.TeamSize, m_queueId.TeamSize, group->ArenaTeamRating);
|
||||
|
||||
// if player leaves queue and he is invited to rated arena match, then he have to lose
|
||||
if (group->IsInvitedToBGInstanceGUID && group->IsRated && decreaseInvitedCount)
|
||||
if (group->IsInvitedToBGInstanceGUID && m_queueId.Rated && decreaseInvitedCount)
|
||||
{
|
||||
if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId))
|
||||
{
|
||||
@@ -385,7 +382,7 @@ void BattlegroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
|
||||
// if group wasn't empty, so it wasn't deleted, and player have left a rated
|
||||
// queue -> everyone from the group should leave too
|
||||
// don't remove recursively if already invited to bg!
|
||||
if (!group->IsInvitedToBGInstanceGUID && group->IsRated)
|
||||
if (!group->IsInvitedToBGInstanceGUID && m_queueId.Rated)
|
||||
{
|
||||
// remove next player, this is recursive
|
||||
// first send removal information
|
||||
@@ -468,7 +465,7 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg,
|
||||
player->SetInviteForBattlegroundQueueType(bgQueueTypeId, ginfo->IsInvitedToBGInstanceGUID);
|
||||
|
||||
// create remind invite events
|
||||
BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(player->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, ginfo->ArenaType, ginfo->RemoveInviteTime);
|
||||
BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(player->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, m_queueId.TeamSize, ginfo->RemoveInviteTime);
|
||||
m_events.AddEvent(inviteEvent, m_events.CalculateTime(INVITATION_REMIND_TIME));
|
||||
// create automatic remove events
|
||||
BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(player->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgQueueTypeId, ginfo->RemoveInviteTime);
|
||||
@@ -480,7 +477,7 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg,
|
||||
player->GetName().c_str(), player->GetGUID().ToString().c_str(), bg->GetInstanceID(), queueSlot, bg->GetTypeID());
|
||||
|
||||
WorldPackets::Battleground::BattlefieldStatusNeedConfirmation battlefieldStatus;
|
||||
sBattlegroundMgr->BuildBattlegroundStatusNeedConfirmation(&battlefieldStatus, bg, player, queueSlot, player->GetBattlegroundQueueJoinTime(bgQueueTypeId), INVITE_ACCEPT_WAIT_TIME, ginfo->ArenaType);
|
||||
sBattlegroundMgr->BuildBattlegroundStatusNeedConfirmation(&battlefieldStatus, bg, player, queueSlot, player->GetBattlegroundQueueJoinTime(bgQueueTypeId), INVITE_ACCEPT_WAIT_TIME, m_queueId.TeamSize);
|
||||
player->SendDirectMessage(battlefieldStatus.Write());
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -41,9 +41,6 @@ struct GroupQueueInfo // stores informatio
|
||||
{
|
||||
std::map<ObjectGuid, PlayerQueueInfo*> Players; // player queue info map
|
||||
uint32 Team; // Player team (ALLIANCE/HORDE)
|
||||
BattlegroundTypeId BgTypeId; // battleground type id
|
||||
bool IsRated; // rated
|
||||
uint8 ArenaType; // 2v2, 3v3, 5v5 or 0 when BG
|
||||
uint32 ArenaTeamId; // team id if rated match
|
||||
uint32 JoinTime; // time when group was added
|
||||
uint32 RemoveInviteTime; // time when we will remove invite for players in group
|
||||
@@ -84,7 +81,7 @@ class TC_GAME_API BattlegroundQueue
|
||||
bool CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);
|
||||
bool CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
|
||||
bool CheckSkirmishForSameFaction(BattlegroundBracketId bracket_id, uint32 minPlayersPerTeam);
|
||||
GroupQueueInfo* AddGroup(Player* leader, Group* group, BattlegroundTypeId bgTypeId, PVPDifficultyEntry const* bracketEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId = 0);
|
||||
GroupQueueInfo* AddGroup(Player* leader, Group* group, PVPDifficultyEntry const* bracketEntry, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId = 0);
|
||||
void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount);
|
||||
bool IsPlayerInvited(ObjectGuid pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime);
|
||||
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo);
|
||||
@@ -126,6 +123,8 @@ class TC_GAME_API BattlegroundQueue
|
||||
//one selection pool for horde, other one for alliance
|
||||
SelectionPool m_SelectionPools[BG_TEAMS_COUNT];
|
||||
uint32 GetPlayersInQueue(TeamId id);
|
||||
|
||||
BattlegroundQueueTypeId const GetQueueId() const { return m_queueId; }
|
||||
private:
|
||||
|
||||
BattlegroundQueueTypeId m_queueId;
|
||||
|
||||
@@ -167,12 +167,12 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPackets::Battleground::Batt
|
||||
return;
|
||||
|
||||
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
|
||||
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, nullptr, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0);
|
||||
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, nullptr, bracketEntry, false, isPremade, 0, 0);
|
||||
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
|
||||
uint32 queueSlot = _player->AddBattlegroundQueueId(bgQueueTypeId);
|
||||
|
||||
WorldPackets::Battleground::BattlefieldStatusQueued battlefieldStatus;
|
||||
sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, _player, queueSlot, ginfo->JoinTime, bgQueueTypeId, avgTime, ginfo->ArenaType, false);
|
||||
sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, _player, queueSlot, ginfo->JoinTime, bgQueueTypeId, avgTime, 0, false);
|
||||
SendPacket(battlefieldStatus.Write());
|
||||
|
||||
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue { BattlemasterListId: %hu, Type: %u, Rated: %s, TeamSize: %u }, %s, NAME %s",
|
||||
@@ -195,7 +195,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPackets::Battleground::Batt
|
||||
if (!err)
|
||||
{
|
||||
TC_LOG_DEBUG("bg.battleground", "Battleground: the following players are joining as group:");
|
||||
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0);
|
||||
ginfo = bgQueue.AddGroup(_player, grp, bracketEntry, false, isPremade, 0, 0);
|
||||
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPackets::Battleground::Batt
|
||||
uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
|
||||
|
||||
WorldPackets::Battleground::BattlefieldStatusQueued battlefieldStatus;
|
||||
sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, member, queueSlot, ginfo->JoinTime, bgQueueTypeId, avgTime, ginfo->ArenaType, true);
|
||||
sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, member, queueSlot, ginfo->JoinTime, bgQueueTypeId, avgTime, 0, true);
|
||||
member->SendDirectMessage(battlefieldStatus.Write());
|
||||
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue { BattlemasterListId: %hu, Type: %u, Rated: %s, TeamSize: %u }, %s, NAME %s",
|
||||
bgQueueTypeId.BattlemasterListId, uint32(bgQueueTypeId.Type), bgQueueTypeId.Rated ? "true" : "false", uint32(bgQueueTypeId.TeamSize),
|
||||
@@ -324,7 +324,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPackets::Battleground::Battl
|
||||
return;
|
||||
|
||||
//some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it
|
||||
if (battlefieldPort.AcceptedInvite && ginfo.ArenaType == 0)
|
||||
if (battlefieldPort.AcceptedInvite && bgQueue.GetQueueId().TeamSize == 0)
|
||||
{
|
||||
//if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue
|
||||
if (!_player->CanJoinToBattleground(bg))
|
||||
@@ -397,7 +397,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPackets::Battleground::Battl
|
||||
else // leave queue
|
||||
{
|
||||
// if player leaves rated arena match before match start, it is counted as he played but he lost
|
||||
if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID)
|
||||
if (bgQueue.GetQueueId().Rated && ginfo.IsInvitedToBGInstanceGUID)
|
||||
{
|
||||
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ginfo.Team);
|
||||
if (at)
|
||||
@@ -415,7 +415,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPackets::Battleground::Battl
|
||||
_player->RemoveBattlegroundQueueId(bgQueueTypeId); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs
|
||||
bgQueue.RemovePlayer(_player->GetGUID(), true);
|
||||
// player left queue, we should update it - do not update Arena Queue
|
||||
if (!ginfo.ArenaType)
|
||||
if (!bgQueue.GetQueueId().TeamSize)
|
||||
sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, bgQueueTypeId, bracketEntry->GetBracketId());
|
||||
|
||||
TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%s) left queue for bgtype %u, queue { BattlemasterListId: %hu, Type: %u, Rated: %s, TeamSize: %u }.",
|
||||
@@ -553,7 +553,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPackets::Battleground::Battl
|
||||
{
|
||||
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);
|
||||
ginfo = bgQueue.AddGroup(_player, grp, bracketEntry, false, arenaRating, matchmakerRating, ateamId);
|
||||
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user