mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 10:56:38 +01:00
Merge pull request #3901 from Yelvann/master
Core/Arenas: Members of same arena team were able to fight each othe...
This commit is contained in:
@@ -911,104 +911,83 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId
|
||||
uint32 discardTime = getMSTime() - sBattlegroundMgr->GetRatingDiscardTimer();
|
||||
|
||||
// we need to find 2 teams which will play next game
|
||||
|
||||
GroupsQueueType::iterator itr_team[BG_TEAMS_COUNT];
|
||||
|
||||
//optimalization : --- we dont need to use selection_pools - each update we select max 2 groups
|
||||
for (uint32 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++)
|
||||
GroupsQueueType::iterator itr_teams[BG_TEAMS_COUNT];
|
||||
uint8 found = 0;
|
||||
uint8 team = 0;
|
||||
|
||||
for (uint8 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++)
|
||||
{
|
||||
// take the group that joined first
|
||||
itr_team[i] = m_QueuedGroups[bracket_id][i].begin();
|
||||
for (; itr_team[i] != m_QueuedGroups[bracket_id][i].end(); ++(itr_team[i]))
|
||||
GroupsQueueType::iterator itr = m_QueuedGroups[bracket_id][i].begin();
|
||||
for (; itr != m_QueuedGroups[bracket_id][i].end(); ++itr)
|
||||
{
|
||||
// if group match conditions, then add it to pool
|
||||
if (!(*itr_team[i])->IsInvitedToBGInstanceGUID
|
||||
&& (((*itr_team[i])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[i])->ArenaMatchmakerRating <= arenaMaxRating)
|
||||
|| (*itr_team[i])->JoinTime < discardTime))
|
||||
if (!(*itr)->IsInvitedToBGInstanceGUID
|
||||
&& (((*itr)->ArenaMatchmakerRating >= arenaMinRating && (*itr)->ArenaMatchmakerRating <= arenaMaxRating)
|
||||
|| (*itr)->JoinTime < discardTime))
|
||||
{
|
||||
m_SelectionPools[i].AddGroup((*itr_team[i]), MaxPlayersPerTeam);
|
||||
// break for cycle to be able to start selecting another group from same faction queue
|
||||
itr_teams[found++] = itr;
|
||||
team = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now we are done if we have 2 groups - ali vs horde!
|
||||
// if we don't have, we must try to continue search in same queue
|
||||
// tmp variables are correctly set
|
||||
// this code isn't much userfriendly - but it is supposed to continue search for mathing group in HORDE queue
|
||||
if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() == 0 && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount())
|
||||
|
||||
if (!found)
|
||||
return;
|
||||
|
||||
if (found == 1)
|
||||
{
|
||||
itr_team[BG_TEAM_ALLIANCE] = itr_team[BG_TEAM_HORDE];
|
||||
++itr_team[BG_TEAM_ALLIANCE];
|
||||
for (; itr_team[BG_TEAM_ALLIANCE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++(itr_team[BG_TEAM_ALLIANCE]))
|
||||
for (GroupsQueueType::iterator itr = itr_teams[0]; itr != m_QueuedGroups[bracket_id][team].end(); ++itr)
|
||||
{
|
||||
if (!(*itr_team[BG_TEAM_ALLIANCE])->IsInvitedToBGInstanceGUID
|
||||
&& (((*itr_team[BG_TEAM_ALLIANCE])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[BG_TEAM_ALLIANCE])->ArenaMatchmakerRating <= arenaMaxRating)
|
||||
|| (*itr_team[BG_TEAM_ALLIANCE])->JoinTime < discardTime))
|
||||
if (!(*itr)->IsInvitedToBGInstanceGUID
|
||||
&& (((*itr)->ArenaMatchmakerRating >= arenaMinRating && (*itr)->ArenaMatchmakerRating <= arenaMaxRating)
|
||||
|| (*itr)->JoinTime < discardTime)
|
||||
&& (*itr_teams[0])->ArenaTeamId != (*itr)->ArenaTeamId)
|
||||
{
|
||||
m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*itr_team[BG_TEAM_ALLIANCE]), MaxPlayersPerTeam);
|
||||
itr_teams[found++] = itr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this code isn't much userfriendly - but it is supposed to continue search for mathing group in ALLIANCE queue
|
||||
if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == 0 && m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount())
|
||||
{
|
||||
itr_team[BG_TEAM_HORDE] = itr_team[BG_TEAM_ALLIANCE];
|
||||
++itr_team[BG_TEAM_HORDE];
|
||||
for (; itr_team[BG_TEAM_HORDE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++(itr_team[BG_TEAM_HORDE]))
|
||||
{
|
||||
if (!(*itr_team[BG_TEAM_HORDE])->IsInvitedToBGInstanceGUID
|
||||
&& (((*itr_team[BG_TEAM_HORDE])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[BG_TEAM_HORDE])->ArenaMatchmakerRating <= arenaMaxRating)
|
||||
|| (*itr_team[BG_TEAM_HORDE])->JoinTime < discardTime))
|
||||
{
|
||||
m_SelectionPools[BG_TEAM_HORDE].AddGroup((*itr_team[BG_TEAM_HORDE]), MaxPlayersPerTeam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//if we have 2 teams, then start new arena and invite players!
|
||||
if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount())
|
||||
if (found == 2)
|
||||
{
|
||||
GroupQueueInfo* aTeam = *itr_teams[BG_TEAM_ALLIANCE];
|
||||
GroupQueueInfo* hTeam = *itr_teams[BG_TEAM_HORDE];
|
||||
Battleground* arena = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, arenaType, true);
|
||||
if (!arena)
|
||||
{
|
||||
sLog->outError("BattlegroundQueue::Update couldn't create arena instance for rated arena match!");
|
||||
return;
|
||||
}
|
||||
|
||||
(*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamRating;
|
||||
(*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsMatchmakerRating = (*(itr_team[BG_TEAM_HORDE]))->ArenaMatchmakerRating;
|
||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamId, (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsTeamRating);
|
||||
(*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamRating;
|
||||
(*(itr_team[BG_TEAM_HORDE]))->OpponentsMatchmakerRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaMatchmakerRating;
|
||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamId, (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating);
|
||||
|
||||
aTeam->OpponentsTeamRating = hTeam->ArenaTeamRating;
|
||||
hTeam->OpponentsTeamRating = aTeam->ArenaTeamRating;
|
||||
aTeam->OpponentsMatchmakerRating = hTeam->ArenaMatchmakerRating;
|
||||
hTeam->OpponentsMatchmakerRating = aTeam->ArenaMatchmakerRating;
|
||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", aTeam->ArenaTeamId, aTeam->OpponentsTeamRating);
|
||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", hTeam->ArenaTeamId, hTeam->OpponentsTeamRating);
|
||||
|
||||
// now we must move team if we changed its faction to another faction queue, because then we will spam log by errors in Queue::RemovePlayer
|
||||
if ((*(itr_team[BG_TEAM_ALLIANCE]))->Team != ALLIANCE)
|
||||
if (aTeam->Team != ALLIANCE)
|
||||
{
|
||||
// add to alliance queue
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(*(itr_team[BG_TEAM_ALLIANCE]));
|
||||
// erase from horde queue
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_team[BG_TEAM_ALLIANCE]);
|
||||
itr_team[BG_TEAM_ALLIANCE] = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin();
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(aTeam);
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_teams[BG_TEAM_ALLIANCE]);
|
||||
}
|
||||
if ((*(itr_team[BG_TEAM_HORDE]))->Team != HORDE)
|
||||
if (hTeam->Team != HORDE)
|
||||
{
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(*(itr_team[BG_TEAM_HORDE]));
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_team[BG_TEAM_HORDE]);
|
||||
itr_team[BG_TEAM_HORDE] = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].begin();
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(hTeam);
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_teams[BG_TEAM_HORDE]);
|
||||
}
|
||||
|
||||
arena->SetArenaMatchmakerRating(ALLIANCE, (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaMatchmakerRating);
|
||||
arena->SetArenaMatchmakerRating(HORDE, (*(itr_team[BG_TEAM_HORDE]))->ArenaMatchmakerRating);
|
||||
InviteGroupToBG(*(itr_team[BG_TEAM_ALLIANCE]), arena, ALLIANCE);
|
||||
InviteGroupToBG(*(itr_team[BG_TEAM_HORDE]), arena, HORDE);
|
||||
|
||||
|
||||
arena->SetArenaMatchmakerRating(ALLIANCE, aTeam->ArenaMatchmakerRating);
|
||||
arena->SetArenaMatchmakerRating( HORDE, hTeam->ArenaMatchmakerRating);
|
||||
InviteGroupToBG(aTeam, arena, ALLIANCE);
|
||||
InviteGroupToBG(hTeam, arena, HORDE);
|
||||
|
||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Starting rated arena match!");
|
||||
|
||||
arena->StartBattleground();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user