AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
BattlegroundMgr Class Reference

#include "BattlegroundMgr.h"

Public Member Functions

void Update (uint32 diff)
 
void BuildPlayerJoinedBattlegroundPacket (WorldPacket *data, Player *player)
 
void BuildPlayerLeftBattlegroundPacket (WorldPacket *data, ObjectGuid guid)
 
void BuildBattlegroundListPacket (WorldPacket *data, ObjectGuid guid, Player *player, BattlegroundTypeId bgTypeId, uint8 fromWhere)
 
void BuildGroupJoinedBattlegroundPacket (WorldPacket *data, GroupJoinBattlegroundResult result)
 
void BuildBattlegroundStatusPacket (WorldPacket *data, Battleground *bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated=false, BattlegroundTypeId forceBgTypeId=BATTLEGROUND_TYPE_NONE)
 
void SendAreaSpiritHealerQueryOpcode (Player *player, Battleground *bg, ObjectGuid guid)
 
BattlegroundGetBattlegroundThroughClientInstance (uint32 instanceId, BattlegroundTypeId bgTypeId)
 
BattlegroundGetBattleground (uint32 instanceID, BattlegroundTypeId bgTypeId)
 
BattlegroundGetBattlegroundTemplate (BattlegroundTypeId bgTypeId)
 
BattlegroundCreateNewBattleground (BattlegroundTypeId bgTypeId, PvPDifficultyEntry const *bracketEntry, uint8 arenaType, bool isRated)
 
std::vector< Battleground const * > GetActiveBattlegrounds ()
 
void AddBattleground (Battleground *bg)
 
void RemoveBattleground (BattlegroundTypeId bgTypeId, uint32 instanceId)
 
void AddToBGFreeSlotQueue (BattlegroundTypeId bgTypeId, Battleground *bg)
 
void RemoveFromBGFreeSlotQueue (BattlegroundTypeId bgTypeId, uint32 instanceId)
 
BGFreeSlotQueueContainerGetBGFreeSlotQueueStore (BattlegroundTypeId bgTypeId)
 
void LoadBattlegroundTemplates ()
 
void DeleteAllBattlegrounds ()
 
bool SendToBattleground (Player *player, uint32 InstanceID, BattlegroundTypeId bgTypeId)
 
BattlegroundQueueGetBattlegroundQueue (BattlegroundQueueTypeId bgQueueTypeId)
 
void ScheduleQueueUpdate (uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
 
uint32 GetPrematureFinishTime () const
 
void ToggleArenaTesting ()
 
void ToggleTesting ()
 
void SetHolidayWeekends (uint32 mask)
 
bool isArenaTesting () const
 
bool isTesting () const
 
uint32 GetMaxRatingDifference () const
 
uint32 GetRatingDiscardTimer () const
 
void InitAutomaticArenaPointDistribution ()
 
void LoadBattleMastersEntry ()
 
void CheckBattleMasters ()
 
BattlegroundTypeId GetBattleMasterBG (uint32 entry) const
 

Static Public Member Functions

static BattlegroundMgrinstance ()
 
static BattlegroundQueueTypeId BGQueueTypeId (BattlegroundTypeId bgTypeId, uint8 arenaType)
 
static BattlegroundTypeId BGTemplateId (BattlegroundQueueTypeId bgQueueTypeId)
 
static bool IsArenaType (BattlegroundTypeId bgTypeId)
 
static uint8 BGArenaType (BattlegroundQueueTypeId bgQueueTypeId)
 
static HolidayIds BGTypeToWeekendHolidayId (BattlegroundTypeId bgTypeId)
 
static BattlegroundTypeId WeekendHolidayIdToBGType (HolidayIds holiday)
 
static bool IsBGWeekend (BattlegroundTypeId bgTypeId)
 

Static Public Attributes

static std::unordered_map< int, BattlegroundQueueTypeIdbgToQueue
 
static std::unordered_map< int, BattlegroundTypeIdqueueToBg
 
static std::unordered_map< int, Battleground * > bgtypeToBattleground
 
static std::unordered_map< int, bgRefbgTypeToTemplate
 
static std::unordered_map< int, bgMapRefgetBgFromMap = {}
 
static std::unordered_map< int, bgTypeRefgetBgFromTypeID
 
static std::unordered_map< uint32, BattlegroundQueueTypeIdArenaTypeToQueue
 
static std::unordered_map< uint32, ArenaTypeQueueToArenaType
 

Private Types

typedef std::map< BattlegroundTypeId, BattlegroundDataBattlegroundDataContainer
 
typedef std::map< BattlegroundTypeId, uint8BattlegroundSelectionWeightMap
 
typedef std::map< BattlegroundTypeId, BattlegroundTemplateBattlegroundTemplateMap
 
typedef std::map< uint32, BattlegroundTemplate * > BattlegroundMapTemplateContainer
 

Private Member Functions

 BattlegroundMgr ()
 
 ~BattlegroundMgr ()
 
bool CreateBattleground (BattlegroundTemplate const *bgTemplate)
 
uint32 CreateClientVisibleInstanceId (BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
 
BattlegroundTypeId GetRandomBG (BattlegroundTypeId id, uint32 minLevel)
 
BattlegroundTemplate const * GetBattlegroundTemplateByTypeId (BattlegroundTypeId id)
 
BattlegroundTemplate const * GetBattlegroundTemplateByMapId (uint32 mapId)
 

Private Attributes

BattlegroundDataContainer bgDataStore
 
BattlegroundQueue m_BattlegroundQueues [MAX_BATTLEGROUND_QUEUE_TYPES]
 
std::vector< uint64m_QueueUpdateScheduler
 
bool m_ArenaTesting
 
bool m_Testing
 
Seconds m_NextAutoDistributionTime
 
uint32 m_AutoDistributionTimeChecker
 
uint32 m_NextPeriodicQueueUpdateTime
 
BattleMastersMap mBattleMastersMap
 
BattlegroundTemplateMap _battlegroundTemplates
 
BattlegroundMapTemplateContainer _battlegroundMapTemplates
 

Detailed Description

Member Typedef Documentation

◆ BattlegroundDataContainer

◆ BattlegroundMapTemplateContainer

◆ BattlegroundSelectionWeightMap

◆ BattlegroundTemplateMap

Constructor & Destructor Documentation

◆ BattlegroundMgr()

BattlegroundMgr::BattlegroundMgr ( )
private
63 :
69{
70}
constexpr auto IN_MILLISECONDS
Definition Common.h:53
@ CONFIG_DEBUG_ARENA
Definition WorldConfig.h:123
@ CONFIG_DEBUG_BATTLEGROUND
Definition WorldConfig.h:122
bool m_ArenaTesting
Definition BattlegroundMgr.h:157
uint32 m_AutoDistributionTimeChecker
Definition BattlegroundMgr.h:160
Seconds m_NextAutoDistributionTime
Definition BattlegroundMgr.h:159
uint32 m_NextPeriodicQueueUpdateTime
Definition BattlegroundMgr.h:161
bool m_Testing
Definition BattlegroundMgr.h:158
#define sWorld
Definition World.h:318

◆ ~BattlegroundMgr()

BattlegroundMgr::~BattlegroundMgr ( )
private
73{
75}
void DeleteAllBattlegrounds()
Definition BattlegroundMgr.cpp:83

References DeleteAllBattlegrounds().

Member Function Documentation

◆ AddBattleground()

void BattlegroundMgr::AddBattleground ( Battleground bg)
966{
967 if (bg)
968 bgDataStore[bg->GetBgTypeID()]._Battlegrounds[bg->GetInstanceID()] = bg;
969
970 sScriptMgr->OnBattlegroundCreate(bg);
971}
#define sScriptMgr
Definition ScriptMgr.h:743
BattlegroundDataContainer bgDataStore
Definition BattlegroundMgr.h:152
uint32 GetInstanceID() const
Definition Battleground.h:331
BattlegroundTypeId GetBgTypeID(bool GetRandom=false) const
Definition Battleground.h:329

References bgDataStore, Battleground::GetBgTypeID(), Battleground::GetInstanceID(), and sScriptMgr.

Referenced by CreateBattleground().

◆ AddToBGFreeSlotQueue()

void BattlegroundMgr::AddToBGFreeSlotQueue ( BattlegroundTypeId  bgTypeId,
Battleground bg 
)
950{
951 bgDataStore[bgTypeId].BGFreeSlotQueue.push_back(bg);
952}

References bgDataStore.

◆ BGArenaType()

uint8 BattlegroundMgr::BGArenaType ( BattlegroundQueueTypeId  bgQueueTypeId)
static
720{
721 uint8 arenaType = 0;
722
724 {
725 arenaType = BattlegroundMgr::QueueToArenaType.at(bgQueueTypeId);
726 }
727
728 sScriptMgr->OnArenaQueueIdToArenaType(bgQueueTypeId, arenaType);
729
730 return arenaType;
731}
std::uint8_t uint8
Definition Define.h:109
static std::unordered_map< uint32, ArenaType > QueueToArenaType
Definition BattlegroundMgr.h:1075

References QueueToArenaType, and sScriptMgr.

Referenced by Update().

◆ BGQueueTypeId()

BattlegroundQueueTypeId BattlegroundMgr::BGQueueTypeId ( BattlegroundTypeId  bgTypeId,
uint8  arenaType 
)
static
686{
687 uint32 queueTypeID = BATTLEGROUND_QUEUE_NONE;
688
689 if (arenaType)
690 {
692 {
693 queueTypeID = BattlegroundMgr::ArenaTypeToQueue.at(arenaType);
694 }
695
696 sScriptMgr->OnArenaTypeIDToQueueID(bgTypeId, arenaType, queueTypeID);
697
698 return static_cast<BattlegroundQueueTypeId>(queueTypeID);
699 }
700
701 if (BattlegroundMgr::bgToQueue.find(bgTypeId) != BattlegroundMgr::bgToQueue.end())
702 {
703 queueTypeID = BattlegroundMgr::bgToQueue.at(bgTypeId);
704 }
705
706 return static_cast<BattlegroundQueueTypeId>(queueTypeID);
707}
std::uint32_t uint32
Definition Define.h:107
BattlegroundQueueTypeId
Definition SharedDefines.h:3875
@ BATTLEGROUND_QUEUE_NONE
Definition SharedDefines.h:3876
static std::unordered_map< int, BattlegroundQueueTypeId > bgToQueue
Definition BattlegroundMgr.h:980
static std::unordered_map< uint32, BattlegroundQueueTypeId > ArenaTypeToQueue
Definition BattlegroundMgr.h:1068

References ArenaTypeToQueue, BATTLEGROUND_QUEUE_NONE, bgToQueue, and sScriptMgr.

Referenced by Group::CanJoinBattlegroundQueue(), ArenaTeam::DelMember(), BGQueueInviteEvent::Execute(), WorldSession::HandleArenaTeamDisbandOpcode(), WorldSession::HandleArenaTeamLeaveOpcode(), WorldSession::HandleArenaTeamRemoveOpcode(), WorldSession::HandleBattleFieldPortOpcode(), WorldSession::HandleBattlemasterJoinArena(), WorldSession::HandleBattlemasterJoinOpcode(), WorldSession::HandleMoveWorldportAck(), BattlegroundQueue::InviteGroupToBG(), BattlegroundQueue::RemovePlayer(), and Battleground::RemovePlayerAtLeave().

◆ BGTemplateId()

BattlegroundTypeId BattlegroundMgr::BGTemplateId ( BattlegroundQueueTypeId  bgQueueTypeId)
static
710{
711 if (BattlegroundMgr::queueToBg.find(bgQueueTypeId) == BattlegroundMgr::queueToBg.end())
712 {
713 return BattlegroundTypeId(0);
714 }
715
716 return BattlegroundMgr::queueToBg[bgQueueTypeId];
717}
BattlegroundTypeId
Definition SharedDefines.h:3735
static std::unordered_map< int, BattlegroundTypeId > queueToBg
Definition BattlegroundMgr.h:998

References queueToBg.

Referenced by BattlegroundQueue::BattlegroundQueueAnnouncerUpdate(), and WorldSession::HandleBattlefieldStatusOpcode().

◆ BGTypeToWeekendHolidayId()

HolidayIds BattlegroundMgr::BGTypeToWeekendHolidayId ( BattlegroundTypeId  bgTypeId)
static
868{
869 switch (bgTypeId)
870 {
871 case BATTLEGROUND_AV:
873 case BATTLEGROUND_EY:
875 case BATTLEGROUND_WS:
877 case BATTLEGROUND_SA:
879 case BATTLEGROUND_AB:
881 case BATTLEGROUND_IC:
883 default:
884 return HOLIDAY_NONE;
885 }
886}
@ BATTLEGROUND_IC
Definition SharedDefines.h:3748
@ BATTLEGROUND_WS
Definition SharedDefines.h:3738
@ BATTLEGROUND_EY
Definition SharedDefines.h:3743
@ BATTLEGROUND_AV
Definition SharedDefines.h:3737
@ BATTLEGROUND_SA
Definition SharedDefines.h:3745
@ BATTLEGROUND_AB
Definition SharedDefines.h:3739
@ HOLIDAY_NONE
Definition SharedDefines.h:2975
@ HOLIDAY_CALL_TO_ARMS_AB
Definition SharedDefines.h:2983
@ HOLIDAY_CALL_TO_ARMS_EY
Definition SharedDefines.h:2990
@ HOLIDAY_CALL_TO_ARMS_SA
Definition SharedDefines.h:2996
@ HOLIDAY_CALL_TO_ARMS_IC
Definition SharedDefines.h:3000
@ HOLIDAY_CALL_TO_ARMS_AV
Definition SharedDefines.h:2981
@ HOLIDAY_CALL_TO_ARMS_WS
Definition SharedDefines.h:2982

References BATTLEGROUND_AB, BATTLEGROUND_AV, BATTLEGROUND_EY, BATTLEGROUND_IC, BATTLEGROUND_SA, BATTLEGROUND_WS, HOLIDAY_CALL_TO_ARMS_AB, HOLIDAY_CALL_TO_ARMS_AV, HOLIDAY_CALL_TO_ARMS_EY, HOLIDAY_CALL_TO_ARMS_IC, HOLIDAY_CALL_TO_ARMS_SA, HOLIDAY_CALL_TO_ARMS_WS, and HOLIDAY_NONE.

Referenced by IsBGWeekend().

◆ BuildBattlegroundListPacket()

void BattlegroundMgr::BuildBattlegroundListPacket ( WorldPacket data,
ObjectGuid  guid,
Player player,
BattlegroundTypeId  bgTypeId,
uint8  fromWhere 
)
585{
586 if (!player)
587 return;
588
589 uint32 winner_kills = player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_HONOR_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_HONOR_FIRST);
590 uint32 winner_arena = player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_ARENA_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_ARENA_FIRST);
591 uint32 loser_kills = player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_FIRST);
592
593 winner_kills = Acore::Honor::hk_honor_at_level(player->GetLevel(), float(winner_kills));
594 loser_kills = Acore::Honor::hk_honor_at_level(player->GetLevel(), float(loser_kills));
595
597 *data << guid; // battlemaster guid
598 *data << uint8(fromWhere); // from where you joined
599 *data << uint32(bgTypeId); // battleground id
600 *data << uint8(0); // unk
601 *data << uint8(0); // unk
602
603 // Rewards
604 *data << uint8(player->GetRandomWinner()); // 3.3.3 hasWin
605 *data << uint32(winner_kills); // 3.3.3 winHonor
606 *data << uint32(winner_arena); // 3.3.3 winArena
607 *data << uint32(loser_kills); // 3.3.3 lossHonor
608
609 uint8 isQueueRandom = (bgTypeId == BATTLEGROUND_RB);
610
611 *data << uint8(isQueueRandom); // 3.3.3 isRandom
612 if (isQueueRandom)
613 {
614 // Rewards (random)
615 *data << uint8(player->GetRandomWinner()); // 3.3.3 hasWin_Random
616 *data << uint32(winner_kills); // 3.3.3 winHonor_Random
617 *data << uint32(winner_arena); // 3.3.3 winArena_Random
618 *data << uint32(loser_kills); // 3.3.3 lossHonor_Random
619 }
620
621 if (bgTypeId == BATTLEGROUND_AA) // arena
622 *data << uint32(0); // unk (count?)
623 else // battleground
624 {
625 std::size_t count_pos = data->wpos();
626 *data << uint32(0); // number of bg instances
627
628 auto const& it = bgDataStore.find(bgTypeId);
629 if (it != bgDataStore.end())
630 {
631 // expected bracket entry
632 if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(it->second._Battlegrounds.begin()->second->GetMapId(), player->GetLevel()))
633 {
634 uint32 count = 0;
635 BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
636 BattlegroundClientIdsContainer& clientIds = it->second._ClientBattlegroundIds[bracketId];
637
638 for (auto const& itr : clientIds)
639 {
640 *data << uint32(itr);
641 ++count;
642 }
643
644 data->put<uint32>(count_pos, count);
645 }
646 }
647 }
648}
std::set< uint32 > BattlegroundClientIdsContainer
Definition BattlegroundMgr.h:28
BattlegroundBracketId
Definition DBCEnums.h:46
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition DBCStores.cpp:793
@ BATTLEGROUND_AA
Definition SharedDefines.h:3742
@ BATTLEGROUND_RB
Definition SharedDefines.h:3749
@ CONFIG_BG_REWARD_LOSER_HONOR_LAST
Definition WorldConfig.h:367
@ CONFIG_BG_REWARD_WINNER_ARENA_FIRST
Definition WorldConfig.h:363
@ CONFIG_BG_REWARD_WINNER_ARENA_LAST
Definition WorldConfig.h:365
@ CONFIG_BG_REWARD_WINNER_HONOR_FIRST
Definition WorldConfig.h:362
@ CONFIG_BG_REWARD_LOSER_HONOR_FIRST
Definition WorldConfig.h:366
@ CONFIG_BG_REWARD_WINNER_HONOR_LAST
Definition WorldConfig.h:364
std::size_t wpos() const
Definition ByteBuffer.h:330
void put(std::size_t pos, T value)
Definition ByteBuffer.h:137
bool GetRandomWinner()
Definition Player.h:2338
uint8 GetLevel() const
Definition Unit.h:1104
void Initialize(uint16 opcode, std::size_t newres=200)
Definition WorldPacket.h:68
@ SMSG_BATTLEFIELD_LIST
Definition Opcodes.h:603
uint32 hk_honor_at_level(uint8 level, float multiplier=1.0f)
Definition Formulas.h:38
Definition DBCStructure.h:1431

References BATTLEGROUND_AA, BATTLEGROUND_RB, bgDataStore, CONFIG_BG_REWARD_LOSER_HONOR_FIRST, CONFIG_BG_REWARD_LOSER_HONOR_LAST, CONFIG_BG_REWARD_WINNER_ARENA_FIRST, CONFIG_BG_REWARD_WINNER_ARENA_LAST, CONFIG_BG_REWARD_WINNER_HONOR_FIRST, CONFIG_BG_REWARD_WINNER_HONOR_LAST, GetBattlegroundBracketByLevel(), Unit::GetLevel(), Player::GetRandomWinner(), Acore::Honor::hk_honor_at_level(), WorldPacket::Initialize(), ByteBuffer::put(), SMSG_BATTLEFIELD_LIST, sWorld, and ByteBuffer::wpos().

◆ BuildBattlegroundStatusPacket()

void BattlegroundMgr::BuildBattlegroundStatusPacket ( WorldPacket data,
Battleground bg,
uint8  queueSlot,
uint8  statusId,
uint32  time1,
uint32  time2,
uint8  arenaType,
TeamId  teamId,
bool  isRated = false,
BattlegroundTypeId  forceBgTypeId = BATTLEGROUND_TYPE_NONE 
)
197{
198 // pussywizard:
199 //ASSERT(QueueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES);
200
201 if (StatusID == STATUS_NONE || !bg)
202 {
204 *data << uint32(QueueSlot);
205 *data << uint64(0);
206 return;
207 }
208
209 data->Initialize(SMSG_BATTLEFIELD_STATUS, (4 + 8 + 1 + 1 + 4 + 1 + 4 + 4 + 4));
210 *data << uint32(QueueSlot);
211 // The following segment is read as uint64 in client but can be appended as their original type.
212 *data << uint8(arenatype);
213 *data << uint8(bg->isArena() ? 0xE : 0x0);
214 *data << uint32(forceBgTypeId != BATTLEGROUND_TYPE_NONE ? forceBgTypeId : bg->GetBgTypeID());
215 *data << uint16(0x1F90);
216 // End of uint64 segment, decomposed this way for simplicity
217 *data << uint8(bg->GetMinLevel());
218 *data << uint8(bg->GetMaxLevel());
219 *data << uint32(bg->GetClientInstanceID());
220
221 // following displays the minimap icon. 0 = faction icon, 1 = arenaicon
222 *data << uint8(bg->isRated() || isRated); // 1 for rated match, 0 for bg or non rated match
223
224 *data << uint32(StatusID); // status
225 switch (StatusID)
226 {
227 case STATUS_WAIT_QUEUE: // status_in_queue
228 *data << uint32(Time1); // average wait time, milliseconds
229 *data << uint32(Time2); // time in queue, updated every minute!, milliseconds
230 break;
231 case STATUS_WAIT_JOIN: // status_invite
232 *data << uint32(bg->GetMapId()); // map id
233 *data << uint64(0); // 3.3.5, unknown
234 *data << uint32(Time1); // time to remove from queue, milliseconds
235 break;
236 case STATUS_IN_PROGRESS: // status_in_progress
237 *data << uint32(bg->GetMapId()); // map id
238 *data << uint64(0); // 3.3.5, unknown
239 *data << uint32(Time1); // time to bg auto leave, 0 at bg start, 120000 after bg end, milliseconds
240 *data << uint32(Time2); // time from bg start, milliseconds
241 *data << uint8(teamId == TEAM_ALLIANCE ? 1 : 0); // arenafaction (0 for horde, 1 for alliance)
242 break;
243 default:
244 break;
245 }
246}
@ STATUS_WAIT_QUEUE
Definition Battleground.h:191
@ STATUS_NONE
Definition Battleground.h:190
@ STATUS_WAIT_JOIN
Definition Battleground.h:192
@ STATUS_IN_PROGRESS
Definition Battleground.h:193
std::uint64_t uint64
Definition Define.h:106
std::uint16_t uint16
Definition Define.h:108
@ BATTLEGROUND_TYPE_NONE
Definition SharedDefines.h:3736
@ TEAM_ALLIANCE
Definition SharedDefines.h:748
uint32 GetMapId() const
Definition Battleground.h:441
uint32 GetMinLevel() const
Definition Battleground.h:338
bool isRated() const
Definition Battleground.h:414
uint32 GetClientInstanceID() const
Definition Battleground.h:333
bool isArena() const
Definition Battleground.h:412
uint32 GetMaxLevel() const
Definition Battleground.h:339
@ SMSG_BATTLEFIELD_STATUS
Definition Opcodes.h:754

References BATTLEGROUND_TYPE_NONE, Battleground::GetBgTypeID(), Battleground::GetClientInstanceID(), Battleground::GetMapId(), Battleground::GetMaxLevel(), Battleground::GetMinLevel(), WorldPacket::Initialize(), Battleground::isArena(), Battleground::isRated(), SMSG_BATTLEFIELD_STATUS, STATUS_IN_PROGRESS, STATUS_NONE, STATUS_WAIT_JOIN, STATUS_WAIT_QUEUE, and TEAM_ALLIANCE.

◆ BuildGroupJoinedBattlegroundPacket()

void BattlegroundMgr::BuildGroupJoinedBattlegroundPacket ( WorldPacket data,
GroupJoinBattlegroundResult  result 
)
249{
251 *data << int32(result);
253 *data << uint64(0); // player guid
254}
std::int32_t int32
Definition Define.h:103
@ ERR_BATTLEGROUND_JOIN_TIMED_OUT
Definition SharedDefines.h:3904
@ ERR_BATTLEGROUND_JOIN_FAILED
Definition SharedDefines.h:3905
@ SMSG_GROUP_JOINED_BATTLEGROUND
Definition Opcodes.h:774

References ERR_BATTLEGROUND_JOIN_FAILED, ERR_BATTLEGROUND_JOIN_TIMED_OUT, WorldPacket::Initialize(), and SMSG_GROUP_JOINED_BATTLEGROUND.

◆ BuildPlayerJoinedBattlegroundPacket()

void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket ( WorldPacket data,
Player player 
)
263{
265 *data << player->GetGUID();
266}
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
@ SMSG_BATTLEGROUND_PLAYER_JOINED
Definition Opcodes.h:778

References Object::GetGUID(), WorldPacket::Initialize(), and SMSG_BATTLEGROUND_PLAYER_JOINED.

◆ BuildPlayerLeftBattlegroundPacket()

void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket ( WorldPacket data,
ObjectGuid  guid 
)
257{
259 *data << guid;
260}
@ SMSG_BATTLEGROUND_PLAYER_LEFT
Definition Opcodes.h:779

References WorldPacket::Initialize(), and SMSG_BATTLEGROUND_PLAYER_LEFT.

◆ CheckBattleMasters()

