mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 10:37:01 +00:00
Use PVPDificulty.dbc for bg/arena bracket selection (levels and difficulty)
This commit is contained in:
parent
75c81894b2
commit
63709fdc49
15 changed files with 167 additions and 98 deletions
|
|
@ -148,8 +148,10 @@ 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, BattleGroundBracketId bracket_id, uint8 ArenaType, bool isRated, bool isPremade, uint32 arenaRating, uint32 arenateamid)
|
||||
GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleGroundTypeId BgTypeId, PvPDifficultyEntry const* backetEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 arenaRating, uint32 arenateamid)
|
||||
{
|
||||
BattleGroundBracketId bracketId = backetEntry->GetBracketId();
|
||||
|
||||
// create new ginfo
|
||||
GroupQueueInfo* ginfo = new GroupQueueInfo;
|
||||
ginfo->BgTypeId = BgTypeId;
|
||||
|
|
@ -171,7 +173,7 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG
|
|||
index += BG_TEAMS_COUNT;
|
||||
if (ginfo->Team == HORDE)
|
||||
index++;
|
||||
sLog.outDebug("Adding Group to BattleGroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracket_id, index);
|
||||
sLog.outDebug("Adding Group to BattleGroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
|
||||
|
||||
uint32 lastOnlineTime = getMSTime();
|
||||
|
||||
|
|
@ -207,37 +209,37 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG
|
|||
}
|
||||
|
||||
//add GroupInfo to m_QueuedGroups
|
||||
m_QueuedGroups[bracket_id][index].push_back(ginfo);
|
||||
m_QueuedGroups[bracketId][index].push_back(ginfo);
|
||||
|
||||
//announce to world, this code needs mutex
|
||||
if (!isRated && !isPremade && sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
|
||||
{
|
||||
BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(ginfo->BgTypeId);
|
||||
if (bg)
|
||||
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 = (bracket_id + 1) * 10;
|
||||
uint32 q_min_level = backetEntry->minLevel;
|
||||
uint32 q_max_level = backetEntry->maxLevel;
|
||||
GroupsQueueType::const_iterator itr;
|
||||
for(itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].end(); ++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[bracket_id][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
|
||||
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_min_level + 10,
|
||||
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_min_level + 10,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -800,6 +802,14 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
|
|||
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();
|
||||
|
|
@ -844,7 +854,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
|
|||
if (CheckPremadeMatch(bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam))
|
||||
{
|
||||
//create new battleground
|
||||
BattleGround * bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracket_id, 0, false);
|
||||
BattleGround * bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, 0, false);
|
||||
if (!bg2)
|
||||
{
|
||||
sLog.outError("BattleGroundQueue::Update - Cannot create battleground: %u", bgTypeId);
|
||||
|
|
@ -870,7 +880,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
|
|||
|| (bg_template->isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam)) )
|
||||
{
|
||||
// we successfully created a pool
|
||||
BattleGround * bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracket_id, arenaType, false);
|
||||
BattleGround * bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, arenaType, false);
|
||||
if (!bg2)
|
||||
{
|
||||
sLog.outError("BattleGroundQueue::Update - Cannot create battleground: %u", bgTypeId);
|
||||
|
|
@ -984,8 +994,8 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
|
|||
//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, bracket_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;
|
||||
|
|
@ -1207,14 +1217,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, BG_BRACKET_ID_MAX_LEVEL_79, ARENA_TYPE_2v2, true, 0);
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_2v2].Update(BATTLEGROUND_AA, BG_BRACKET_ID_MAX_LEVEL_80, ARENA_TYPE_2v2, true, 0);
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_3v3].Update(BATTLEGROUND_AA, BG_BRACKET_ID_MAX_LEVEL_79, ARENA_TYPE_3v3, true, 0);
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_3v3].Update(BATTLEGROUND_AA, BG_BRACKET_ID_MAX_LEVEL_80, ARENA_TYPE_3v3, true, 0);
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_5v5].Update(BATTLEGROUND_AA, BG_BRACKET_ID_MAX_LEVEL_79, ARENA_TYPE_5v5, true, 0);
|
||||
m_BattleGroundQueues[BATTLEGROUND_QUEUE_5v5].Update(BATTLEGROUND_AA, BG_BRACKET_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
|
||||
|
|
@ -1494,7 +1504,7 @@ uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeI
|
|||
}
|
||||
|
||||
// create a new battleground that will really be used to play
|
||||
BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_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);
|
||||
|
|
@ -1568,14 +1578,14 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
|
|||
|
||||
// generate a new instance id
|
||||
bg->SetInstanceID(sMapMgr.GenerateInstanceId()); // set instance id
|
||||
bg->SetClientInstanceID(CreateClientVisibleInstanceId(bgTypeId, bracket_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->SetBracketId(bracket_id);
|
||||
bg->SetBracket(bracketEntry);
|
||||
bg->SetArenaType(arenaType);
|
||||
bg->SetRated(isRated);
|
||||
|
||||
|
|
@ -1841,13 +1851,20 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint6
|
|||
uint32 count = 0;
|
||||
*data << uint32(0); // number of bg instances
|
||||
|
||||
uint32 bracket_id = plr->GetBattleGroundBracketIdFromLevel();
|
||||
for(std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][bracket_id].begin(); itr != m_ClientBattleGroundIds[bgTypeId][bracket_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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue