Use PVPDificulty.dbc for bg/arena bracket selection (levels and difficulty). Rename BG/arena queue_id to bracket_id and related functions/etc. Author: VladimirMangos.
--HG-- branch : trunk
This commit is contained in:
+236
-226
@@ -56,13 +56,13 @@ INSTANTIATE_SINGLETON_1( BattleGroundMgr );
|
||||
|
||||
BattleGroundQueue::BattleGroundQueue()
|
||||
{
|
||||
for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
|
||||
for (uint32 i = 0; i < BG_TEAMS_COUNT; ++i)
|
||||
{
|
||||
for (uint32 j = 0; j < MAX_BATTLEGROUND_QUEUES; j++)
|
||||
for (uint32 j = 0; j < MAX_BATTLEGROUND_BRACKETS; ++j)
|
||||
{
|
||||
m_SumOfWaitTimes[i][j] = 0;
|
||||
m_WaitTimeLastPlayer[i][j] = 0;
|
||||
for (uint32 k = 0; k < COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME; k++)
|
||||
for (uint32 k = 0; k < COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME; ++k)
|
||||
m_WaitTimes[i][j][k] = 0;
|
||||
}
|
||||
}
|
||||
@@ -71,9 +71,9 @@ BattleGroundQueue::BattleGroundQueue()
|
||||
BattleGroundQueue::~BattleGroundQueue()
|
||||
{
|
||||
m_QueuedPlayers.clear();
|
||||
for (int i = 0; i < MAX_BATTLEGROUND_QUEUES; i++)
|
||||
for (int i = 0; i < MAX_BATTLEGROUND_BRACKETS; ++i)
|
||||
{
|
||||
for (uint32 j = 0; j < BG_QUEUE_GROUP_TYPES_COUNT; j++)
|
||||
for (uint32 j = 0; j < BG_QUEUE_GROUP_TYPES_COUNT; ++j)
|
||||
{
|
||||
for (GroupsQueueType::iterator itr = m_QueuedGroups[i][j].begin(); itr!= m_QueuedGroups[i][j].end(); ++itr)
|
||||
delete (*itr);
|
||||
@@ -149,14 +149,12 @@ bool BattleGroundQueue::SelectionPool::AddGroup(GroupQueueInfo *ginfo, uint32 de
|
||||
/*** BATTLEGROUND QUEUES ***/
|
||||
/*********************************************************/
|
||||
|
||||
// add group to bg queue with the given leader and bg specifications
|
||||
GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, BattleGroundTypeId BgTypeId, uint8 ArenaType, bool isRated, bool isPremade, uint32 arenaRating, uint32 arenateamid)
|
||||
// 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* backetEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 arenaRating, uint32 arenateamid)
|
||||
{
|
||||
BGQueueIdBasedOnLevel queue_id = leader->GetBattleGroundQueueIdFromLevel(BgTypeId);
|
||||
BattleGroundBracketId bracketId = backetEntry->GetBracketId();
|
||||
|
||||
// create new ginfo
|
||||
// cannot use the method like in addplayer, because that could modify an in-queue group's stats
|
||||
// (e.g. leader leaving queue then joining as individual again)
|
||||
GroupQueueInfo* ginfo = new GroupQueueInfo;
|
||||
ginfo->BgTypeId = BgTypeId;
|
||||
ginfo->ArenaType = ArenaType;
|
||||
@@ -177,27 +175,84 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, BattleGroundTypeId
|
||||
index += BG_TEAMS_COUNT;
|
||||
if (ginfo->Team == HORDE)
|
||||
index++;
|
||||
sLog.outDebug("Adding Group to BattleGroundQueue bgTypeId : %u, queue_id : %u, index : %u", BgTypeId, queue_id, index);
|
||||
sLog.outDebug("Adding Group to BattleGroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
|
||||
|
||||
m_QueuedGroups[queue_id][index].push_back(ginfo);
|
||||
uint32 lastOnlineTime = getMSTime();
|
||||
|
||||
//announce world (this don't need mutex)
|
||||
if (isRated && sWorld.getConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
||||
{
|
||||
sWorld.SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, ginfo->ArenaType, ginfo->ArenaType, ginfo->ArenaTeamRating);
|
||||
}
|
||||
|
||||
//add players from group to ginfo
|
||||
{
|
||||
//ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_Lock);
|
||||
if (grp)
|
||||
{
|
||||
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
Player *member = itr->getSource();
|
||||
if(!member)
|
||||
continue; // this should never happen
|
||||
PlayerQueueInfo& pl_info = m_QueuedPlayers[member->GetGUID()];
|
||||
pl_info.LastOnlineTime = lastOnlineTime;
|
||||
pl_info.GroupInfo = ginfo;
|
||||
// add the pinfo to ginfo's list
|
||||
ginfo->Players[member->GetGUID()] = &pl_info;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerQueueInfo& pl_info = m_QueuedPlayers[leader->GetGUID()];
|
||||
pl_info.LastOnlineTime = lastOnlineTime;
|
||||
pl_info.GroupInfo = ginfo;
|
||||
ginfo->Players[leader->GetGUID()] = &pl_info;
|
||||
}
|
||||
|
||||
//add GroupInfo to m_QueuedGroups
|
||||
m_QueuedGroups[bracketId][index].push_back(ginfo);
|
||||
|
||||
//announce to world, this code needs mutex
|
||||
if (!isRated && !isPremade && sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
|
||||
{
|
||||
if (BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(ginfo->BgTypeId))
|
||||
{
|
||||
char const* bgName = bg->GetName();
|
||||
uint32 MinPlayers = bg->GetMinPlayersPerTeam();
|
||||
uint32 qHorde = 0;
|
||||
uint32 qAlliance = 0;
|
||||
uint32 q_min_level = backetEntry->minLevel;
|
||||
uint32 q_max_level = backetEntry->maxLevel;
|
||||
GroupsQueueType::const_iterator itr;
|
||||
for(itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr)
|
||||
if (!(*itr)->IsInvitedToBGInstanceGUID)
|
||||
qAlliance += (*itr)->Players.size();
|
||||
for(itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
|
||||
if (!(*itr)->IsInvitedToBGInstanceGUID)
|
||||
qHorde += (*itr)->Players.size();
|
||||
|
||||
// Show queue status to player only (when joining queue)
|
||||
if (sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
|
||||
{
|
||||
ChatHandler(leader).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level,
|
||||
qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
|
||||
}
|
||||
// System message
|
||||
else
|
||||
{
|
||||
sWorld.SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level,
|
||||
qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//release mutex
|
||||
}
|
||||
|
||||
// return ginfo, because it is needed to add players to this group info
|
||||
return ginfo;
|
||||
}
|
||||
|
||||
//add player to playermap
|
||||
void BattleGroundQueue::AddPlayer(Player *plr, GroupQueueInfo *ginfo)
|
||||
{
|
||||
//if player isn't in queue, he is added, if already is, then values are overwritten, no memory leak
|
||||
PlayerQueueInfo& info = m_QueuedPlayers[plr->GetGUID()];
|
||||
info.LastOnlineTime = getMSTime();
|
||||
info.GroupInfo = ginfo;
|
||||
|
||||
// add the pinfo to ginfo's list
|
||||
ginfo->Players[plr->GetGUID()] = &info;
|
||||
}
|
||||
|
||||
void BattleGroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BGQueueIdBasedOnLevel queue_id)
|
||||
void BattleGroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattleGroundBracketId bracket_id)
|
||||
{
|
||||
uint32 timeInQueue = getMSTimeDiff(ginfo->JoinTime, getMSTime());
|
||||
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
|
||||
@@ -213,19 +268,19 @@ void BattleGroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* g
|
||||
}
|
||||
|
||||
//store pointer to arrayindex of player that was added first
|
||||
uint32* lastPlayerAddedPointer = &(m_WaitTimeLastPlayer[team_index][queue_id]);
|
||||
uint32* lastPlayerAddedPointer = &(m_WaitTimeLastPlayer[team_index][bracket_id]);
|
||||
//remove his time from sum
|
||||
m_SumOfWaitTimes[team_index][queue_id] -= m_WaitTimes[team_index][queue_id][(*lastPlayerAddedPointer)];
|
||||
m_SumOfWaitTimes[team_index][bracket_id] -= m_WaitTimes[team_index][bracket_id][(*lastPlayerAddedPointer)];
|
||||
//set average time to new
|
||||
m_WaitTimes[team_index][queue_id][(*lastPlayerAddedPointer)] = timeInQueue;
|
||||
m_WaitTimes[team_index][bracket_id][(*lastPlayerAddedPointer)] = timeInQueue;
|
||||
//add new time to sum
|
||||
m_SumOfWaitTimes[team_index][queue_id] += timeInQueue;
|
||||
m_SumOfWaitTimes[team_index][bracket_id] += timeInQueue;
|
||||
//set index of last player added to next one
|
||||
(*lastPlayerAddedPointer)++;
|
||||
(*lastPlayerAddedPointer) %= COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME;
|
||||
}
|
||||
|
||||
uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BGQueueIdBasedOnLevel queue_id)
|
||||
uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattleGroundBracketId bracket_id)
|
||||
{
|
||||
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
|
||||
if (!ginfo->ArenaType)
|
||||
@@ -239,8 +294,8 @@ uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BGQueue
|
||||
team_index = BG_TEAM_HORDE; //for rated arenas use BG_TEAM_HORDE
|
||||
}
|
||||
//check if there is enought values(we always add values > 0)
|
||||
if (m_WaitTimes[team_index][queue_id][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME - 1] )
|
||||
return (m_SumOfWaitTimes[team_index][queue_id] / COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME);
|
||||
if (m_WaitTimes[team_index][bracket_id][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME - 1] )
|
||||
return (m_SumOfWaitTimes[team_index][bracket_id] / COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME);
|
||||
else
|
||||
//if there aren't enough values return 0 - not available
|
||||
return 0;
|
||||
@@ -251,7 +306,7 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
|
||||
{
|
||||
//Player *plr = objmgr.GetPlayer(guid);
|
||||
|
||||
int32 queue_id = -1; // signed for proper for-loop finish
|
||||
int32 bracket_id = -1; // signed for proper for-loop finish
|
||||
QueuedPlayersMap::iterator itr;
|
||||
|
||||
//remove player from map, if he's there
|
||||
@@ -269,17 +324,17 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
|
||||
// variable index removes useless searching in other team's queue
|
||||
uint32 index = (group->Team == HORDE) ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE;
|
||||
|
||||
for (int32 queue_id_tmp = MAX_BATTLEGROUND_QUEUES - 1; queue_id_tmp >= 0 && queue_id == -1; --queue_id_tmp)
|
||||
for (int32 bracket_id_tmp = MAX_BATTLEGROUND_BRACKETS - 1; bracket_id_tmp >= 0 && bracket_id == -1; --bracket_id_tmp)
|
||||
{
|
||||
//we must check premade and normal team's queue - because when players from premade are joining bg,
|
||||
//they leave groupinfo so we can't use its players size to find out index
|
||||
for (uint32 j = index; j < BG_QUEUE_GROUP_TYPES_COUNT; j += BG_QUEUE_NORMAL_ALLIANCE)
|
||||
{
|
||||
for (group_itr_tmp = m_QueuedGroups[queue_id_tmp][j].begin(); group_itr_tmp != m_QueuedGroups[queue_id_tmp][j].end(); ++group_itr_tmp)
|
||||
for(group_itr_tmp = m_QueuedGroups[bracket_id_tmp][j].begin(); group_itr_tmp != m_QueuedGroups[bracket_id_tmp][j].end(); ++group_itr_tmp)
|
||||
{
|
||||
if ((*group_itr_tmp) == group)
|
||||
{
|
||||
queue_id = queue_id_tmp;
|
||||
bracket_id = bracket_id_tmp;
|
||||
group_itr = group_itr_tmp;
|
||||
//we must store index to be able to erase iterator
|
||||
index = j;
|
||||
@@ -289,12 +344,12 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
|
||||
}
|
||||
}
|
||||
//player can't be in queue without group, but just in case
|
||||
if (queue_id == -1)
|
||||
if (bracket_id == -1)
|
||||
{
|
||||
sLog.outError("BattleGroundQueue: ERROR Cannot find groupinfo for player GUID: %u", GUID_LOPART(guid));
|
||||
return;
|
||||
}
|
||||
sLog.outDebug("BattleGroundQueue: Removing player GUID %u, from queue_id %u", GUID_LOPART(guid), (uint32)queue_id);
|
||||
sLog.outDebug("BattleGroundQueue: Removing player GUID %u, from bracket_id %u", GUID_LOPART(guid), (uint32)bracket_id);
|
||||
|
||||
// ALL variables are correctly set
|
||||
// We can ignore leveling up in queue - it should not cause crash
|
||||
@@ -317,9 +372,9 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
|
||||
// remove player queue info
|
||||
m_QueuedPlayers.erase(itr);
|
||||
|
||||
//if we left BG queue(not porting) OR if arena team left queue for rated match
|
||||
if ((decreaseInvitedCount && !group->ArenaType) || (group->ArenaType && group->IsRated && group->Players.empty()))
|
||||
AnnounceWorld(group, guid, false);
|
||||
// announce to world if arena team left queue for rated match, show only once
|
||||
if (group->ArenaType && group->IsRated && group->Players.empty() && sWorld.getConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
||||
sWorld.SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, group->ArenaType, group->ArenaType, group->ArenaTeamRating);
|
||||
|
||||
//if player leaves queue and he is invited to rated arena match, then he have to loose
|
||||
if (group->IsInvitedToBGInstanceGUID && group->IsRated && decreaseInvitedCount)
|
||||
@@ -340,7 +395,7 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
|
||||
// remove group queue info if needed
|
||||
if (group->Players.empty())
|
||||
{
|
||||
m_QueuedGroups[queue_id][index].erase(group_itr);
|
||||
m_QueuedGroups[bracket_id][index].erase(group_itr);
|
||||
delete group;
|
||||
}
|
||||
// if group wasn't empty, so it wasn't deleted, and player have left a rated
|
||||
@@ -366,78 +421,22 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
|
||||
}
|
||||
}
|
||||
|
||||
//Announce world message
|
||||
void BattleGroundQueue::AnnounceWorld(GroupQueueInfo *ginfo, const uint64& playerGUID, bool isAddedToQueue)
|
||||
//returns true when player pl_guid is in queue and is invited to bgInstanceGuid
|
||||
bool BattleGroundQueue::IsPlayerInvited(const uint64& pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime)
|
||||
{
|
||||
if(ginfo->ArenaType) //if Arena
|
||||
{
|
||||
if (sWorld.getConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE) && ginfo->IsRated)
|
||||
{
|
||||
BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(ginfo->BgTypeId);
|
||||
if (!bg)
|
||||
return;
|
||||
QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(pl_guid);
|
||||
return ( qItr != m_QueuedPlayers.end()
|
||||
&& qItr->second.GroupInfo->IsInvitedToBGInstanceGUID == bgInstanceGuid
|
||||
&& qItr->second.GroupInfo->RemoveInviteTime == removeTime );
|
||||
}
|
||||
|
||||
char const* bgName = bg->GetName();
|
||||
if (isAddedToQueue)
|
||||
{
|
||||
if (sWorld.getConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_PLAYERONLY))
|
||||
{
|
||||
if(Player *plr = objmgr.GetPlayer(playerGUID))
|
||||
ChatHandler(plr).PSendSysMessage(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, bgName, ginfo->ArenaType, ginfo->ArenaType, ginfo->ArenaTeamRating);
|
||||
}
|
||||
else
|
||||
sWorld.SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, bgName, ginfo->ArenaType, ginfo->ArenaType, ginfo->ArenaTeamRating);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sWorld.getConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_PLAYERONLY))
|
||||
{
|
||||
if(Player *plr = objmgr.GetPlayer(playerGUID))
|
||||
ChatHandler(plr).PSendSysMessage(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, bgName, ginfo->ArenaType, ginfo->ArenaType, ginfo->ArenaTeamRating);
|
||||
}
|
||||
else
|
||||
sWorld.SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, bgName, ginfo->ArenaType, ginfo->ArenaType, ginfo->ArenaTeamRating);
|
||||
}
|
||||
}
|
||||
}
|
||||
else //if BG
|
||||
{
|
||||
if (sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
|
||||
{
|
||||
Player *plr = objmgr.GetPlayer(playerGUID);
|
||||
BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(ginfo->BgTypeId);
|
||||
if (!bg || !plr)
|
||||
return;
|
||||
|
||||
BGQueueIdBasedOnLevel queue_id = plr->GetBattleGroundQueueIdFromLevel(bg->GetTypeID());
|
||||
char const* bgName = bg->GetName();
|
||||
uint32 MinPlayers = bg->GetMinPlayersPerTeam();
|
||||
uint32 qHorde = 0;
|
||||
uint32 qAlliance = 0;
|
||||
uint32 q_min_level = (queue_id + 1) * 10;
|
||||
uint32 q_max_level = std::min(q_min_level + 9, sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
|
||||
GroupsQueueType::const_iterator itr;
|
||||
for (itr = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr)
|
||||
if (!(*itr)->IsInvitedToBGInstanceGUID)
|
||||
qAlliance += (*itr)->Players.size();
|
||||
for (itr = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
|
||||
if (!(*itr)->IsInvitedToBGInstanceGUID)
|
||||
qHorde += (*itr)->Players.size();
|
||||
|
||||
// Show queue status to player only (when joining queue)
|
||||
if (sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
|
||||
{
|
||||
ChatHandler(plr).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF,
|
||||
bgName, q_min_level, q_max_level, qAlliance, MinPlayers, qHorde, MinPlayers);
|
||||
}
|
||||
// System message
|
||||
else
|
||||
{
|
||||
sWorld.SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD,
|
||||
bgName, q_min_level, q_max_level, qAlliance, MinPlayers, qHorde, MinPlayers);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool BattleGroundQueue::GetPlayerGroupInfoData(const uint64& guid, GroupQueueInfo* ginfo)
|
||||
{
|
||||
QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(guid);
|
||||
if (qItr == m_QueuedPlayers.end())
|
||||
return false;
|
||||
*ginfo = *(qItr->second.GroupInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, uint32 side)
|
||||
@@ -453,7 +452,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
|
||||
ginfo->IsInvitedToBGInstanceGUID = bg->GetInstanceID();
|
||||
BattleGroundTypeId bgTypeId = bg->GetTypeID();
|
||||
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, bg->GetArenaType());
|
||||
BGQueueIdBasedOnLevel queue_id = bg->GetQueueId();
|
||||
BattleGroundBracketId bracket_id = bg->GetBracketId();
|
||||
|
||||
// set ArenaTeamId for rated matches
|
||||
if (bg->isArena() && bg->isRated())
|
||||
@@ -471,7 +470,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
|
||||
continue;
|
||||
|
||||
// invite the player
|
||||
PlayerInvitedToBGUpdateAverageWaitTime(ginfo, queue_id);
|
||||
PlayerInvitedToBGUpdateAverageWaitTime(ginfo, bracket_id);
|
||||
//sBattleGroundMgr.InvitePlayer(plr, bg, ginfo->Team);
|
||||
|
||||
// set invited player counters
|
||||
@@ -480,7 +479,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
|
||||
plr->SetInviteForBattleGroundQueueType(bgQueueTypeId, ginfo->IsInvitedToBGInstanceGUID);
|
||||
|
||||
// create remind invite events
|
||||
BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(plr->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, ginfo->RemoveInviteTime);
|
||||
BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(plr->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, ginfo->ArenaType, ginfo->RemoveInviteTime);
|
||||
plr->m_Events.AddEvent(inviteEvent, plr->m_Events.CalculateTime(INVITATION_REMIND_TIME));
|
||||
// create automatic remove events
|
||||
BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(plr->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, bgQueueTypeId, ginfo->RemoveInviteTime);
|
||||
@@ -507,22 +506,22 @@ This function is inviting players to already running battlegrounds
|
||||
Invitation type is based on config file
|
||||
large groups are disadvantageous, because they will be kicked first if invitation type = 1
|
||||
*/
|
||||
void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BGQueueIdBasedOnLevel queue_id)
|
||||
void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BattleGroundBracketId bracket_id)
|
||||
{
|
||||
int32 hordeFree = bg->GetFreeSlotsForTeam(HORDE);
|
||||
int32 aliFree = bg->GetFreeSlotsForTeam(ALLIANCE);
|
||||
|
||||
//iterator for iterating through bg queue
|
||||
GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE].begin();
|
||||
GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].begin();
|
||||
//count of groups in queue - used to stop cycles
|
||||
uint32 aliCount = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE].size();
|
||||
uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size();
|
||||
//index to queue which group is current
|
||||
uint32 aliIndex = 0;
|
||||
for (; aliIndex < aliCount && m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree); aliIndex++)
|
||||
++Ali_itr;
|
||||
//the same thing for horde
|
||||
GroupsQueueType::const_iterator Horde_itr = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_HORDE].begin();
|
||||
uint32 hordeCount = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_HORDE].size();
|
||||
GroupsQueueType::const_iterator Horde_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].begin();
|
||||
uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size();
|
||||
uint32 hordeIndex = 0;
|
||||
for (; hordeIndex < hordeCount && m_SelectionPools[BG_TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); hordeIndex++)
|
||||
++Horde_itr;
|
||||
@@ -585,22 +584,22 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BGQueueIdBasedOnLevel
|
||||
// this method checks if premade versus premade battleground is possible
|
||||
// then after 30 mins (default) in queue it moves premade group to normal queue
|
||||
// it tries to invite as much players as it can - to MaxPlayersPerTeam, because premade groups have more than MinPlayersPerTeam players
|
||||
bool BattleGroundQueue::CheckPremadeMatch(BGQueueIdBasedOnLevel queue_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam)
|
||||
bool BattleGroundQueue::CheckPremadeMatch(BattleGroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam)
|
||||
{
|
||||
//check match
|
||||
if (!m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].empty() && !m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].empty())
|
||||
if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].empty() && !m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty())
|
||||
{
|
||||
//start premade match
|
||||
//if groups aren't invited
|
||||
GroupsQueueType::const_iterator ali_group, horde_group;
|
||||
for (ali_group = m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].begin(); ali_group != m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++ali_group)
|
||||
for( ali_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin(); ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++ali_group)
|
||||
if (!(*ali_group)->IsInvitedToBGInstanceGUID)
|
||||
break;
|
||||
for (horde_group = m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].begin(); horde_group != m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].end(); ++horde_group)
|
||||
for( horde_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].begin(); horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++horde_group)
|
||||
if (!(*horde_group)->IsInvitedToBGInstanceGUID)
|
||||
break;
|
||||
|
||||
if (ali_group != m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].end() && horde_group != m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].end())
|
||||
if (ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end() && horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end())
|
||||
{
|
||||
m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*ali_group), MaxPlayersPerTeam);
|
||||
m_SelectionPools[BG_TEAM_HORDE].AddGroup((*horde_group), MaxPlayersPerTeam);
|
||||
@@ -609,7 +608,7 @@ bool BattleGroundQueue::CheckPremadeMatch(BGQueueIdBasedOnLevel queue_id, uint32
|
||||
GroupsQueueType::const_iterator itr;
|
||||
for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
|
||||
{
|
||||
for (itr = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + i].begin(); itr != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + i].end(); ++itr)
|
||||
for(itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].end(); ++itr)
|
||||
{
|
||||
//if itr can join BG and player count is less that maxPlayers, then add group to selectionpool
|
||||
if (!(*itr)->IsInvitedToBGInstanceGUID && !m_SelectionPools[i].AddGroup((*itr), maxPlayers))
|
||||
@@ -627,14 +626,14 @@ bool BattleGroundQueue::CheckPremadeMatch(BGQueueIdBasedOnLevel queue_id, uint32
|
||||
uint32 time_before = getMSTime() - sWorld.getConfig(CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH);
|
||||
for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
|
||||
{
|
||||
if (!m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE + i].empty())
|
||||
if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i].empty())
|
||||
{
|
||||
GroupsQueueType::iterator itr = m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE + i].begin();
|
||||
GroupsQueueType::iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i].begin();
|
||||
if (!(*itr)->IsInvitedToBGInstanceGUID && ((*itr)->JoinTime < time_before || (*itr)->Players.size() < MinPlayersPerTeam))
|
||||
{
|
||||
//we must insert group to normal queue and erase pointer from premade queue
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + i].push_front((*itr));
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE + i].erase(itr);
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].push_front((*itr));
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i].erase(itr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -643,13 +642,13 @@ bool BattleGroundQueue::CheckPremadeMatch(BGQueueIdBasedOnLevel queue_id, uint32
|
||||
}
|
||||
|
||||
// this method tries to create battleground or arena with MinPlayersPerTeam against MinPlayersPerTeam
|
||||
bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BGQueueIdBasedOnLevel queue_id, uint32 minPlayers, uint32 maxPlayers)
|
||||
bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BattleGroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers)
|
||||
{
|
||||
GroupsQueueType::const_iterator itr_team[BG_TEAMS_COUNT];
|
||||
for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
|
||||
{
|
||||
itr_team[i] = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + i].begin();
|
||||
for (; itr_team[i] != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + i].end(); ++(itr_team[i]))
|
||||
itr_team[i] = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].begin();
|
||||
for(; itr_team[i] != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].end(); ++(itr_team[i]))
|
||||
{
|
||||
if (!(*(itr_team[i]))->IsInvitedToBGInstanceGUID)
|
||||
{
|
||||
@@ -668,7 +667,7 @@ bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BGQueueIdBas
|
||||
{
|
||||
//we will try to invite more groups to team with less players indexed by j
|
||||
++(itr_team[j]); //this will not cause a crash, because for cycle above reached break;
|
||||
for (; itr_team[j] != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + j].end(); ++(itr_team[j]))
|
||||
for(; itr_team[j] != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + j].end(); ++(itr_team[j]))
|
||||
{
|
||||
if (!(*(itr_team[j]))->IsInvitedToBGInstanceGUID)
|
||||
if (!m_SelectionPools[j].AddGroup(*(itr_team[j]), m_SelectionPools[(j + 1) % BG_TEAMS_COUNT].GetPlayerCount()))
|
||||
@@ -686,7 +685,7 @@ bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BGQueueIdBas
|
||||
}
|
||||
|
||||
// this method will check if we can invite players to same faction skirmish match
|
||||
bool BattleGroundQueue::CheckSkirmishForSameFaction(BGQueueIdBasedOnLevel queue_id, uint32 minPlayersPerTeam)
|
||||
bool BattleGroundQueue::CheckSkirmishForSameFaction(BattleGroundBracketId bracket_id, uint32 minPlayersPerTeam)
|
||||
{
|
||||
if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() < minPlayersPerTeam && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() < minPlayersPerTeam)
|
||||
return false;
|
||||
@@ -704,16 +703,16 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BGQueueIdBasedOnLevel queue_
|
||||
//store last ginfo pointer
|
||||
GroupQueueInfo* ginfo = m_SelectionPools[teamIndex].SelectedGroups.back();
|
||||
//set itr_team to group that was added to selection pool latest
|
||||
GroupsQueueType::iterator itr_team = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].begin();
|
||||
for (; itr_team != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr_team)
|
||||
GroupsQueueType::iterator itr_team = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].begin();
|
||||
for(; itr_team != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr_team)
|
||||
if (ginfo == *itr_team)
|
||||
break;
|
||||
if (itr_team == m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end())
|
||||
if (itr_team == m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end())
|
||||
return false;
|
||||
GroupsQueueType::iterator itr_team2 = itr_team;
|
||||
++itr_team2;
|
||||
//invite players to other selection pool
|
||||
for (; itr_team2 != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr_team2)
|
||||
for(; itr_team2 != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr_team2)
|
||||
{
|
||||
//if selection pool is full then break;
|
||||
if (!(*itr_team2)->IsInvitedToBGInstanceGUID && !m_SelectionPools[otherTeam].AddGroup(*itr_team2, minPlayersPerTeam))
|
||||
@@ -728,15 +727,15 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BGQueueIdBasedOnLevel queue_
|
||||
//set correct team
|
||||
(*itr)->Team = otherTeamId;
|
||||
//add team to other queue
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + otherTeam].push_front(*itr);
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + otherTeam].push_front(*itr);
|
||||
//remove team from old queue
|
||||
GroupsQueueType::iterator itr2 = itr_team;
|
||||
++itr2;
|
||||
for (; itr2 != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr2)
|
||||
for(; itr2 != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr2)
|
||||
{
|
||||
if (*itr2 == *itr)
|
||||
{
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].erase(itr2);
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].erase(itr2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -749,24 +748,24 @@ this method is called when group is inserted, or player / group is removed from
|
||||
it must be called after fully adding the members of a group to ensure group joining
|
||||
should be called from BattleGround::RemovePlayer function in some cases
|
||||
*/
|
||||
void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id, uint8 arenaType, bool isRated, uint32 arenaRating)
|
||||
void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id, uint8 arenaType, bool isRated, uint32 arenaRating)
|
||||
{
|
||||
//if no players in queue - do nothing
|
||||
if( m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].empty() &&
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].empty() &&
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE].empty() &&
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_HORDE].empty() )
|
||||
if( m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].empty() &&
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty() &&
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].empty() &&
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty() )
|
||||
return;
|
||||
|
||||
//battleground with free slot for player should be always in the beggining of the queue
|
||||
// maybe it would be better to create bgfreeslotqueue for each queue_id_based_on_level
|
||||
// maybe it would be better to create bgfreeslotqueue for each bracket_id
|
||||
BGFreeSlotQueueType::iterator itr, next;
|
||||
for (itr = sBattleGroundMgr.BGFreeSlotQueue[bgTypeId].begin(); itr != sBattleGroundMgr.BGFreeSlotQueue[bgTypeId].end(); itr = next)
|
||||
{
|
||||
next = itr;
|
||||
++next;
|
||||
// DO NOT allow queue manager to invite new player to arena
|
||||
if( (*itr)->isBattleGround() && (*itr)->GetTypeID() == bgTypeId && (*itr)->GetQueueId() == queue_id &&
|
||||
if( (*itr)->isBattleGround() && (*itr)->GetTypeID() == bgTypeId && (*itr)->GetBracketId() == bracket_id &&
|
||||
(*itr)->GetStatus() > STATUS_WAIT_QUEUE && (*itr)->GetStatus() < STATUS_WAIT_LEAVE )
|
||||
{
|
||||
BattleGround* bg = *itr; //we have to store battleground pointer here, because when battleground is full, it is removed from free queue (not yet implemented!!)
|
||||
@@ -777,7 +776,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
|
||||
m_SelectionPools[BG_TEAM_HORDE].Init();
|
||||
|
||||
// call a function that does the job for us
|
||||
FillPlayersToBG(bg, queue_id);
|
||||
FillPlayersToBG(bg, bracket_id);
|
||||
|
||||
// now everything is set, invite players
|
||||
for (GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++citr)
|
||||
@@ -801,6 +800,14 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
|
||||
sLog.outError("Battleground: Update: bg template not found for %u", bgTypeId);
|
||||
return;
|
||||
}
|
||||
|
||||
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketById(bg_template->GetMapId(),bracket_id);
|
||||
if (!bracketEntry)
|
||||
{
|
||||
sLog.outError("Battleground: Update: bg bracket entry not found for map %u bracket id %u", bg_template->GetMapId(), bracket_id);
|
||||
return;
|
||||
}
|
||||
|
||||
// get the min. players per team, properly for larger arenas as well. (must have full teams for arena matches!)
|
||||
uint32 MinPlayersPerTeam = bg_template->GetMinPlayersPerTeam();
|
||||
uint32 MaxPlayersPerTeam = bg_template->GetMaxPlayersPerTeam();
|
||||
@@ -842,11 +849,11 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
|
||||
if (bg_template->isBattleGround())
|
||||
{
|
||||
//check if there is premade against premade match
|
||||
if (CheckPremadeMatch(queue_id, MinPlayersPerTeam, MaxPlayersPerTeam))
|
||||
if (CheckPremadeMatch(bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam))
|
||||
{
|
||||
//create new battleground
|
||||
BattleGround * bg2 = NULL;
|
||||
if (!(bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, queue_id, 0, false)))
|
||||
BattleGround * bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, 0, false);
|
||||
if (!bg2)
|
||||
{
|
||||
sLog.outError("BattleGroundQueue::Update - Cannot create battleground: %u", bgTypeId);
|
||||
return;
|
||||
@@ -867,12 +874,12 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
|
||||
if (!isRated)
|
||||
{
|
||||
// if there are enough players in pools, start new battleground or non rated arena
|
||||
if (CheckNormalMatch(bg_template, queue_id, MinPlayersPerTeam, MaxPlayersPerTeam)
|
||||
|| (bg_template->isArena() && CheckSkirmishForSameFaction(queue_id, MinPlayersPerTeam)) )
|
||||
if (CheckNormalMatch(bg_template, bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam)
|
||||
|| (bg_template->isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam)) )
|
||||
{
|
||||
// we successfully created a pool
|
||||
BattleGround * bg2 = NULL;
|
||||
if (!(bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, queue_id, arenaType, false)))
|
||||
BattleGround * bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, arenaType, false);
|
||||
if (!bg2)
|
||||
{
|
||||
sLog.outError("BattleGroundQueue::Update - Cannot create battleground: %u", bgTypeId);
|
||||
return;
|
||||
@@ -895,14 +902,14 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
|
||||
{
|
||||
GroupQueueInfo* front1 = NULL;
|
||||
GroupQueueInfo* front2 = NULL;
|
||||
if (!m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].empty())
|
||||
if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].empty())
|
||||
{
|
||||
front1 = m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].front();
|
||||
front1 = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].front();
|
||||
arenaRating = front1->ArenaTeamRating;
|
||||
}
|
||||
if (!m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].empty())
|
||||
if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty())
|
||||
{
|
||||
front2 = m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].front();
|
||||
front2 = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].front();
|
||||
arenaRating = front2->ArenaTeamRating;
|
||||
}
|
||||
if (front1 && front2)
|
||||
@@ -932,8 +939,8 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
|
||||
for (uint32 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++)
|
||||
{
|
||||
// take the group that joined first
|
||||
itr_team[i] = m_QueuedGroups[queue_id][i].begin();
|
||||
for (; itr_team[i] != m_QueuedGroups[queue_id][i].end(); ++(itr_team[i]))
|
||||
itr_team[i] = m_QueuedGroups[bracket_id][i].begin();
|
||||
for(; itr_team[i] != m_QueuedGroups[bracket_id][i].end(); ++(itr_team[i]))
|
||||
{
|
||||
// if group match conditions, then add it to pool
|
||||
if( !(*itr_team[i])->IsInvitedToBGInstanceGUID
|
||||
@@ -954,7 +961,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
|
||||
{
|
||||
itr_team[BG_TEAM_ALLIANCE] = itr_team[BG_TEAM_HORDE];
|
||||
++itr_team[BG_TEAM_ALLIANCE];
|
||||
for (; itr_team[BG_TEAM_ALLIANCE] != m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].end(); ++(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]))
|
||||
{
|
||||
if( !(*itr_team[BG_TEAM_ALLIANCE])->IsInvitedToBGInstanceGUID
|
||||
&& (((*itr_team[BG_TEAM_ALLIANCE])->ArenaTeamRating >= arenaMinRating && (*itr_team[BG_TEAM_ALLIANCE])->ArenaTeamRating <= arenaMaxRating)
|
||||
@@ -970,7 +977,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
|
||||
{
|
||||
itr_team[BG_TEAM_HORDE] = itr_team[BG_TEAM_ALLIANCE];
|
||||
++itr_team[BG_TEAM_HORDE];
|
||||
for (; itr_team[BG_TEAM_HORDE] != m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++(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])->ArenaTeamRating >= arenaMinRating && (*itr_team[BG_TEAM_HORDE])->ArenaTeamRating <= arenaMaxRating)
|
||||
@@ -985,8 +992,8 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
|
||||
//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())
|
||||
{
|
||||
BattleGround* arena = NULL;
|
||||
if (!(arena = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, queue_id, arenaType, true)))
|
||||
BattleGround* arena = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, arenaType, true);
|
||||
if (!arena)
|
||||
{
|
||||
sLog.outError("BattlegroundQueue::Update couldn't create arena instance for rated arena match!");
|
||||
return;
|
||||
@@ -1000,16 +1007,16 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
|
||||
if ((*(itr_team[BG_TEAM_ALLIANCE]))->Team != ALLIANCE)
|
||||
{
|
||||
// add to alliance queue
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(*(itr_team[BG_TEAM_ALLIANCE]));
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(*(itr_team[BG_TEAM_ALLIANCE]));
|
||||
// erase from horde queue
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].erase(itr_team[BG_TEAM_ALLIANCE]);
|
||||
itr_team[BG_TEAM_ALLIANCE] = m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].begin();
|
||||
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();
|
||||
}
|
||||
if ((*(itr_team[BG_TEAM_HORDE]))->Team != HORDE)
|
||||
{
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].push_front(*(itr_team[BG_TEAM_HORDE]));
|
||||
m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_team[BG_TEAM_HORDE]);
|
||||
itr_team[BG_TEAM_HORDE] = m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].begin();
|
||||
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();
|
||||
}
|
||||
|
||||
InviteGroupToBG(*(itr_team[BG_TEAM_ALLIANCE]), arena, ALLIANCE);
|
||||
@@ -1040,17 +1047,15 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
|
||||
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType());
|
||||
uint32 queueSlot = plr->GetBattleGroundQueueIndex(bgQueueTypeId);
|
||||
if( queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES ) // player is in queue or in battleground
|
||||
if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue or in battleground
|
||||
{
|
||||
// check if player is invited to this bg
|
||||
BattleGroundQueue::QueuedPlayersMap const& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
||||
BattleGroundQueue::QueuedPlayersMap::const_iterator qItr = qpMap.find(m_PlayerGuid);
|
||||
if( qItr != qpMap.end() && qItr->second.GroupInfo->IsInvitedToBGInstanceGUID == m_BgInstanceGUID
|
||||
&& qItr->second.GroupInfo->RemoveInviteTime == m_RemoveTime )
|
||||
BattleGroundQueue &bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
|
||||
if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime))
|
||||
{
|
||||
WorldPacket data;
|
||||
//we must send remaining time in queue
|
||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME - INVITATION_REMIND_TIME, 0, qItr->second.GroupInfo->ArenaType);
|
||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME - INVITATION_REMIND_TIME, 0, m_ArenaType);
|
||||
plr->GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
@@ -1083,22 +1088,19 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
//bg pointer can be NULL! so use it carefully!
|
||||
|
||||
uint32 queueSlot = plr->GetBattleGroundQueueIndex(m_BgQueueTypeId);
|
||||
if( queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES ) // player is in queue, or in Battleground
|
||||
if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue, or in Battleground
|
||||
{
|
||||
// check if player is in queue for this BG and if we are removing his invite event
|
||||
BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[m_BgQueueTypeId].m_QueuedPlayers;
|
||||
BattleGroundQueue::QueuedPlayersMap::iterator qMapItr = qpMap.find(m_PlayerGuid);
|
||||
if( qMapItr != qpMap.end() && qMapItr->second.GroupInfo
|
||||
&& qMapItr->second.GroupInfo->IsInvitedToBGInstanceGUID == m_BgInstanceGUID
|
||||
&& qMapItr->second.GroupInfo->RemoveInviteTime == m_RemoveTime )
|
||||
BattleGroundQueue &bgQueue = sBattleGroundMgr.m_BattleGroundQueues[m_BgQueueTypeId];
|
||||
if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime))
|
||||
{
|
||||
sLog.outDebug("Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.",plr->GetGUIDLow(),m_BgInstanceGUID);
|
||||
|
||||
plr->RemoveBattleGroundQueueId(m_BgQueueTypeId);
|
||||
sBattleGroundMgr.m_BattleGroundQueues[m_BgQueueTypeId].RemovePlayer(m_PlayerGuid, true);
|
||||
bgQueue.RemovePlayer(m_PlayerGuid, true);
|
||||
//update queues if battleground isn't ended
|
||||
if (bg)
|
||||
sBattleGroundMgr.ScheduleQueueUpdate(m_BgQueueTypeId, m_BgTypeId, bg->GetQueueId());
|
||||
if (bg && bg->isBattleGround() && bg->GetStatus() != STATUS_WAIT_LEAVE)
|
||||
sBattleGroundMgr.ScheduleQueueUpdate(0, 0, m_BgQueueTypeId, m_BgTypeId, bg->GetBracketId());
|
||||
|
||||
WorldPacket data;
|
||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0);
|
||||
@@ -1140,8 +1142,8 @@ void BattleGroundMgr::DeleteAllBattleGrounds()
|
||||
{
|
||||
BattleGround * bg = itr->second;
|
||||
m_BattleGrounds[i].erase(itr++);
|
||||
if (!m_ClientBattleGroundIds[i][bg->GetQueueId()].empty())
|
||||
m_ClientBattleGroundIds[i][bg->GetQueueId()].erase(bg->GetClientInstanceID());
|
||||
if (!m_ClientBattleGroundIds[i][bg->GetBracketId()].empty())
|
||||
m_ClientBattleGroundIds[i][bg->GetBracketId()].erase(bg->GetClientInstanceID());
|
||||
delete bg;
|
||||
}
|
||||
}
|
||||
@@ -1176,8 +1178,8 @@ void BattleGroundMgr::Update(uint32 diff)
|
||||
{
|
||||
BattleGround * bg = itr->second;
|
||||
m_BattleGrounds[i].erase(itr);
|
||||
if (!m_ClientBattleGroundIds[i][bg->GetQueueId()].empty())
|
||||
m_ClientBattleGroundIds[i][bg->GetQueueId()].erase(bg->GetClientInstanceID());
|
||||
if (!m_ClientBattleGroundIds[i][bg->GetBracketId()].empty())
|
||||
m_ClientBattleGroundIds[i][bg->GetBracketId()].erase(bg->GetClientInstanceID());
|
||||
delete bg;
|
||||
}
|
||||
}
|
||||
@@ -1186,18 +1188,22 @@ void BattleGroundMgr::Update(uint32 diff)
|
||||
// update scheduled queues
|
||||
if (!m_QueueUpdateScheduler.empty())
|
||||
{
|
||||
//copy vector and clear the other
|
||||
// TODO add lock
|
||||
// TODO maybe std::list would be better and then unlock after end of cycle
|
||||
std::vector<uint32> scheduled(m_QueueUpdateScheduler);
|
||||
m_QueueUpdateScheduler.clear();
|
||||
// TODO drop lock
|
||||
std::vector<uint64> scheduled;
|
||||
{
|
||||
//copy vector and clear the other
|
||||
scheduled = std::vector<uint64>(m_QueueUpdateScheduler);
|
||||
m_QueueUpdateScheduler.clear();
|
||||
//release lock
|
||||
}
|
||||
|
||||
for (uint8 i = 0; i < scheduled.size(); i++)
|
||||
{
|
||||
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundQueueTypeId(scheduled[i] >> 16);
|
||||
uint32 arenaRating = scheduled[i] >> 32;
|
||||
uint8 arenaType = scheduled[i] >> 24 & 255;
|
||||
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundQueueTypeId(scheduled[i] >> 16 & 255);
|
||||
BattleGroundTypeId bgTypeId = BattleGroundTypeId((scheduled[i] >> 8) & 255);
|
||||
BGQueueIdBasedOnLevel queue_id = BGQueueIdBasedOnLevel(scheduled[i] & 255);
|
||||
m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, queue_id);
|
||||
BattleGroundBracketId bracket_id = BattleGroundBracketId(scheduled[i] & 255);
|
||||
m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, bracket_id, arenaType, arenaRating > 0, arenaRating);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1207,14 +1213,14 @@ void BattleGroundMgr::Update(uint32 diff)
|
||||
// it's time to force update
|
||||
if (m_NextRatingDiscardUpdate < diff)
|
||||
{
|
||||
// forced update for level 70 rated arenas
|
||||
// forced update for rated arenas (scan all, but skipped non rated)
|
||||
sLog.outDebug("BattleGroundMgr: UPDATING ARENA QUEUES");
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_2v2].Update(BATTLEGROUND_AA, QUEUE_ID_MAX_LEVEL_79, ARENA_TYPE_2v2, true, 0);
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_2v2].Update(BATTLEGROUND_AA, QUEUE_ID_MAX_LEVEL_80, ARENA_TYPE_2v2, true, 0);
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_3v3].Update(BATTLEGROUND_AA, QUEUE_ID_MAX_LEVEL_79, ARENA_TYPE_3v3, true, 0);
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_3v3].Update(BATTLEGROUND_AA, QUEUE_ID_MAX_LEVEL_80, ARENA_TYPE_3v3, true, 0);
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_5v5].Update(BATTLEGROUND_AA, QUEUE_ID_MAX_LEVEL_79, ARENA_TYPE_5v5, true, 0);
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_5v5].Update(BATTLEGROUND_AA, QUEUE_ID_MAX_LEVEL_80, ARENA_TYPE_5v5, true, 0);
|
||||
for(int qtype = BATTLEGROUND_QUEUE_2v2; qtype <= BATTLEGROUND_QUEUE_5v5; ++qtype)
|
||||
for(int bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
|
||||
m_BattleGroundQueues[qtype].Update(
|
||||
BATTLEGROUND_AA, BattleGroundBracketId(bracket),
|
||||
BattleGroundMgr::BGArenaType(BattleGroundQueueTypeId(qtype)), true, 0);
|
||||
|
||||
m_NextRatingDiscardUpdate = sWorld.getConfig(CONFIG_ARENA_RATING_DISCARD_TIMER);
|
||||
}
|
||||
else
|
||||
@@ -1484,7 +1490,7 @@ BattleGround * BattleGroundMgr::GetBattleGroundTemplate(BattleGroundTypeId bgTyp
|
||||
return m_BattleGrounds[bgTypeId].empty() ? NULL : m_BattleGrounds[bgTypeId].begin()->second;
|
||||
}
|
||||
|
||||
uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id)
|
||||
uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id)
|
||||
{
|
||||
if (IsArenaType(bgTypeId))
|
||||
return 0; //arenas don't have client-instanceids
|
||||
@@ -1496,18 +1502,18 @@ uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeI
|
||||
// the following works, because std::set is default ordered with "<"
|
||||
// the optimalization would be to use as bitmask std::vector<uint32> - but that would only make code unreadable
|
||||
uint32 lastId = 0;
|
||||
for (std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][queue_id].begin(); itr != m_ClientBattleGroundIds[bgTypeId][queue_id].end();)
|
||||
for(std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][bracket_id].begin(); itr != m_ClientBattleGroundIds[bgTypeId][bracket_id].end();)
|
||||
{
|
||||
if( (++lastId) != *itr) //if there is a gap between the ids, we will break..
|
||||
break;
|
||||
lastId = *itr;
|
||||
}
|
||||
m_ClientBattleGroundIds[bgTypeId][queue_id].insert(lastId + 1);
|
||||
m_ClientBattleGroundIds[bgTypeId][bracket_id].insert(lastId + 1);
|
||||
return lastId + 1;
|
||||
}
|
||||
|
||||
// create a new battleground that will really be used to play
|
||||
BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id, uint8 arenaType, bool isRated)
|
||||
BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated)
|
||||
{
|
||||
// get the template BG
|
||||
BattleGround *bg_template = GetBattleGroundTemplate(bgTypeId);
|
||||
@@ -1589,14 +1595,14 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
|
||||
|
||||
// generate a new instance id
|
||||
bg->SetInstanceID(MapManager::Instance().GenerateInstanceId()); // set instance id
|
||||
bg->SetClientInstanceID(CreateClientVisibleInstanceId(bgTypeId, queue_id));
|
||||
bg->SetClientInstanceID(CreateClientVisibleInstanceId(bgTypeId, bracketEntry->GetBracketId()));
|
||||
|
||||
// reset the new bg (set status to status_wait_queue from status_none)
|
||||
bg->Reset();
|
||||
|
||||
// start the joining of the bg
|
||||
bg->SetStatus(STATUS_WAIT_JOIN);
|
||||
bg->SetQueueId(queue_id);
|
||||
bg->SetBracket(bracketEntry);
|
||||
bg->SetArenaType(arenaType);
|
||||
bg->SetRated(isRated);
|
||||
|
||||
@@ -1843,9 +1849,6 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint6
|
||||
if (!plr)
|
||||
return;
|
||||
|
||||
uint32 PlayerLevel = 10;
|
||||
PlayerLevel = plr->getLevel();
|
||||
|
||||
data->Initialize(SMSG_BATTLEFIELD_LIST);
|
||||
*data << uint64(guid); // battlemaster guid
|
||||
*data << uint8(fromWhere); // from where you joined
|
||||
@@ -1865,13 +1868,20 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint6
|
||||
uint32 count = 0;
|
||||
*data << uint32(0); // number of bg instances
|
||||
|
||||
uint32 queue_id = plr->GetBattleGroundQueueIdFromLevel(bgTypeId);
|
||||
for (std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][queue_id].begin(); itr != m_ClientBattleGroundIds[bgTypeId][queue_id].end(); ++itr)
|
||||
if(BattleGround* bgTemplate = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId))
|
||||
{
|
||||
*data << uint32(*itr);
|
||||
++count;
|
||||
// expected bracket entry
|
||||
if(PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(),plr->getLevel()))
|
||||
{
|
||||
BattleGroundBracketId bracketId = bracketEntry->GetBracketId();
|
||||
for(std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][bracketId].begin(); itr != m_ClientBattleGroundIds[bgTypeId][bracketId].end();++itr)
|
||||
{
|
||||
*data << uint32(*itr);
|
||||
++count;
|
||||
}
|
||||
data->put<uint32>( count_pos , count);
|
||||
}
|
||||
}
|
||||
data->put<uint32>( count_pos , count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2026,11 +2036,11 @@ void BattleGroundMgr::SetHolidayWeekends(uint32 mask)
|
||||
}
|
||||
}
|
||||
|
||||
void BattleGroundMgr::ScheduleQueueUpdate(BattleGroundQueueTypeId bgQueueTypeId, BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id)
|
||||
void BattleGroundMgr::ScheduleQueueUpdate(uint32 arenaRating, uint8 arenaType, BattleGroundQueueTypeId bgQueueTypeId, BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id)
|
||||
{
|
||||
//This method must be atomic, TODO add mutex
|
||||
//we will use only 1 number created of bgTypeId and queue_id
|
||||
uint32 schedule_id = (bgQueueTypeId << 16) | (bgTypeId << 8) | queue_id;
|
||||
//we will use only 1 number created of bgTypeId and bracket_id
|
||||
uint64 schedule_id = ((uint64)arenaRating << 32) | (arenaType << 24) | (bgQueueTypeId << 16) | (bgTypeId << 8) | bracket_id;
|
||||
bool found = false;
|
||||
for (uint8 i = 0; i < m_QueueUpdateScheduler.size(); i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user