void BattlegroundMgr::CheckBattleMasters ( )
855{
856 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
857 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
858 {
859 if ((itr->second.npcflag & UNIT_NPC_FLAG_BATTLEMASTER) && mBattleMastersMap.find(itr->second.Entry) == mBattleMastersMap.end())
860 {
861 LOG_ERROR("sql.sql", "CreatureTemplate (Entry: {}) has UNIT_NPC_FLAG_BATTLEMASTER but no data in `battlemaster_entry` table. Removing flag!", itr->second.Entry);
862 const_cast<CreatureTemplate*>(&itr->second)->npcflag &= ~UNIT_NPC_FLAG_BATTLEMASTER;
863 }
864 }
865}
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition CreatureData.h:287
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
#define sObjectMgr
Definition ObjectMgr.h:1730
@ UNIT_NPC_FLAG_BATTLEMASTER
Definition UnitDefines.h:342
BattleMastersMap mBattleMastersMap
Definition BattlegroundMgr.h:162
Definition CreatureData.h:187

References LOG_ERROR, mBattleMastersMap, sObjectMgr, and UNIT_NPC_FLAG_BATTLEMASTER.

Referenced by LoadBattleMastersEntry().

◆ CreateBattleground()

bool BattlegroundMgr::CreateBattleground ( BattlegroundTemplate const *  bgTemplate)
private
430{
431 // Create the BG
432 Battleground* bg = GetBattlegroundTemplate(bgTemplate->Id);
433
434 if (!bg)
435 {
436 bg = BattlegroundMgr::bgtypeToBattleground[bgTemplate->Id];
437
438 ASSERT(bg);
439
440 if (bgTemplate->Id == BATTLEGROUND_RB)
441 bg->SetRandom(true);
442
443 bg->SetBgTypeID(bgTemplate->Id);
444 bg->SetInstanceID(0);
445 AddBattleground(bg);
446 }
447
448 bg->SetMapId(bgTemplate->BattlemasterEntry->mapid[0]);
449 bg->SetName(bgTemplate->BattlemasterEntry->name[sWorld->GetDefaultDbcLocale()]);
450 bg->SetArenaorBGType(bgTemplate->IsArena());
451 bg->SetMinPlayersPerTeam(bgTemplate->MinPlayersPerTeam);
452 bg->SetMaxPlayersPerTeam(bgTemplate->MaxPlayersPerTeam);
453 bg->SetTeamStartPosition(TEAM_ALLIANCE, bgTemplate->StartLocation[TEAM_ALLIANCE]);
454 bg->SetTeamStartPosition(TEAM_HORDE, bgTemplate->StartLocation[TEAM_HORDE]);
455 bg->SetStartMaxDist(bgTemplate->MaxStartDistSq);
456 bg->SetLevelRange(bgTemplate->MinLevel, bgTemplate->MaxLevel);
457 bg->SetScriptId(bgTemplate->ScriptId);
458
459 return true;
460}
#define ASSERT
Definition Errors.h:68
@ TEAM_HORDE
Definition SharedDefines.h:749
void AddBattleground(Battleground *bg)
Definition BattlegroundMgr.cpp:965
Battleground * GetBattlegroundTemplate(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:327
static std::unordered_map< int, Battleground * > bgtypeToBattleground
Definition BattlegroundMgr.h:1013
Definition Battleground.h:303
void SetMapId(uint32 MapID)
Definition Battleground.h:440
void SetInstanceID(uint32 InstanceID)
Definition Battleground.h:368
void SetRandom(bool isRandom)
Definition Battleground.h:380
void SetScriptId(uint32 scriptId)
Definition Battleground.h:379
void SetBgTypeID(BattlegroundTypeId TypeID)
Definition Battleground.h:365
void SetMinPlayersPerTeam(uint32 MinPlayers)
Definition Battleground.h:389
void SetStartMaxDist(float startMaxDist)
Definition Battleground.h:451
void SetName(std::string_view name)
Definition Battleground.h:364
void SetLevelRange(uint32 min, uint32 max)
Definition Battleground.h:374
void SetArenaorBGType(bool _isArena)
Definition Battleground.h:377
void SetTeamStartPosition(TeamId teamId, Position const &pos)
Definition Battleground.cpp:690
void SetMaxPlayersPerTeam(uint32 MaxPlayers)
Definition Battleground.h:388

References AddBattleground(), ASSERT, BATTLEGROUND_RB, BattlegroundTemplate::BattlemasterEntry, bgtypeToBattleground, GetBattlegroundTemplate(), BattlegroundTemplate::Id, BattlegroundTemplate::IsArena(), BattlemasterListEntry::mapid, BattlegroundTemplate::MaxLevel, BattlegroundTemplate::MaxPlayersPerTeam, BattlegroundTemplate::MaxStartDistSq, BattlegroundTemplate::MinLevel, BattlegroundTemplate::MinPlayersPerTeam, BattlemasterListEntry::name, BattlegroundTemplate::ScriptId, Battleground::SetArenaorBGType(), Battleground::SetBgTypeID(), Battleground::SetInstanceID(), Battleground::SetLevelRange(), Battleground::SetMapId(), Battleground::SetMaxPlayersPerTeam(), Battleground::SetMinPlayersPerTeam(), Battleground::SetName(), Battleground::SetRandom(), Battleground::SetScriptId(), Battleground::SetStartMaxDist(), Battleground::SetTeamStartPosition(), BattlegroundTemplate::StartLocation, sWorld, TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by LoadBattlegroundTemplates().

◆ CreateClientVisibleInstanceId()

uint32 BattlegroundMgr::CreateClientVisibleInstanceId ( BattlegroundTypeId  bgTypeId,
BattlegroundBracketId  bracket_id 
)
private
352{
353 if (IsArenaType(bgTypeId))
354 return 0; // arenas don't have client-instanceids
355
356 // we create here an instanceid, which is just for
357 // displaying this to the client and without any other use..
358 // the client-instanceIds are unique for each battleground-type
359 // the instance-id just needs to be as low as possible, beginning with 1
360 // the following works, because std::set is default ordered with "<"
361 // the optimalization would be to use as bitmask std::vector<uint32> - but that would only make code unreadable
362
363 BattlegroundClientIdsContainer& clientIds = bgDataStore[bgTypeId]._ClientBattlegroundIds[bracket_id];
364 uint32 lastId = 0;
365
366 for (BattlegroundClientIdsContainer::const_iterator itr = clientIds.begin(); itr != clientIds.end();)
367 {
368 if ((++lastId) != *itr) // if there is a gap between the ids, we will break..
369 break;
370
371 lastId = *itr;
372 }
373
374 clientIds.emplace(++lastId);
375 return lastId;
376}
static bool IsArenaType(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:675

References bgDataStore, and IsArenaType().

Referenced by CreateNewBattleground().

◆ CreateNewBattleground()

Battleground * BattlegroundMgr::CreateNewBattleground ( BattlegroundTypeId  bgTypeId,
PvPDifficultyEntry const *  bracketEntry,
uint8  arenaType,
bool  isRated 
)
380{
381 BattlegroundTypeId bgTypeId = GetRandomBG(originalBgTypeId, bracketEntry->minLevel);
382
383 if (originalBgTypeId == BATTLEGROUND_AA)
384 originalBgTypeId = bgTypeId;
385
386 // get the template BG
387 Battleground* bg_template = GetBattlegroundTemplate(bgTypeId);
388 if (!bg_template)
389 {
390 LOG_ERROR("bg.battleground", "Battleground: CreateNewBattleground - bg template not found for {}", bgTypeId);
391 return nullptr;
392 }
393
394 Battleground* bg = nullptr;
395
396 // create a copy of the BG template
398 {
399 return nullptr;
400 }
401
402 bg = BattlegroundMgr::bgTypeToTemplate[bgTypeId](bg_template);
403
404 bool isRandom = bgTypeId != originalBgTypeId && !bg->isArena();
405
406 bg->SetBracket(bracketEntry);
407 bg->SetInstanceID(sMapMgr->GenerateInstanceId());
408 bg->SetClientInstanceID(CreateClientVisibleInstanceId(originalBgTypeId, bracketEntry->GetBracketId()));
409 bg->Init();
410 bg->SetStatus(STATUS_WAIT_JOIN); // start the joining of the bg
411 bg->SetArenaType(arenaType);
412 bg->SetBgTypeID(originalBgTypeId);
413 bg->SetRandomTypeID(bgTypeId);
414 bg->SetRated(isRated);
415 bg->SetRandom(isRandom);
416
417 // Set up correct min/max player counts for scoreboards
418 if (bg->isArena())
419 {
420 uint32 maxPlayersPerTeam = ArenaTeam::GetReqPlayersForType(arenaType) / 2;
421 sScriptMgr->OnSetArenaMaxPlayersPerTeam(arenaType, maxPlayersPerTeam);
422 bg->SetMaxPlayersPerTeam(maxPlayersPerTeam);
423 }
424
425 return bg;
426}
#define sMapMgr
Definition MapMgr.h:220
static uint8 GetReqPlayersForType(uint32 type)
Definition ArenaTeam.cpp:1030
static std::unordered_map< int, bgRef > bgTypeToTemplate
Definition BattlegroundMgr.h:1030
BattlegroundTypeId GetRandomBG(BattlegroundTypeId id, uint32 minLevel)
Definition BattlegroundMgr.cpp:914
uint32 CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
Definition BattlegroundMgr.cpp:351
void SetBracket(PvPDifficultyEntry const *bracketEntry)
Definition Battleground.cpp:1873
void SetRated(bool state)
Definition Battleground.h:375
virtual void Init()
Definition Battleground.cpp:1136
void SetClientInstanceID(uint32 InstanceID)
Definition Battleground.h:370
void SetStatus(BattlegroundStatus Status)
Definition Battleground.cpp:1906
void SetArenaType(uint8 type)
Definition Battleground.h:376
void SetRandomTypeID(BattlegroundTypeId TypeID)
Definition Battleground.h:366

References BATTLEGROUND_AA, bgTypeToTemplate, CreateClientVisibleInstanceId(), GetBattlegroundTemplate(), PvPDifficultyEntry::GetBracketId(), GetRandomBG(), ArenaTeam::GetReqPlayersForType(), Battleground::Init(), Battleground::isArena(), LOG_ERROR, PvPDifficultyEntry::minLevel, Battleground::SetArenaType(), Battleground::SetBgTypeID(), Battleground::SetBracket(), Battleground::SetClientInstanceID(), Battleground::SetInstanceID(), Battleground::SetMaxPlayersPerTeam(), Battleground::SetRandom(), Battleground::SetRandomTypeID(), Battleground::SetRated(), Battleground::SetStatus(), sMapMgr, sScriptMgr, and STATUS_WAIT_JOIN.

◆ DeleteAllBattlegrounds()

void BattlegroundMgr::DeleteAllBattlegrounds ( )
84{
85 for (auto& [_, data] : bgDataStore)
86 {
87 while (!data._Battlegrounds.empty())
88 delete data._Battlegrounds.begin()->second;
89
90 data._Battlegrounds.clear();
91
92 while (!data.BGFreeSlotQueue.empty())
93 delete data.BGFreeSlotQueue.front();
94 }
95
96 bgDataStore.clear();
97}

References bgDataStore.

Referenced by ~BattlegroundMgr().

◆ GetActiveBattlegrounds()

std::vector< Battleground const * > BattlegroundMgr::GetActiveBattlegrounds ( )
340{
341 std::vector<Battleground const*> result;
342
343 for (auto const& [bgType, bgData] : bgDataStore)
344 for (auto const& [id, bg] : bgData._Battlegrounds)
345 if (bg->GetStatus() == STATUS_WAIT_JOIN || bg->GetStatus() == STATUS_IN_PROGRESS)
346 result.push_back(static_cast<Battleground const*>(bg));
347
348 return result;
349}

References bgDataStore, STATUS_IN_PROGRESS, and STATUS_WAIT_JOIN.

◆ GetBattleground()

Battleground * BattlegroundMgr::GetBattleground ( uint32  instanceID,
BattlegroundTypeId  bgTypeId 
)
293{
294 if (!instanceId)
295 return nullptr;
296
297 auto GetBgWithInstanceID = [instanceId](BattlegroundData const* bgData) -> Battleground*
298 {
299 auto const& itr = bgData->_Battlegrounds.find(instanceId);
300 if (itr != bgData->_Battlegrounds.end())
301 return itr->second;
302
303 return nullptr;
304 };
305
306 if (bgTypeId == BATTLEGROUND_TYPE_NONE)
307 {
308 for (auto const& [bgType, bgData] : bgDataStore)
309 {
310 if (auto bg = GetBgWithInstanceID(&bgData))
311 return bg;
312 }
313 }
314 else
315 {
316 auto const& itr = bgDataStore.find(bgTypeId);
317 if (itr == bgDataStore.end())
318 return nullptr;
319
320 if (auto bg = GetBgWithInstanceID(&itr->second))
321 return bg;
322 }
323
324 return nullptr;
325}
Definition BattlegroundMgr.h:39

References BATTLEGROUND_TYPE_NONE, and bgDataStore.

Referenced by GetBattlegroundThroughClientInstance(), and SendToBattleground().

◆ GetBattlegroundQueue()

BattlegroundQueue & BattlegroundMgr::GetBattlegroundQueue ( BattlegroundQueueTypeId  bgQueueTypeId)
inline
102{ return m_BattlegroundQueues[bgQueueTypeId]; }
BattlegroundQueue m_BattlegroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES]
Definition BattlegroundMgr.h:154

References m_BattlegroundQueues.

◆ GetBattlegroundTemplate()

Battleground * BattlegroundMgr::GetBattlegroundTemplate ( BattlegroundTypeId  bgTypeId)
328{
329 BattlegroundDataContainer::const_iterator itr = bgDataStore.find(bgTypeId);
330 if (itr == bgDataStore.end())
331 return nullptr;
332
333 BattlegroundContainer const& bgs = itr->second._Battlegrounds;
334
335 // map is sorted and we can be sure that lowest instance id has only BG template
336 return bgs.empty() ? nullptr : bgs.begin()->second;
337}
std::map< uint32, Battleground * > BattlegroundContainer
Definition BattlegroundMgr.h:27

References bgDataStore.

Referenced by CreateBattleground(), CreateNewBattleground(), GetBattlegroundThroughClientInstance(), and SetHolidayWeekends().

◆ GetBattlegroundTemplateByMapId()

BattlegroundTemplate const * BattlegroundMgr::GetBattlegroundTemplateByMapId ( uint32  mapId)
inlineprivate
174 {
175 auto const& itr = _battlegroundMapTemplates.find(mapId);
176 if (itr != _battlegroundMapTemplates.end())
177 return itr->second;
178
179 return nullptr;
180 }
BattlegroundMapTemplateContainer _battlegroundMapTemplates
Definition BattlegroundMgr.h:187

References _battlegroundMapTemplates.

Referenced by GetRandomBG().

◆ GetBattlegroundTemplateByTypeId()

BattlegroundTemplate const * BattlegroundMgr::GetBattlegroundTemplateByTypeId ( BattlegroundTypeId  id)
inlineprivate
165 {
166 auto const& itr = _battlegroundTemplates.find(id);
167 if (itr != _battlegroundTemplates.end())
168 return &itr->second;
169
170 return nullptr;
171 }
BattlegroundTemplateMap _battlegroundTemplates
Definition BattlegroundMgr.h:186

References _battlegroundTemplates.

Referenced by GetRandomBG().

◆ GetBattlegroundThroughClientInstance()

Battleground * BattlegroundMgr::GetBattlegroundThroughClientInstance ( uint32  instanceId,
BattlegroundTypeId  bgTypeId 
)
269{
270 //cause at HandleBattlegroundJoinOpcode the clients sends the instanceid he gets from
271 //SMSG_BATTLEFIELD_LIST we need to find the battleground with this clientinstance-id
273 if (!bg)
274 return nullptr;
275
276 if (bg->isArena())
277 return GetBattleground(instanceId, bgTypeId);
278
279 auto const& it = bgDataStore.find(bgTypeId);
280 if (it == bgDataStore.end())
281 return nullptr;
282
283 for (auto const& itr : it->second._Battlegrounds)
284 {
285 if (itr.second->GetClientInstanceID() == instanceId)
286 return itr.second;
287 }
288
289 return nullptr;
290}
Battleground * GetBattleground(uint32 instanceID, BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:292

References bgDataStore, GetBattleground(), GetBattlegroundTemplate(), and Battleground::isArena().

◆ GetBattleMasterBG()

BattlegroundTypeId BattlegroundMgr::GetBattleMasterBG ( uint32  entry) const
inline
130 {
131 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
132 if (itr != mBattleMastersMap.end())
133 return itr->second;
135 }

References BATTLEGROUND_TYPE_NONE, and mBattleMastersMap.

◆ GetBGFreeSlotQueueStore()

BGFreeSlotQueueContainer & BattlegroundMgr::GetBGFreeSlotQueueStore ( BattlegroundTypeId  bgTypeId)
945{
946 return bgDataStore[bgTypeId].BGFreeSlotQueue;
947}

References bgDataStore.

◆ GetMaxRatingDifference()

uint32 BattlegroundMgr::GetMaxRatingDifference ( ) const
782{
784
785 if (diff == 0)
786 {
787 diff = 5000;
788 }
789
790 return diff;
791}
@ CONFIG_ARENA_MAX_RATING_DIFFERENCE
Definition WorldConfig.h:294

References CONFIG_ARENA_MAX_RATING_DIFFERENCE, and sWorld.

◆ GetPrematureFinishTime()

uint32 BattlegroundMgr::GetPrematureFinishTime ( ) const
799{
801}
@ CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER
Definition WorldConfig.h:276

References CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER, and sWorld.

◆ GetRandomBG()

BattlegroundTypeId BattlegroundMgr::GetRandomBG ( BattlegroundTypeId  id,
uint32  minLevel 
)
private
915{
916 if (BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId))
917 {
918 std::vector<BattlegroundTypeId> ids;
919 ids.reserve(16);
920 std::vector<double> weights;
921 weights.reserve(16);
922
923 for (int32 mapId : bgTemplate->BattlemasterEntry->mapid)
924 {
925 if (mapId == -1)
926 break;
927
929 {
930 if (bg->MinLevel <= minLevel)
931 {
932 ids.push_back(bg->Id);
933 weights.push_back(bg->Weight);
934 }
935 }
936 }
937
939 }
940
942}
BattlegroundTemplate const * GetBattlegroundTemplateByMapId(uint32 mapId)
Definition BattlegroundMgr.h:173
BattlegroundTemplate const * GetBattlegroundTemplateByTypeId(BattlegroundTypeId id)
Definition BattlegroundMgr.h:164
auto SelectRandomWeightedContainerElement(C const &container, std::vector< double > weights) -> decltype(std::begin(container))
Definition Containers.h:175
Definition BattlegroundMgr.h:46

References BATTLEGROUND_TYPE_NONE, GetBattlegroundTemplateByMapId(), GetBattlegroundTemplateByTypeId(), and Acore::Containers::SelectRandomWeightedContainerElement().

Referenced by CreateNewBattleground().

◆ GetRatingDiscardTimer()

uint32 BattlegroundMgr::GetRatingDiscardTimer ( ) const
794{
795 return sWorld->getIntConfig(CONFIG_ARENA_RATING_DISCARD_TIMER);
796}
@ CONFIG_ARENA_RATING_DISCARD_TIMER
Definition WorldConfig.h:295

References CONFIG_ARENA_RATING_DISCARD_TIMER, and sWorld.

◆ InitAutomaticArenaPointDistribution()

void BattlegroundMgr::InitAutomaticArenaPointDistribution ( )
562{
563 if (!sWorld->getBoolConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS))
564 return;
565
567 Seconds curtime = GameTime::GetGameTime();
568
569 LOG_INFO("server.loading", "Initializing Automatic Arena Point Distribution");
570
571 if (wstime < curtime)
572 {
573 m_NextAutoDistributionTime = curtime; // reset will be called in the next update
574 LOG_INFO("server.loading", "Next arena point distribution time in the past, reseting it now.");
575 }
576 else
577 {
579 }
580
581 LOG_INFO("server.loading", "Automatic Arena Point Distribution initialized.");
582}
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:30
#define LOG_INFO(filterType__,...)
Definition Log.h:153
@ CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS
Definition WorldConfig.h:74
@ WORLD_STATE_CUSTOM_ARENA_DISTRIBUTION_TIME
Definition WorldStateDefines.h:606
#define sWorldState
Definition WorldState.h:377
Seconds GetGameTime()
Definition GameTime.cpp:38

References CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS, GameTime::GetGameTime(), LOG_INFO, m_NextAutoDistributionTime, sWorld, sWorldState, and WORLD_STATE_CUSTOM_ARENA_DISTRIBUTION_TIME.

◆ instance()

BattlegroundMgr * BattlegroundMgr::instance ( )
static
78{
80 return &instance;
81}
Definition BattlegroundMgr.h:62
static BattlegroundMgr * instance()
Definition BattlegroundMgr.cpp:77

References instance().

Referenced by instance().

◆ isArenaTesting()

bool BattlegroundMgr::isArenaTesting ( ) const
inline
111{ return m_ArenaTesting; }

References m_ArenaTesting.

◆ IsArenaType()

bool BattlegroundMgr::IsArenaType ( BattlegroundTypeId  bgTypeId)
static
676{
677 return bgTypeId == BATTLEGROUND_AA
678 || bgTypeId == BATTLEGROUND_BE
679 || bgTypeId == BATTLEGROUND_NA
680 || bgTypeId == BATTLEGROUND_DS
681 || bgTypeId == BATTLEGROUND_RV
682 || bgTypeId == BATTLEGROUND_RL;
683}
@ BATTLEGROUND_BE
Definition SharedDefines.h:3741
@ BATTLEGROUND_RV
Definition SharedDefines.h:3747
@ BATTLEGROUND_NA
Definition SharedDefines.h:3740
@ BATTLEGROUND_DS
Definition SharedDefines.h:3746
@ BATTLEGROUND_RL
Definition SharedDefines.h:3744

References BATTLEGROUND_AA, BATTLEGROUND_BE, BATTLEGROUND_DS, BATTLEGROUND_NA, BATTLEGROUND_RL, and BATTLEGROUND_RV.

Referenced by CreateClientVisibleInstanceId().

◆ IsBGWeekend()

bool BattlegroundMgr::IsBGWeekend ( BattlegroundTypeId  bgTypeId)
static
910{
912}
bool IsHolidayActive(HolidayIds id)
Definition GameEventMgr.cpp:2032
static HolidayIds BGTypeToWeekendHolidayId(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:867

References BGTypeToWeekendHolidayId(), and IsHolidayActive().

Referenced by Battleground::EndBattleground(), BattlegroundAV::EndBattleground(), Player::SendBGWeekendWorldStates(), BattlegroundAB::SetupBattleground(), and BattlegroundEY::SetupBattleground().

◆ isTesting()

bool BattlegroundMgr::isTesting ( ) const
inline
112{ return m_Testing; }

References m_Testing.

◆ LoadBattlegroundTemplates()

void BattlegroundMgr::LoadBattlegroundTemplates ( )
463{
464 uint32 oldMSTime = getMSTime();
465
468
469 // 0 1 2 3 4 5 6 7 8 9 10 11
470 QueryResult result = WorldDatabase.Query("SELECT ID, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, AllianceStartLoc, AllianceStartO, HordeStartLoc, HordeStartO, StartMaxDist, Weight, ScriptName FROM battleground_template");
471
472 if (!result)
473 {
474 LOG_ERROR("bg.battleground", ">> Loaded 0 battlegrounds. DB table `battleground_template` is empty.");
475 return;
476 }
477
478 do
479 {
480 Field* fields = result->Fetch();
481
482 BattlegroundTypeId bgTypeId = static_cast<BattlegroundTypeId>(fields[0].Get<uint32>());
483
484 if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId, nullptr))
485 continue;
486
487 // can be overwrite by values from DB
488 BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId);
489 if (!bl)
490 {
491 LOG_ERROR("bg.battleground", "Battleground ID {} not found in BattlemasterList.dbc. Battleground not created.", bgTypeId);
492 continue;
493 }
494
495 BattlegroundTemplate bgTemplate;
496 bgTemplate.Id = bgTypeId;
497 bgTemplate.MinPlayersPerTeam = fields[1].Get<uint16>();
498 bgTemplate.MaxPlayersPerTeam = fields[2].Get<uint16>();
499 bgTemplate.MinLevel = fields[3].Get<uint8>();
500 bgTemplate.MaxLevel = fields[4].Get<uint8>();
501 float dist = fields[9].Get<float>();
502 bgTemplate.MaxStartDistSq = dist * dist;
503 bgTemplate.Weight = fields[10].Get<uint8>();
504 bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[11].Get<std::string>());
505 bgTemplate.BattlemasterEntry = bl;
506
507 if (bgTemplate.MaxPlayersPerTeam == 0 || bgTemplate.MinPlayersPerTeam > bgTemplate.MaxPlayersPerTeam)
508 {
509 LOG_ERROR("sql.sql", "Table `battleground_template` for id {} contains bad values for MinPlayersPerTeam ({}) and MaxPlayersPerTeam({}).",
510 bgTemplate.Id, bgTemplate.MinPlayersPerTeam, bgTemplate.MaxPlayersPerTeam);
511
512 continue;
513 }
514
515 if (bgTemplate.MinLevel == 0 || bgTemplate.MaxLevel == 0 || bgTemplate.MinLevel > bgTemplate.MaxLevel)
516 {
517 LOG_ERROR("sql.sql", "Table `battleground_template` for id {} has bad values for LevelMin ({}) and LevelMax({})",
518 bgTemplate.Id, bgTemplate.MinLevel, bgTemplate.MaxLevel);
519 continue;
520 }
521
522 if (bgTemplate.Id != BATTLEGROUND_AA && bgTemplate.Id != BATTLEGROUND_RB)
523 {
524 uint32 startId = fields[5].Get<uint32>();
525 if (GraveyardStruct const* start = sGraveyard->GetGraveyard(startId))
526 {
527 bgTemplate.StartLocation[TEAM_ALLIANCE].Relocate(start->x, start->y, start->z, fields[6].Get<float>());
528 }
529 else
530 {
531 LOG_ERROR("sql.sql", "Table `battleground_template` for id {} contains a non-existing WorldSafeLocs.dbc id {} in field `AllianceStartLoc`. BG not created.", bgTemplate.Id, startId);
532 continue;
533 }
534
535 startId = fields[7].Get<uint32>();
536 if (GraveyardStruct const* start = sGraveyard->GetGraveyard(startId))
537 {
538 bgTemplate.StartLocation[TEAM_HORDE].Relocate(start->x, start->y, start->z, fields[8].Get<float>());
539 }
540 else
541 {
542 LOG_ERROR("sql.sql", "Table `battleground_template` for id {} contains a non-existing WorldSafeLocs.dbc id {} in field `HordeStartLoc`. BG not created.", bgTemplate.Id, startId);
543 continue;
544 }
545 }
546
547 if (!CreateBattleground(&bgTemplate))
548 continue;
549
550 _battlegroundTemplates[bgTypeId] = bgTemplate;
551
552 if (bgTemplate.BattlemasterEntry->mapid[1] == -1) // in this case we have only one mapId
554
555 } while (result->NextRow());
556
557 LOG_INFO("server.loading", ">> Loaded {} battlegrounds in {} ms", _battlegroundTemplates.size(), GetMSTimeDiffToNow(oldMSTime));
558 LOG_INFO("server.loading", " ");
559}
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListEntryfmt)
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
#define sDisableMgr
Definition DisableMgr.h:88
@ DISABLE_TYPE_BATTLEGROUND
Definition DisableMgr.h:31
#define sGraveyard
Definition GameGraveyard.h:74
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
bool CreateBattleground(BattlegroundTemplate const *bgTemplate)
Definition BattlegroundMgr.cpp:429
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
BattlegroundTypeId Id
Definition BattlegroundMgr.h:47
uint16 MaxPlayersPerTeam
Definition BattlegroundMgr.h:49
uint8 MinLevel
Definition BattlegroundMgr.h:50
BattlemasterListEntry const * BattlemasterEntry
Definition BattlegroundMgr.h:56
float MaxStartDistSq
Definition BattlegroundMgr.h:53
uint8 MaxLevel
Definition BattlegroundMgr.h:51
std::array< Position, PVP_TEAMS_COUNT > StartLocation
Definition BattlegroundMgr.h:52
uint32 ScriptId
Definition BattlegroundMgr.h:55
uint8 Weight
Definition BattlegroundMgr.h:54
uint16 MinPlayersPerTeam
Definition BattlegroundMgr.h:48
Definition DBCStructure.h:604
int32 mapid[8]
Definition DBCStructure.h:606
Definition GameGraveyard.h:27

References _battlegroundMapTemplates, _battlegroundTemplates, BATTLEGROUND_AA, BATTLEGROUND_RB, BattlegroundTemplate::BattlemasterEntry, CreateBattleground(), DISABLE_TYPE_BATTLEGROUND, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), BattlegroundTemplate::Id, LOG_ERROR, LOG_INFO, BattlemasterListEntry::mapid, BattlegroundTemplate::MaxLevel, BattlegroundTemplate::MaxPlayersPerTeam, BattlegroundTemplate::MaxStartDistSq, BattlegroundTemplate::MinLevel, BattlegroundTemplate::MinPlayersPerTeam, sBattlemasterListStore, BattlegroundTemplate::ScriptId, sDisableMgr, sGraveyard, sObjectMgr, BattlegroundTemplate::StartLocation, TEAM_ALLIANCE, TEAM_HORDE, BattlegroundTemplate::Weight, and WorldDatabase.

◆ LoadBattleMastersEntry()

void BattlegroundMgr::LoadBattleMastersEntry ( )
804{
805 uint32 oldMSTime = getMSTime();
806
807 mBattleMastersMap.clear(); // need for reload case
808
809 QueryResult result = WorldDatabase.Query("SELECT entry, bg_template FROM battlemaster_entry");
810
811 if (!result)
812 {
813 LOG_WARN("server.loading", ">> Loaded 0 battlemaster entries. DB table `battlemaster_entry` is empty!");
814 LOG_INFO("server.loading", " ");
815 return;
816 }
817
818 uint32 count = 0;
819
820 do
821 {
822 ++count;
823
824 Field* fields = result->Fetch();
825
826 uint32 entry = fields[0].Get<uint32>();
827 if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(entry))
828 {
829 if ((cInfo->npcflag & UNIT_NPC_FLAG_BATTLEMASTER) == 0)
830 LOG_ERROR("sql.sql", "Creature (Entry: {}) listed in `battlemaster_entry` is not a battlemaster.", entry);
831 }
832 else
833 {
834 LOG_ERROR("sql.sql", "Creature (Entry: {}) listed in `battlemaster_entry` does not exist.", entry);
835 continue;
836 }
837
838 uint32 bgTypeId = fields[1].Get<uint32>();
839 if (!sBattlemasterListStore.LookupEntry(bgTypeId))
840 {
841 LOG_ERROR("sql.sql", "Table `battlemaster_entry` contain entry {} for not existed battleground type {}, ignored.", entry, bgTypeId);
842 continue;
843 }
844
845 mBattleMastersMap[entry] = BattlegroundTypeId(bgTypeId);
846 } while (result->NextRow());
847
849
850 LOG_INFO("server.loading", ">> Loaded {} battlemaster entries in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
851 LOG_INFO("server.loading", " ");
852}
#define LOG_WARN(filterType__,...)
Definition Log.h:149
void CheckBattleMasters()
Definition BattlegroundMgr.cpp:854

References CheckBattleMasters(), Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, mBattleMastersMap, sBattlemasterListStore, sObjectMgr, UNIT_NPC_FLAG_BATTLEMASTER, and WorldDatabase.

◆ RemoveBattleground()

void BattlegroundMgr::RemoveBattleground ( BattlegroundTypeId  bgTypeId,
uint32  instanceId 
)
974{
975 bgDataStore[bgTypeId]._Battlegrounds.erase(instanceId);
976}

References bgDataStore.

◆ RemoveFromBGFreeSlotQueue()

void BattlegroundMgr::RemoveFromBGFreeSlotQueue ( BattlegroundTypeId  bgTypeId,
uint32  instanceId 
)
955{
956 BGFreeSlotQueueContainer& queues = bgDataStore[bgTypeId].BGFreeSlotQueue;
957 for (BGFreeSlotQueueContainer::iterator itr = queues.begin(); itr != queues.end(); ++itr)
958 if ((*itr)->GetInstanceID() == instanceId)
959 {
960 queues.erase(itr);
961 return;
962 }
963}
std::list< Battleground * > BGFreeSlotQueueContainer
Definition BattlegroundMgr.h:36

References bgDataStore.

◆ ScheduleQueueUpdate()

void BattlegroundMgr::ScheduleQueueUpdate ( uint32  arenaMatchmakerRating,
uint8  arenaType,
BattlegroundQueueTypeId  bgQueueTypeId,
BattlegroundTypeId  bgTypeId,
BattlegroundBracketId  bracket_id 
)
773{
774 //This method must be atomic, @todo add mutex
775 //we will use only 1 number created of bgTypeId and bracket_id
776 uint64 const scheduleId = ((uint64)arenaMatchmakerRating << 32) | ((uint64)arenaType << 24) | ((uint64)bgQueueTypeId << 16) | ((uint64)bgTypeId << 8) | (uint64)bracket_id;
777 if (std::find(m_QueueUpdateScheduler.begin(), m_QueueUpdateScheduler.end(), scheduleId) == m_QueueUpdateScheduler.end())
778 m_QueueUpdateScheduler.emplace_back(scheduleId);
779}
std::vector< uint64 > m_QueueUpdateScheduler
Definition BattlegroundMgr.h:156

References m_QueueUpdateScheduler.

◆ SendAreaSpiritHealerQueryOpcode()

void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode ( Player player,
Battleground bg,
ObjectGuid  guid 
)
666{
668 uint32 time_ = RESURRECTION_INTERVAL - bg->GetLastResurrectTime(); // resurrect every X seconds
669 if (time_ == uint32(-1))
670 time_ = 0;
671 data << guid << time_;
672 player->SendDirectMessage(&data);
673}
#define RESURRECTION_INTERVAL
Definition Battleground.h:163
uint32 GetLastResurrectTime() const
Definition Battleground.h:336
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5852
Definition WorldPacket.h:26
@ SMSG_AREA_SPIRIT_HEALER_TIME
Definition Opcodes.h:770

References Battleground::GetLastResurrectTime(), RESURRECTION_INTERVAL, Player::SendDirectMessage(), and SMSG_AREA_SPIRIT_HEALER_TIME.

◆ SendToBattleground()

bool BattlegroundMgr::SendToBattleground ( Player player,
uint32  InstanceID,
BattlegroundTypeId  bgTypeId 
)
651{
652 if (Battleground* bg = GetBattleground(instanceId, bgTypeId))
653 {
654 uint32 mapid = bg->GetMapId();
655 Position const* pos = bg->GetTeamStartPosition(player->GetBgTeamId());
656
657 LOG_DEBUG("bg.battleground", "BattlegroundMgr::SendToBattleground: Sending {} to map {}, {} (bgType {})", player->GetName(), mapid, pos->ToString(), bgTypeId);
658 return player->TeleportTo(mapid, pos->GetPositionX(), pos->GetPositionY(), pos->GetPositionZ(), pos->GetOrientation());
659 }
660
661 LOG_ERROR("bg.battleground", "BattlegroundMgr::SendToBattleground: Instance {} (bgType {}) not found while trying to teleport player {}", instanceId, bgTypeId, player->GetName());
662 return false;
663}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1399
TeamId GetBgTeamId() const
Definition Player.h:2325
std::string const & GetName() const
Definition Object.h:529
Definition Position.h:27
std::string ToString() const
Definition Position.cpp:59
float GetPositionZ() const
Definition Position.h:123
float GetOrientation() const
Definition Position.h:124
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122

References GetBattleground(), Player::GetBgTeamId(), WorldObject::GetName(), Position::GetOrientation(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), LOG_DEBUG, LOG_ERROR, Player::TeleportTo(), and Position::ToString().

◆ SetHolidayWeekends()

void BattlegroundMgr::SetHolidayWeekends ( uint32  mask)
762{
763 for (uint32 bgtype = 1; bgtype < MAX_BATTLEGROUND_TYPE_ID; ++bgtype)
764 {
765 if (bgtype == BATTLEGROUND_RB)
766 continue;
768 bgt->SetHoliday(mask & (1 << bgtype));
769 }
770}
#define MAX_BATTLEGROUND_TYPE_ID
Definition SharedDefines.h:3752

References BATTLEGROUND_RB, GetBattlegroundTemplate(), and MAX_BATTLEGROUND_TYPE_ID.

◆ ToggleArenaTesting()

void BattlegroundMgr::ToggleArenaTesting ( )
748{
749 if (sWorld->getBoolConfig(CONFIG_DEBUG_ARENA))
750 {
751 m_ArenaTesting = true;
753 }
754 else
755 {
758 }
759}
@ LANG_DEBUG_ARENA_OFF
Definition Language.h:720
@ LANG_DEBUG_ARENA_ON
Definition Language.h:719
@ LANG_DEBUG_ARENA_CONF
Definition Language.h:1423
Definition Chat.h:37
void SendWorldText(std::string_view str)
Definition Chat.cpp:139

References CONFIG_DEBUG_ARENA, LANG_DEBUG_ARENA_CONF, LANG_DEBUG_ARENA_OFF, LANG_DEBUG_ARENA_ON, m_ArenaTesting, ChatHandler::SendWorldText(), and sWorld.

◆ ToggleTesting()

void BattlegroundMgr::ToggleTesting ( )
734{
735 if (sWorld->getBoolConfig(CONFIG_DEBUG_BATTLEGROUND))
736 {
737 m_Testing = true;
739 }
740 else
741 {
744 }
745}
@ LANG_DEBUG_BG_OFF
Definition Language.h:722
@ LANG_DEBUG_BG_CONF
Definition Language.h:1422
@ LANG_DEBUG_BG_ON
Definition Language.h:721

References CONFIG_DEBUG_BATTLEGROUND, LANG_DEBUG_BG_CONF, LANG_DEBUG_BG_OFF, LANG_DEBUG_BG_ON, m_Testing, ChatHandler::SendWorldText(), and sWorld.

◆ Update()

void BattlegroundMgr::Update ( uint32  diff)
101{
102 // update all battlegrounds and delete if needed
103 for (auto& [_, bgData] : bgDataStore)
104 {
105 auto& bgList = bgData._Battlegrounds;
106 auto itrDelete = bgList.begin();
107
108 // first one is template and should not be deleted
109 for (BattlegroundContainer::iterator itr = ++itrDelete; itr != bgList.end();)
110 {
111 itrDelete = itr++;
112 Battleground* bg = itrDelete->second;
113
114 bg->Update(diff);
115 if (bg->ToBeDeleted())
116 {
117 itrDelete->second = nullptr;
118 bgList.erase(itrDelete);
119
120 BattlegroundClientIdsContainer& clients = bgData._ClientBattlegroundIds[bg->GetBracketId()];
121 if (!clients.empty())
122 clients.erase(bg->GetClientInstanceID());
123
124 delete bg;
125 }
126 }
127 }
128
129 // update events
130 for (uint8 qtype = BATTLEGROUND_QUEUE_NONE; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
131 m_BattlegroundQueues[qtype].UpdateEvents(diff);
132
133 // update using scheduled tasks (used only for rated arenas, initial opponent search works differently than periodic queue update)
134 if (!m_QueueUpdateScheduler.empty())
135 {
136 std::vector<uint64> scheduled;
137 std::swap(scheduled, m_QueueUpdateScheduler);
138
139 for (uint8 i = 0; i < scheduled.size(); i++)
140 {
141 uint32 arenaMMRating = scheduled[i] >> 32;
142 uint8 arenaType = scheduled[i] >> 24 & 255;
143 BattlegroundQueueTypeId bgQueueTypeId = BattlegroundQueueTypeId(scheduled[i] >> 16 & 255);
144 BattlegroundTypeId bgTypeId = BattlegroundTypeId((scheduled[i] >> 8) & 255);
145 BattlegroundBracketId bracket_id = BattlegroundBracketId(scheduled[i] & 255);
146 m_BattlegroundQueues[bgQueueTypeId].BattlegroundQueueUpdate(diff, bgTypeId, bracket_id, arenaType, arenaMMRating > 0, arenaMMRating);
147 m_BattlegroundQueues[bgQueueTypeId].BattlegroundQueueAnnouncerUpdate(diff, bgQueueTypeId, bracket_id);
148 }
149 }
150
151 // periodic queue update
153 {
155
156 LOG_TRACE("bg.arena", "BattlegroundMgr: UPDATING ARENA QUEUES");
157
158 // for rated arenas
159 for (uint32 qtype = BATTLEGROUND_QUEUE_2v2; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
160 {
161 for (uint32 bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
162 {
164 }
165 }
166
167 for (uint32 qtype = BATTLEGROUND_QUEUE_AV; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
168 {
169 for (uint32 bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
170 {
172 }
173 }
174 }
175 else
177
178 // arena points auto-distribution
180 {
182 {
184 {
185 sArenaTeamMgr->DistributeArenaPoints();
188 }
189 m_AutoDistributionTimeChecker = 600000; // 10 minutes check
190 }
191 else
193 }
194}
#define sArenaTeamMgr
Definition ArenaTeamMgr.h:69
constexpr auto DAY
Definition Common.h:49
@ BG_BRACKET_ID_FIRST
Definition DBCEnums.h:47
#define MAX_BATTLEGROUND_BRACKETS
Definition DBCEnums.h:52
#define LOG_TRACE(filterType__,...)
Definition Log.h:161
@ BATTLEGROUND_QUEUE_2v2
Definition SharedDefines.h:3884
@ BATTLEGROUND_QUEUE_AV
Definition SharedDefines.h:3877
@ MAX_BATTLEGROUND_QUEUE_TYPES
Definition SharedDefines.h:3887
@ CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS
Definition WorldConfig.h:297
static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId)
Definition BattlegroundMgr.cpp:719
void BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id, uint8 arenaType, bool isRated, uint32 arenaRating)
Definition BattlegroundQueue.cpp:790
void BattlegroundQueueAnnouncerUpdate(uint32 diff, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundBracketId bracket_id)
Definition BattlegroundQueue.cpp:1041
bool ToBeDeleted() const
Definition Battleground.h:564
void Update(uint32 diff)
Definition Battleground.cpp:254
BattlegroundBracketId GetBracketId() const
Definition Battleground.h:330

References BATTLEGROUND_AA, BATTLEGROUND_QUEUE_2v2, BATTLEGROUND_QUEUE_AV, BATTLEGROUND_QUEUE_NONE, BattlegroundQueue::BattlegroundQueueAnnouncerUpdate(), BattlegroundQueue::BattlegroundQueueUpdate(), BG_BRACKET_ID_FIRST, BGArenaType(), bgDataStore, CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS, CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS, DAY, Battleground::GetBracketId(), Battleground::GetClientInstanceID(), GameTime::GetGameTime(), IN_MILLISECONDS, LOG_TRACE, m_AutoDistributionTimeChecker, m_BattlegroundQueues, m_NextAutoDistributionTime, m_NextPeriodicQueueUpdateTime, m_QueueUpdateScheduler, MAX_BATTLEGROUND_BRACKETS, MAX_BATTLEGROUND_QUEUE_TYPES, sArenaTeamMgr, sWorld, sWorldState, Battleground::ToBeDeleted(), Battleground::Update(), and WORLD_STATE_CUSTOM_ARENA_DISTRIBUTION_TIME.

◆ WeekendHolidayIdToBGType()

Member Data Documentation

◆ _battlegroundMapTemplates

BattlegroundMapTemplateContainer BattlegroundMgr::_battlegroundMapTemplates
private

◆ _battlegroundTemplates

BattlegroundTemplateMap BattlegroundMgr::_battlegroundTemplates
private

◆ ArenaTypeToQueue

std::unordered_map< uint32, BattlegroundQueueTypeId > BattlegroundMgr::ArenaTypeToQueue
static
Initial value:
=
{
}
@ ARENA_TYPE_5v5
Definition Battleground.h:210
@ ARENA_TYPE_3v3
Definition Battleground.h:209
@ ARENA_TYPE_2v2
Definition Battleground.h:208
@ BATTLEGROUND_QUEUE_5v5
Definition SharedDefines.h:3886
@ BATTLEGROUND_QUEUE_3v3
Definition SharedDefines.h:3885
1106{
1107 BattlegroundContainer _Battlegrounds;
1108 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1109 BGFreeSlotQueueContainer BGFreeSlotQueue;
1110};
1111
1113{
1115 uint16 MinPlayersPerTeam;
1116 uint16 MaxPlayersPerTeam;
1117 uint8 MinLevel;
1118 uint8 MaxLevel;
1119 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1120 float MaxStartDistSq;
1121 uint8 Weight;
1122 uint32 ScriptId;
1123 BattlemasterListEntry const* BattlemasterEntry;
1124
1125 bool IsArena() const;
1126};
1127
1128class BattlegroundMgr
1129{
1130private:
1133
1134public:
1135 static BattlegroundMgr* instance();
1136
1137 void Update(uint32 diff);
1138
1139 /* Packet Building */
1142 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1144 void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE);
1146
1147 /* Battlegrounds */
1151 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1152 std::vector<Battleground const*> GetActiveBattlegrounds();
1153
1154 void AddBattleground(Battleground* bg);
1155 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1157 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1159
1162
1163 // Returns false when the teleport could not start (instance gone, or a
1164 // synchronous TeleportTo failure) so the accept path can release the
1165 // otherwise-orphaned invited reservation.
1166 bool SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1167
1168 /* Battleground queues */
1170 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1172
1173 void ToggleArenaTesting();
1174 void ToggleTesting();
1175
1176 void SetHolidayWeekends(uint32 mask);
1177
1178 bool isArenaTesting() const { return m_ArenaTesting; }
1179 bool isTesting() const { return m_Testing; }
1180
1183 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1184 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1185
1188 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1189
1194 void CheckBattleMasters();
1195
1197 {
1198 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1199 if (itr != mBattleMastersMap.end())
1200 return itr->second;
1202 }
1203
1204 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1205 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1206 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1207 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1208 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1209 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1210 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1211 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1212
1213private:
1214 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1217
1218 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1220
1222
1223 std::vector<uint64> m_QueueUpdateScheduler;
1224 bool m_ArenaTesting;
1225 bool m_Testing;
1230
1232 {
1233 auto const& itr = _battlegroundTemplates.find(id);
1234 if (itr != _battlegroundTemplates.end())
1235 return &itr->second;
1236
1237 return nullptr;
1238 }
1239
1241 {
1242 auto const& itr = _battlegroundMapTemplates.find(mapId);
1243 if (itr != _battlegroundMapTemplates.end())
1244 return itr->second;
1245
1246 return nullptr;
1247 }
1248
1249 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1250
1251 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1252 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1255};
1256
1257#define sBattlegroundMgr BattlegroundMgr::instance()
1258
1259#endif
std::unordered_map< uint32, BattlegroundTypeId > BattleMastersMap
Definition BattlegroundMgr.h:29
GroupJoinBattlegroundResult
Definition SharedDefines.h:3891
TeamId
Definition SharedDefines.h:747
HolidayIds
Definition SharedDefines.h:2974
std::map< BattlegroundTypeId, BattlegroundTemplate > BattlegroundTemplateMap
Definition BattlegroundMgr.h:184
Battleground * GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:268
void BuildBattlegroundListPacket(WorldPacket *data, ObjectGuid guid, Player *player, BattlegroundTypeId bgTypeId, uint8 fromWhere)
Definition BattlegroundMgr.cpp:584
void LoadBattleMastersEntry()
Definition BattlegroundMgr.cpp:803
std::map< BattlegroundTypeId, uint8 > BattlegroundSelectionWeightMap
Definition BattlegroundMgr.h:182
void AddToBGFreeSlotQueue(BattlegroundTypeId bgTypeId, Battleground *bg)
Definition BattlegroundMgr.cpp:949
BattlegroundMgr()
Definition BattlegroundMgr.cpp:63
void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId)
Definition BattlegroundMgr.cpp:973
bool SendToBattleground(Player *player, uint32 InstanceID, BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:650
std::vector< Battleground const * > GetActiveBattlegrounds()
Definition BattlegroundMgr.cpp:339
uint32 GetMaxRatingDifference() const
Definition BattlegroundMgr.cpp:781
std::map< BattlegroundTypeId, BattlegroundData > BattlegroundDataContainer
Definition BattlegroundMgr.h:151
void BuildBattlegroundStatusPacket(WorldPacket *data, Battleground *bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated=false, BattlegroundTypeId forceBgTypeId=BATTLEGROUND_TYPE_NONE)
Definition BattlegroundMgr.cpp:196
std::map< uint32, BattlegroundTemplate * > BattlegroundMapTemplateContainer
Definition BattlegroundMgr.h:185
BGFreeSlotQueueContainer & GetBGFreeSlotQueueStore(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:944
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition BattlegroundMgr.cpp:685
bool isArenaTesting() const
Definition BattlegroundMgr.h:111
BattlegroundQueue & GetBattlegroundQueue(BattlegroundQueueTypeId bgQueueTypeId)
Definition BattlegroundMgr.h:102
void ToggleArenaTesting()
Definition BattlegroundMgr.cpp:747
static BattlegroundTypeId BGTemplateId(BattlegroundQueueTypeId bgQueueTypeId)
Definition BattlegroundMgr.cpp:709
void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId)
Definition BattlegroundMgr.cpp:954
void BuildPlayerJoinedBattlegroundPacket(WorldPacket *data, Player *player)
Definition BattlegroundMgr.cpp:262
void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
Definition BattlegroundMgr.cpp:772
void BuildGroupJoinedBattlegroundPacket(WorldPacket *data, GroupJoinBattlegroundResult result)
Definition BattlegroundMgr.cpp:248
Battleground * CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const *bracketEntry, uint8 arenaType, bool isRated)
Definition BattlegroundMgr.cpp:379
void InitAutomaticArenaPointDistribution()
Definition BattlegroundMgr.cpp:561
void BuildPlayerLeftBattlegroundPacket(WorldPacket *data, ObjectGuid guid)
Definition BattlegroundMgr.cpp:256
void SetHolidayWeekends(uint32 mask)
Definition BattlegroundMgr.cpp:761
void ToggleTesting()
Definition BattlegroundMgr.cpp:733
uint32 GetRatingDiscardTimer() const
Definition BattlegroundMgr.cpp:793
static std::unordered_map< int, bgMapRef > getBgFromMap
Definition BattlegroundMgr.h:1048
static std::unordered_map< int, bgTypeRef > getBgFromTypeID
Definition BattlegroundMgr.h:1050
static BattlegroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday)
Definition BattlegroundMgr.cpp:888
BattlegroundTypeId GetBattleMasterBG(uint32 entry) const
Definition BattlegroundMgr.h:129
~BattlegroundMgr()
Definition BattlegroundMgr.cpp:72
uint32 GetPrematureFinishTime() const
Definition BattlegroundMgr.cpp:798
void SendAreaSpiritHealerQueryOpcode(Player *player, Battleground *bg, ObjectGuid guid)
Definition BattlegroundMgr.cpp:665
void Update(uint32 diff)
Definition BattlegroundMgr.cpp:100
bool isTesting() const
Definition BattlegroundMgr.h:112
static bool IsBGWeekend(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:909
void LoadBattlegroundTemplates()
Definition BattlegroundMgr.cpp:462
Definition BattlegroundQueue.h:68
Definition ObjectGuid.h:121
Definition Player.h:1086

Referenced by BGQueueTypeId().

◆ bgDataStore

◆ bgToQueue

std::unordered_map< int, BattlegroundQueueTypeId > BattlegroundMgr::bgToQueue
static
Initial value:
=
{
}
@ BATTLEGROUND_QUEUE_RB
Definition SharedDefines.h:3883
@ BATTLEGROUND_QUEUE_SA
Definition SharedDefines.h:3881
@ BATTLEGROUND_QUEUE_AB
Definition SharedDefines.h:3879
@ BATTLEGROUND_QUEUE_WS
Definition SharedDefines.h:3878
@ BATTLEGROUND_QUEUE_EY
Definition SharedDefines.h:3880
@ BATTLEGROUND_QUEUE_IC
Definition SharedDefines.h:3882
1018{
1019 BattlegroundContainer _Battlegrounds;
1020 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1021 BGFreeSlotQueueContainer BGFreeSlotQueue;
1022};
1023
1025{
1027 uint16 MinPlayersPerTeam;
1028 uint16 MaxPlayersPerTeam;
1029 uint8 MinLevel;
1030 uint8 MaxLevel;
1031 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1032 float MaxStartDistSq;
1033 uint8 Weight;
1034 uint32 ScriptId;
1035 BattlemasterListEntry const* BattlemasterEntry;
1036
1037 bool IsArena() const;
1038};
1039
1040class BattlegroundMgr
1041{
1042private:
1045
1046public:
1047 static BattlegroundMgr* instance();
1048
1049 void Update(uint32 diff);
1050
1051 /* Packet Building */
1054 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1056 void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE);
1058
1059 /* Battlegrounds */
1063 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1064 std::vector<Battleground const*> GetActiveBattlegrounds();
1065
1066 void AddBattleground(Battleground* bg);
1067 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1069 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1071
1074
1075 // Returns false when the teleport could not start (instance gone, or a
1076 // synchronous TeleportTo failure) so the accept path can release the
1077 // otherwise-orphaned invited reservation.
1078 bool SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1079
1080 /* Battleground queues */
1082 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1084
1085 void ToggleArenaTesting();
1086 void ToggleTesting();
1087
1088 void SetHolidayWeekends(uint32 mask);
1089
1090 bool isArenaTesting() const { return m_ArenaTesting; }
1091 bool isTesting() const { return m_Testing; }
1092
1095 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1096 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1097
1100 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1101
1106 void CheckBattleMasters();
1107
1109 {
1110 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1111 if (itr != mBattleMastersMap.end())
1112 return itr->second;
1114 }
1115
1116 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1117 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1118 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1119 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1120 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1121 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1122 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1123 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1124
1125private:
1126 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1129
1130 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1132
1134
1135 std::vector<uint64> m_QueueUpdateScheduler;
1136 bool m_ArenaTesting;
1137 bool m_Testing;
1142
1144 {
1145 auto const& itr = _battlegroundTemplates.find(id);
1146 if (itr != _battlegroundTemplates.end())
1147 return &itr->second;
1148
1149 return nullptr;
1150 }
1151
1153 {
1154 auto const& itr = _battlegroundMapTemplates.find(mapId);
1155 if (itr != _battlegroundMapTemplates.end())
1156 return itr->second;
1157
1158 return nullptr;
1159 }
1160
1161 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1162
1163 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1164 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1167};
1168
1169#define sBattlegroundMgr BattlegroundMgr::instance()
1170
1171#endif

Referenced by BGQueueTypeId().

◆ bgtypeToBattleground

std::unordered_map< int, Battleground * > BattlegroundMgr::bgtypeToBattleground
static
Initial value:
=
{
}
Definition BattlegroundAB.h:250
Definition BattlegroundAV.h:1758
Definition BattlegroundBE.h:45
Definition BattlegroundDS.h:92
Definition BattlegroundEY.h:350
Definition BattlegroundIC.h:891
Definition BattlegroundNA.h:45
Definition BattlegroundRL.h:41
Definition BattlegroundRV.h:79
Class for manage Strand of Ancient battleground.
Definition BattlegroundSA.h:428
Definition BattlegroundWS.h:209
1051{
1052 BattlegroundContainer _Battlegrounds;
1053 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1054 BGFreeSlotQueueContainer BGFreeSlotQueue;
1055};
1056
1058{
1060 uint16 MinPlayersPerTeam;
1061 uint16 MaxPlayersPerTeam;
1062 uint8 MinLevel;
1063 uint8 MaxLevel;
1064 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1065 float MaxStartDistSq;
1066 uint8 Weight;
1067 uint32 ScriptId;
1068 BattlemasterListEntry const* BattlemasterEntry;
1069
1070 bool IsArena() const;
1071};
1072
1073class BattlegroundMgr
1074{
1075private:
1078
1079public:
1080 static BattlegroundMgr* instance();
1081
1082 void Update(uint32 diff);
1083
1084 /* Packet Building */
1087 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1089 void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE);
1091
1092 /* Battlegrounds */
1096 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1097 std::vector<Battleground const*> GetActiveBattlegrounds();
1098
1099 void AddBattleground(Battleground* bg);
1100 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1102 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1104
1107
1108 // Returns false when the teleport could not start (instance gone, or a
1109 // synchronous TeleportTo failure) so the accept path can release the
1110 // otherwise-orphaned invited reservation.
1111 bool SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1112
1113 /* Battleground queues */
1115 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1117
1118 void ToggleArenaTesting();
1119 void ToggleTesting();
1120
1121 void SetHolidayWeekends(uint32 mask);
1122
1123 bool isArenaTesting() const { return m_ArenaTesting; }
1124 bool isTesting() const { return m_Testing; }
1125
1128 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1129 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1130
1133 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1134
1139 void CheckBattleMasters();
1140
1142 {
1143 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1144 if (itr != mBattleMastersMap.end())
1145 return itr->second;
1147 }
1148
1149 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1150 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1151 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1152 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1153 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1154 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1155 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1156 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1157
1158private:
1159 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1162
1163 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1165
1167
1168 std::vector<uint64> m_QueueUpdateScheduler;
1169 bool m_ArenaTesting;
1170 bool m_Testing;
1175
1177 {
1178 auto const& itr = _battlegroundTemplates.find(id);
1179 if (itr != _battlegroundTemplates.end())
1180 return &itr->second;
1181
1182 return nullptr;
1183 }
1184
1186 {
1187 auto const& itr = _battlegroundMapTemplates.find(mapId);
1188 if (itr != _battlegroundMapTemplates.end())
1189 return itr->second;
1190
1191 return nullptr;
1192 }
1193
1194 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1195
1196 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1197 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1200};
1201
1202#define sBattlegroundMgr BattlegroundMgr::instance()
1203
1204#endif

Referenced by CreateBattleground().

◆ bgTypeToTemplate

std::unordered_map< int, bgRef > BattlegroundMgr::bgTypeToTemplate
static
Initial value:
=
{
{ BATTLEGROUND_AV, [](Battleground * bg_t) -> Battleground* { return new BattlegroundAV(*(BattlegroundAV*)bg_t); } },
{ BATTLEGROUND_WS, [](Battleground * bg_t) -> Battleground* { return new BattlegroundWS(*(BattlegroundWS*)bg_t); } },
{ BATTLEGROUND_AB, [](Battleground * bg_t) -> Battleground* { return new BattlegroundAB(*(BattlegroundAB*)bg_t); } },
{ BATTLEGROUND_NA, [](Battleground * bg_t) -> Battleground* { return new BattlegroundNA(*(BattlegroundNA*)bg_t); } },
{ BATTLEGROUND_BE, [](Battleground * bg_t) -> Battleground* { return new BattlegroundBE(*(BattlegroundBE*)bg_t); } },
{ BATTLEGROUND_EY, [](Battleground * bg_t) -> Battleground* { return new BattlegroundEY(*(BattlegroundEY*)bg_t); } },
{ BATTLEGROUND_RL, [](Battleground * bg_t) -> Battleground* { return new BattlegroundRL(*(BattlegroundRL*)bg_t); } },
{ BATTLEGROUND_SA, [](Battleground * bg_t) -> Battleground* { return new BattlegroundSA(*(BattlegroundSA*)bg_t); } },
{ BATTLEGROUND_DS, [](Battleground * bg_t) -> Battleground* { return new BattlegroundDS(*(BattlegroundDS*)bg_t); } },
{ BATTLEGROUND_RV, [](Battleground * bg_t) -> Battleground* { return new BattlegroundRV(*(BattlegroundRV*)bg_t); } },
{ BATTLEGROUND_IC, [](Battleground * bg_t) -> Battleground* { return new BattlegroundIC(*(BattlegroundIC*)bg_t); } },
{ BATTLEGROUND_RB, [](Battleground * bg_t) -> Battleground* { return new Battleground(*bg_t); }, },
{ BATTLEGROUND_AA, [](Battleground * bg_t) -> Battleground* { return new Battleground(*bg_t); }, },
}
1068{
1069 BattlegroundContainer _Battlegrounds;
1070 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1071 BGFreeSlotQueueContainer BGFreeSlotQueue;
1072};
1073
1075{
1077 uint16 MinPlayersPerTeam;
1078 uint16 MaxPlayersPerTeam;
1079 uint8 MinLevel;
1080 uint8 MaxLevel;
1081 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1082 float MaxStartDistSq;
1083 uint8 Weight;
1084 uint32 ScriptId;
1085 BattlemasterListEntry const* BattlemasterEntry;
1086
1087 bool IsArena() const;
1088};
1089
1090class BattlegroundMgr
1091{
1092private:
1095
1096public:
1097 static BattlegroundMgr* instance();
1098
1099 void Update(uint32 diff);
1100
1101 /* Packet Building */
1104 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1106 void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE);
1108
1109 /* Battlegrounds */
1113 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1114 std::vector<Battleground const*> GetActiveBattlegrounds();
1115
1116 void AddBattleground(Battleground* bg);
1117 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1119 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1121
1124
1125 // Returns false when the teleport could not start (instance gone, or a
1126 // synchronous TeleportTo failure) so the accept path can release the
1127 // otherwise-orphaned invited reservation.
1128 bool SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1129
1130 /* Battleground queues */
1132 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1134
1135 void ToggleArenaTesting();
1136 void ToggleTesting();
1137
1138 void SetHolidayWeekends(uint32 mask);
1139
1140 bool isArenaTesting() const { return m_ArenaTesting; }
1141 bool isTesting() const { return m_Testing; }
1142
1145 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1146 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1147
1150 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1151
1156 void CheckBattleMasters();
1157
1159 {
1160 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1161 if (itr != mBattleMastersMap.end())
1162 return itr->second;
1164 }
1165
1166 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1167 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1168 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1169 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1170 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1171 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1172 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1173 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1174
1175private:
1176 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1179
1180 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1182
1184
1185 std::vector<uint64> m_QueueUpdateScheduler;
1186 bool m_ArenaTesting;
1187 bool m_Testing;
1192
1194 {
1195 auto const& itr = _battlegroundTemplates.find(id);
1196 if (itr != _battlegroundTemplates.end())
1197 return &itr->second;
1198
1199 return nullptr;
1200 }
1201
1203 {
1204 auto const& itr = _battlegroundMapTemplates.find(mapId);
1205 if (itr != _battlegroundMapTemplates.end())
1206 return itr->second;
1207
1208 return nullptr;
1209 }
1210
1211 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1212
1213 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1214 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1217};
1218
1219#define sBattlegroundMgr BattlegroundMgr::instance()
1220
1221#endif

Referenced by CreateNewBattleground().

◆ getBgFromMap

std::unordered_map< int, bgMapRef > BattlegroundMgr::getBgFromMap = {}
static
1086{
1087 BattlegroundContainer _Battlegrounds;
1088 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1089 BGFreeSlotQueueContainer BGFreeSlotQueue;
1090};
1091
1093{
1095 uint16 MinPlayersPerTeam;
1096 uint16 MaxPlayersPerTeam;
1097 uint8 MinLevel;
1098 uint8 MaxLevel;
1099 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1100 float MaxStartDistSq;
1101 uint8 Weight;
1102 uint32 ScriptId;
1103 BattlemasterListEntry const* BattlemasterEntry;
1104
1105 bool IsArena() const;
1106};
1107
1108class BattlegroundMgr
1109{
1110private:
1113
1114public:
1115 static BattlegroundMgr* instance();
1116
1117 void Update(uint32 diff);
1118
1119 /* Packet Building */
1122 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1124 void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE);
1126
1127 /* Battlegrounds */
1131 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1132 std::vector<Battleground const*> GetActiveBattlegrounds();
1133
1134 void AddBattleground(Battleground* bg);
1135 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1137 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1139
1142
1143 // Returns false when the teleport could not start (instance gone, or a
1144 // synchronous TeleportTo failure) so the accept path can release the
1145 // otherwise-orphaned invited reservation.
1146 bool SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1147
1148 /* Battleground queues */
1150 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1152
1153 void ToggleArenaTesting();
1154 void ToggleTesting();
1155
1156 void SetHolidayWeekends(uint32 mask);
1157
1158 bool isArenaTesting() const { return m_ArenaTesting; }
1159 bool isTesting() const { return m_Testing; }
1160
1163 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1164 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1165
1168 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1169
1174 void CheckBattleMasters();
1175
1177 {
1178 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1179 if (itr != mBattleMastersMap.end())
1180 return itr->second;
1182 }
1183
1184 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1185 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1186 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1187 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1188 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1189 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1190 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1191 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1192
1193private:
1194 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1197
1198 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1200
1202
1203 std::vector<uint64> m_QueueUpdateScheduler;
1204 bool m_ArenaTesting;
1205 bool m_Testing;
1210
1212 {
1213 auto const& itr = _battlegroundTemplates.find(id);
1214 if (itr != _battlegroundTemplates.end())
1215 return &itr->second;
1216
1217 return nullptr;
1218 }
1219
1221 {
1222 auto const& itr = _battlegroundMapTemplates.find(mapId);
1223 if (itr != _battlegroundMapTemplates.end())
1224 return itr->second;
1225
1226 return nullptr;
1227 }
1228
1229 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1230
1231 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1232 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1235};
1236
1237#define sBattlegroundMgr BattlegroundMgr::instance()
1238
1239#endif

◆ getBgFromTypeID

std::unordered_map< int, bgTypeRef > BattlegroundMgr::getBgFromTypeID
static
Initial value:
=
{
{
[](WorldPacket * data, Battleground::BattlegroundScoreMap::const_iterator itr2, Battleground * bg)
{
{
*data << uint32(0);
}
else
{
BattlegroundMgr::getBgFromMap[bg->GetMapId()](data, itr2);
}
}
}
}
1088{
1089 BattlegroundContainer _Battlegrounds;
1090 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1091 BGFreeSlotQueueContainer BGFreeSlotQueue;
1092};
1093
1095{
1097 uint16 MinPlayersPerTeam;
1098 uint16 MaxPlayersPerTeam;
1099 uint8 MinLevel;
1100 uint8 MaxLevel;
1101 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1102 float MaxStartDistSq;
1103 uint8 Weight;
1104 uint32 ScriptId;
1105 BattlemasterListEntry const* BattlemasterEntry;
1106
1107 bool IsArena() const;
1108};
1109
1110class BattlegroundMgr
1111{
1112private:
1115
1116public:
1117 static BattlegroundMgr* instance();
1118
1119 void Update(uint32 diff);
1120
1121 /* Packet Building */
1124 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1126 void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE);
1128
1129 /* Battlegrounds */
1133 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1134 std::vector<Battleground const*> GetActiveBattlegrounds();
1135
1136 void AddBattleground(Battleground* bg);
1137 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1139 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1141
1144
1145 // Returns false when the teleport could not start (instance gone, or a
1146 // synchronous TeleportTo failure) so the accept path can release the
1147 // otherwise-orphaned invited reservation.
1148 bool SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1149
1150 /* Battleground queues */
1152 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1154
1155 void ToggleArenaTesting();
1156 void ToggleTesting();
1157
1158 void SetHolidayWeekends(uint32 mask);
1159
1160 bool isArenaTesting() const { return m_ArenaTesting; }
1161 bool isTesting() const { return m_Testing; }
1162
1165 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1166 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1167
1170 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1171
1176 void CheckBattleMasters();
1177
1179 {
1180 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1181 if (itr != mBattleMastersMap.end())
1182 return itr->second;
1184 }
1185
1186 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1187 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1188 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1189 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1190 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1191 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1192 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1193 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1194
1195private:
1196 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1199
1200 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1202
1204
1205 std::vector<uint64> m_QueueUpdateScheduler;
1206 bool m_ArenaTesting;
1207 bool m_Testing;
1212
1214 {
1215 auto const& itr = _battlegroundTemplates.find(id);
1216 if (itr != _battlegroundTemplates.end())
1217 return &itr->second;
1218
1219 return nullptr;
1220 }
1221
1223 {
1224 auto const& itr = _battlegroundMapTemplates.find(mapId);
1225 if (itr != _battlegroundMapTemplates.end())
1226 return itr->second;
1227
1228 return nullptr;
1229 }
1230
1231 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1232
1233 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1234 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1237};
1238
1239#define sBattlegroundMgr BattlegroundMgr::instance()
1240
1241#endif

◆ m_ArenaTesting

bool BattlegroundMgr::m_ArenaTesting
private

◆ m_AutoDistributionTimeChecker

uint32 BattlegroundMgr::m_AutoDistributionTimeChecker
private

Referenced by Update().

◆ m_BattlegroundQueues

BattlegroundQueue BattlegroundMgr::m_BattlegroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES]
private

Referenced by GetBattlegroundQueue(), and Update().

◆ m_NextAutoDistributionTime

Seconds BattlegroundMgr::m_NextAutoDistributionTime
private

◆ m_NextPeriodicQueueUpdateTime

uint32 BattlegroundMgr::m_NextPeriodicQueueUpdateTime
private

Referenced by Update().

◆ m_QueueUpdateScheduler

std::vector<uint64> BattlegroundMgr::m_QueueUpdateScheduler
private

Referenced by ScheduleQueueUpdate(), and Update().

◆ m_Testing

bool BattlegroundMgr::m_Testing
private

Referenced by isTesting(), and ToggleTesting().

◆ mBattleMastersMap

BattleMastersMap BattlegroundMgr::mBattleMastersMap
private

◆ QueueToArenaType

std::unordered_map< uint32, ArenaType > BattlegroundMgr::QueueToArenaType
static
Initial value:
1113{
1114 BattlegroundContainer _Battlegrounds;
1115 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1116 BGFreeSlotQueueContainer BGFreeSlotQueue;
1117};
1118
1120{
1122 uint16 MinPlayersPerTeam;
1123 uint16 MaxPlayersPerTeam;
1124 uint8 MinLevel;
1125 uint8 MaxLevel;
1126 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1127 float MaxStartDistSq;
1128 uint8 Weight;
1129 uint32 ScriptId;
1130 BattlemasterListEntry const* BattlemasterEntry;
1131
1132 bool IsArena() const;
1133};
1134
1135class BattlegroundMgr
1136{
1137private:
1140
1141public:
1142 static BattlegroundMgr* instance();
1143
1144 void Update(uint32 diff);
1145
1146 /* Packet Building */
1149 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1151 void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE);
1153
1154 /* Battlegrounds */
1158 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1159 std::vector<Battleground const*> GetActiveBattlegrounds();
1160
1161 void AddBattleground(Battleground* bg);
1162 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1164 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1166
1169
1170 // Returns false when the teleport could not start (instance gone, or a
1171 // synchronous TeleportTo failure) so the accept path can release the
1172 // otherwise-orphaned invited reservation.
1173 bool SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1174
1175 /* Battleground queues */
1177 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1179
1180 void ToggleArenaTesting();
1181 void ToggleTesting();
1182
1183 void SetHolidayWeekends(uint32 mask);
1184
1185 bool isArenaTesting() const { return m_ArenaTesting; }
1186 bool isTesting() const { return m_Testing; }
1187
1190 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1191 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1192
1195 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1196
1201 void CheckBattleMasters();
1202
1204 {
1205 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1206 if (itr != mBattleMastersMap.end())
1207 return itr->second;
1209 }
1210
1211 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1212 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1213 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1214 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1215 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1216 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1217 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1218 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1219
1220private:
1221 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1224
1225 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1227
1229
1230 std::vector<uint64> m_QueueUpdateScheduler;
1231 bool m_ArenaTesting;
1232 bool m_Testing;
1237
1239 {
1240 auto const& itr = _battlegroundTemplates.find(id);
1241 if (itr != _battlegroundTemplates.end())
1242 return &itr->second;
1243
1244 return nullptr;
1245 }
1246
1248 {
1249 auto const& itr = _battlegroundMapTemplates.find(mapId);
1250 if (itr != _battlegroundMapTemplates.end())
1251 return itr->second;
1252
1253 return nullptr;
1254 }
1255
1256 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1257
1258 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1259 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1262};
1263
1264#define sBattlegroundMgr BattlegroundMgr::instance()
1265
1266#endif

Referenced by BGArenaType().

◆ queueToBg

std::unordered_map< int, BattlegroundTypeId > BattlegroundMgr::queueToBg
static
Initial value:
1036{
1037 BattlegroundContainer _Battlegrounds;
1038 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1039 BGFreeSlotQueueContainer BGFreeSlotQueue;
1040};
1041
1043{
1045 uint16 MinPlayersPerTeam;
1046 uint16 MaxPlayersPerTeam;
1047 uint8 MinLevel;
1048 uint8 MaxLevel;
1049 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1050 float MaxStartDistSq;
1051 uint8 Weight;
1052 uint32 ScriptId;
1053 BattlemasterListEntry const* BattlemasterEntry;
1054
1055 bool IsArena() const;
1056};
1057
1058class BattlegroundMgr
1059{
1060private:
1063
1064public:
1065 static BattlegroundMgr* instance();
1066
1067 void Update(uint32 diff);
1068
1069 /* Packet Building */
1072 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1074 void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE);
1076
1077 /* Battlegrounds */
1081 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1082 std::vector<Battleground const*> GetActiveBattlegrounds();
1083
1084 void AddBattleground(Battleground* bg);
1085 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1087 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1089
1092
1093 // Returns false when the teleport could not start (instance gone, or a
1094 // synchronous TeleportTo failure) so the accept path can release the
1095 // otherwise-orphaned invited reservation.
1096 bool SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1097
1098 /* Battleground queues */
1100 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1102
1103 void ToggleArenaTesting();
1104 void ToggleTesting();
1105
1106 void SetHolidayWeekends(uint32 mask);
1107
1108 bool isArenaTesting() const { return m_ArenaTesting; }
1109 bool isTesting() const { return m_Testing; }
1110
1113 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1114 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1115
1118 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1119
1124 void CheckBattleMasters();
1125
1127 {
1128 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1129 if (itr != mBattleMastersMap.end())
1130 return itr->second;
1132 }
1133
1134 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1135 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1136 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1137 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1138 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1139 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1140 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1141 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1142
1143private:
1144 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1147
1148 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1150
1152
1153 std::vector<uint64> m_QueueUpdateScheduler;
1154 bool m_ArenaTesting;
1155 bool m_Testing;
1160
1162 {
1163 auto const& itr = _battlegroundTemplates.find(id);
1164 if (itr != _battlegroundTemplates.end())
1165 return &itr->second;
1166
1167 return nullptr;
1168 }
1169
1171 {
1172 auto const& itr = _battlegroundMapTemplates.find(mapId);
1173 if (itr != _battlegroundMapTemplates.end())
1174 return itr->second;
1175
1176 return nullptr;
1177 }
1178
1179 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1180
1181 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1182 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1185};
1186
1187#define sBattlegroundMgr BattlegroundMgr::instance()
1188
1189#endif

Referenced by BGTemplateId().


The documentation for this class was generated from the following files: