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 ()
 
void 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
62 :
63 m_ArenaTesting(false),
64 m_Testing(false),
68{
69}
constexpr auto IN_MILLISECONDS
Definition Common.h:53
bool m_ArenaTesting
Definition BattlegroundMgr.h:154
uint32 m_AutoDistributionTimeChecker
Definition BattlegroundMgr.h:157
Seconds m_NextAutoDistributionTime
Definition BattlegroundMgr.h:156
uint32 m_NextPeriodicQueueUpdateTime
Definition BattlegroundMgr.h:158
bool m_Testing
Definition BattlegroundMgr.h:155

◆ ~BattlegroundMgr()

BattlegroundMgr::~BattlegroundMgr ( )
private
72{
74}
void DeleteAllBattlegrounds()
Definition BattlegroundMgr.cpp:82

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:727
BattlegroundDataContainer bgDataStore
Definition BattlegroundMgr.h:149
uint32 GetInstanceID() const
Definition Battleground.h:332
BattlegroundTypeId GetBgTypeID(bool GetRandom=false) const
Definition Battleground.h:330

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_front(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:3619
@ BATTLEGROUND_QUEUE_NONE
Definition SharedDefines.h:3620
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(), 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:3479
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:3492
@ BATTLEGROUND_WS
Definition SharedDefines.h:3482
@ BATTLEGROUND_EY
Definition SharedDefines.h:3487
@ BATTLEGROUND_AV
Definition SharedDefines.h:3481
@ BATTLEGROUND_SA
Definition SharedDefines.h:3489
@ BATTLEGROUND_AB
Definition SharedDefines.h:3483
@ HOLIDAY_NONE
Definition SharedDefines.h:2742
@ HOLIDAY_CALL_TO_ARMS_AB
Definition SharedDefines.h:2750
@ HOLIDAY_CALL_TO_ARMS_EY
Definition SharedDefines.h:2757
@ HOLIDAY_CALL_TO_ARMS_SA
Definition SharedDefines.h:2763
@ HOLIDAY_CALL_TO_ARMS_IC
Definition SharedDefines.h:2767
@ HOLIDAY_CALL_TO_ARMS_AV
Definition SharedDefines.h:2748
@ HOLIDAY_CALL_TO_ARMS_WS
Definition SharedDefines.h:2749

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

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 
)
196{
197 // pussywizard:
198 //ASSERT(QueueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES);
199
200 if (StatusID == STATUS_NONE || !bg)
201 {
203 *data << uint32(QueueSlot);
204 *data << uint64(0);
205 return;
206 }
207
208 data->Initialize(SMSG_BATTLEFIELD_STATUS, (4 + 8 + 1 + 1 + 4 + 1 + 4 + 4 + 4));
209 *data << uint32(QueueSlot);
210 // The following segment is read as uint64 in client but can be appended as their original type.
211 *data << uint8(arenatype);
212 *data << uint8(bg->isArena() ? 0xE : 0x0);
213 *data << uint32(forceBgTypeId != BATTLEGROUND_TYPE_NONE ? forceBgTypeId : bg->GetBgTypeID());
214 *data << uint16(0x1F90);
215 // End of uint64 segment, decomposed this way for simplicity
216 *data << uint8(bg->GetMinLevel());
217 *data << uint8(bg->GetMaxLevel());
218 *data << uint32(bg->GetClientInstanceID());
219
220 // following displays the minimap icon. 0 = faction icon, 1 = arenaicon
221 *data << uint8(bg->isRated() || isRated); // 1 for rated match, 0 for bg or non rated match
222
223 *data << uint32(StatusID); // status
224 switch (StatusID)
225 {
226 case STATUS_WAIT_QUEUE: // status_in_queue
227 *data << uint32(Time1); // average wait time, milliseconds
228 *data << uint32(Time2); // time in queue, updated every minute!, milliseconds
229 break;
230 case STATUS_WAIT_JOIN: // status_invite
231 *data << uint32(bg->GetMapId()); // map id
232 *data << uint64(0); // 3.3.5, unknown
233 *data << uint32(Time1); // time to remove from queue, milliseconds
234 break;
235 case STATUS_IN_PROGRESS: // status_in_progress
236 *data << uint32(bg->GetMapId()); // map id
237 *data << uint64(0); // 3.3.5, unknown
238 *data << uint32(Time1); // time to bg auto leave, 0 at bg start, 120000 after bg end, milliseconds
239 *data << uint32(Time2); // time from bg start, milliseconds
240 *data << uint8(teamId == TEAM_ALLIANCE ? 1 : 0); // arenafaction (0 for horde, 1 for alliance)
241 break;
242 default:
243 break;
244 }
245}
@ STATUS_WAIT_QUEUE
Definition Battleground.h:201
@ STATUS_NONE
Definition Battleground.h:200
@ STATUS_WAIT_JOIN
Definition Battleground.h:202
@ STATUS_IN_PROGRESS
Definition Battleground.h:203
std::uint64_t uint64
Definition Define.h:106
std::uint16_t uint16
Definition Define.h:108
@ BATTLEGROUND_TYPE_NONE
Definition SharedDefines.h:3480
@ TEAM_ALLIANCE
Definition SharedDefines.h:760
uint32 GetMapId() const
Definition Battleground.h:446
uint32 GetMinLevel() const
Definition Battleground.h:339
bool isRated() const
Definition Battleground.h:416
uint32 GetClientInstanceID() const
Definition Battleground.h:334
bool isArena() const
Definition Battleground.h:414
uint32 GetMaxLevel() const
Definition Battleground.h:340
@ 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 
)
248{
250 *data << int32(result);
252 *data << uint64(0); // player guid
253}
std::int32_t int32
Definition Define.h:103
@ ERR_BATTLEGROUND_JOIN_TIMED_OUT
Definition SharedDefines.h:3648
@ ERR_BATTLEGROUND_JOIN_FAILED
Definition SharedDefines.h:3649
@ 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 
)
262{
264 *data << player->GetGUID();
265}
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:112
@ 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 
)
256{
258 *data << guid;
259}
@ 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:292
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
#define sObjectMgr
Definition ObjectMgr.h:1636
@ UNIT_NPC_FLAG_BATTLEMASTER
Definition UnitDefines.h:335
BattleMastersMap mBattleMastersMap
Definition BattlegroundMgr.h:159
Definition CreatureData.h:186

References LOG_ERROR, mBattleMastersMap, sObjectMgr, and UNIT_NPC_FLAG_BATTLEMASTER.

Referenced by LoadBattleMastersEntry().

◆ CreateBattleground()

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

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
351{
352 if (IsArenaType(bgTypeId))
353 return 0; // arenas don't have client-instanceids
354
355 // we create here an instanceid, which is just for
356 // displaying this to the client and without any other use..
357 // the client-instanceIds are unique for each battleground-type
358 // the instance-id just needs to be as low as possible, beginning with 1
359 // the following works, because std::set is default ordered with "<"
360 // the optimalization would be to use as bitmask std::vector<uint32> - but that would only make code unreadable
361
362 BattlegroundClientIdsContainer& clientIds = bgDataStore[bgTypeId]._ClientBattlegroundIds[bracket_id];
363 uint32 lastId = 0;
364
365 for (BattlegroundClientIdsContainer::const_iterator itr = clientIds.begin(); itr != clientIds.end();)
366 {
367 if ((++lastId) != *itr) // if there is a gap between the ids, we will break..
368 break;
369
370 lastId = *itr;
371 }
372
373 clientIds.emplace(++lastId);
374 return lastId;
375}
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 
)
379{
380 BattlegroundTypeId bgTypeId = GetRandomBG(originalBgTypeId, bracketEntry->minLevel);
381
382 if (originalBgTypeId == BATTLEGROUND_AA)
383 originalBgTypeId = bgTypeId;
384
385 // get the template BG
386 Battleground* bg_template = GetBattlegroundTemplate(bgTypeId);
387 if (!bg_template)
388 {
389 LOG_ERROR("bg.battleground", "Battleground: CreateNewBattleground - bg template not found for {}", bgTypeId);
390 return nullptr;
391 }
392
393 Battleground* bg = nullptr;
394
395 // create a copy of the BG template
397 {
398 return nullptr;
399 }
400
401 bg = BattlegroundMgr::bgTypeToTemplate[bgTypeId](bg_template);
402
403 bool isRandom = bgTypeId != originalBgTypeId && !bg->isArena();
404
405 bg->SetBracket(bracketEntry);
406 bg->SetInstanceID(sMapMgr->GenerateInstanceId());
407 bg->SetClientInstanceID(CreateClientVisibleInstanceId(originalBgTypeId, bracketEntry->GetBracketId()));
408 bg->Init();
409 bg->SetStatus(STATUS_WAIT_JOIN); // start the joining of the bg
410 bg->SetArenaType(arenaType);
411 bg->SetBgTypeID(originalBgTypeId);
412 bg->SetRandomTypeID(bgTypeId);
413 bg->SetRated(isRated);
414 bg->SetRandom(isRandom);
415
416 // Set up correct min/max player counts for scoreboards
417 if (bg->isArena())
418 {
419 uint32 maxPlayersPerTeam = ArenaTeam::GetReqPlayersForType(arenaType) / 2;
420 sScriptMgr->OnSetArenaMaxPlayersPerTeam(arenaType, maxPlayersPerTeam);
421 bg->SetMaxPlayersPerTeam(maxPlayersPerTeam);
422 }
423
424 return bg;
425}
#define sMapMgr
Definition MapMgr.h:220
static uint8 GetReqPlayersForType(uint32 type)
Definition ArenaTeam.cpp:1022
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:350
void SetBracket(PvPDifficultyEntry const *bracketEntry)
Definition Battleground.cpp:1821
void SetRated(bool state)
Definition Battleground.h:380
virtual void Init()
Definition Battleground.cpp:1070
void SetClientInstanceID(uint32 InstanceID)
Definition Battleground.h:375
void SetStatus(BattlegroundStatus Status)
Definition Battleground.h:374
void SetArenaType(uint8 type)
Definition Battleground.h:381
void SetRandomTypeID(BattlegroundTypeId TypeID)
Definition Battleground.h:371

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 ( )
83{
84 for (auto& [_, data] : bgDataStore)
85 {
86 while (!data._Battlegrounds.empty())
87 delete data._Battlegrounds.begin()->second;
88
89 data._Battlegrounds.clear();
90
91 while (!data.BGFreeSlotQueue.empty())
92 delete data.BGFreeSlotQueue.front();
93 }
94
95 bgDataStore.clear();
96}

References bgDataStore.

Referenced by ~BattlegroundMgr().

◆ GetActiveBattlegrounds()

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

References bgDataStore, STATUS_IN_PROGRESS, and STATUS_WAIT_JOIN.

◆ GetBattleground()

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

References BATTLEGROUND_TYPE_NONE, and bgDataStore.

Referenced by GetBattlegroundThroughClientInstance(), and SendToBattleground().

◆ GetBattlegroundQueue()

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

References m_BattlegroundQueues.

◆ GetBattlegroundTemplate()

Battleground * BattlegroundMgr::GetBattlegroundTemplate ( BattlegroundTypeId  bgTypeId)
327{
328 BattlegroundDataContainer::const_iterator itr = bgDataStore.find(bgTypeId);
329 if (itr == bgDataStore.end())
330 return nullptr;
331
332 BattlegroundContainer const& bgs = itr->second._Battlegrounds;
333
334 // map is sorted and we can be sure that lowest instance id has only BG template
335 return bgs.empty() ? nullptr : bgs.begin()->second;
336}
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
171 {
172 auto const& itr = _battlegroundMapTemplates.find(mapId);
173 if (itr != _battlegroundMapTemplates.end())
174 return itr->second;
175
176 return nullptr;
177 }
BattlegroundMapTemplateContainer _battlegroundMapTemplates
Definition BattlegroundMgr.h:184

References _battlegroundMapTemplates.

Referenced by GetRandomBG().

◆ GetBattlegroundTemplateByTypeId()

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

References _battlegroundTemplates.

Referenced by GetRandomBG().

◆ GetBattlegroundThroughClientInstance()

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

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

◆ GetBattleMasterBG()

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

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 IWorld.h:327

References CONFIG_ARENA_MAX_RATING_DIFFERENCE, and sWorld.

◆ GetPrematureFinishTime()

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

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:170
BattlegroundTemplate const * GetBattlegroundTemplateByTypeId(BattlegroundTypeId id)
Definition BattlegroundMgr.h:161
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 IWorld.h:328

References CONFIG_ARENA_RATING_DISCARD_TIMER, and sWorld.

◆ InitAutomaticArenaPointDistribution()

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

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

◆ instance()

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

References instance().

Referenced by instance().

◆ isArenaTesting()

bool BattlegroundMgr::isArenaTesting ( ) const
inline
108{ 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:3485
@ BATTLEGROUND_RV
Definition SharedDefines.h:3491
@ BATTLEGROUND_NA
Definition SharedDefines.h:3484
@ BATTLEGROUND_DS
Definition SharedDefines.h:3490
@ BATTLEGROUND_RL
Definition SharedDefines.h:3488

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:1949
static HolidayIds BGTypeToWeekendHolidayId(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:867

References BGTypeToWeekendHolidayId(), and IsHolidayActive().

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

◆ isTesting()

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

References m_Testing.

◆ LoadBattlegroundTemplates()

void BattlegroundMgr::LoadBattlegroundTemplates ( )
462{
463 uint32 oldMSTime = getMSTime();
464
467
468 // 0 1 2 3 4 5 6 7 8 9 10 11
469 QueryResult result = WorldDatabase.Query("SELECT ID, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, AllianceStartLoc, AllianceStartO, HordeStartLoc, HordeStartO, StartMaxDist, Weight, ScriptName FROM battleground_template");
470
471 if (!result)
472 {
473 LOG_ERROR("bg.battleground", ">> Loaded 0 battlegrounds. DB table `battleground_template` is empty.");
474 return;
475 }
476
477 do
478 {
479 Field* fields = result->Fetch();
480
481 BattlegroundTypeId bgTypeId = static_cast<BattlegroundTypeId>(fields[0].Get<uint32>());
482
483 if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId, nullptr))
484 continue;
485
486 // can be overwrite by values from DB
487 BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId);
488 if (!bl)
489 {
490 LOG_ERROR("bg.battleground", "Battleground ID {} not found in BattlemasterList.dbc. Battleground not created.", bgTypeId);
491 continue;
492 }
493
494 BattlegroundTemplate bgTemplate;
495 bgTemplate.Id = bgTypeId;
496 bgTemplate.MinPlayersPerTeam = fields[1].Get<uint16>();
497 bgTemplate.MaxPlayersPerTeam = fields[2].Get<uint16>();
498 bgTemplate.MinLevel = fields[3].Get<uint8>();
499 bgTemplate.MaxLevel = fields[4].Get<uint8>();
500 float dist = fields[9].Get<float>();
501 bgTemplate.MaxStartDistSq = dist * dist;
502 bgTemplate.Weight = fields[10].Get<uint8>();
503 bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[11].Get<std::string>());
504 bgTemplate.BattlemasterEntry = bl;
505
506 if (bgTemplate.MaxPlayersPerTeam == 0 || bgTemplate.MinPlayersPerTeam > bgTemplate.MaxPlayersPerTeam)
507 {
508 LOG_ERROR("sql.sql", "Table `battleground_template` for id {} contains bad values for MinPlayersPerTeam ({}) and MaxPlayersPerTeam({}).",
509 bgTemplate.Id, bgTemplate.MinPlayersPerTeam, bgTemplate.MaxPlayersPerTeam);
510
511 continue;
512 }
513
514 if (bgTemplate.MinLevel == 0 || bgTemplate.MaxLevel == 0 || bgTemplate.MinLevel > bgTemplate.MaxLevel)
515 {
516 LOG_ERROR("sql.sql", "Table `battleground_template` for id {} has bad values for LevelMin ({}) and LevelMax({})",
517 bgTemplate.Id, bgTemplate.MinLevel, bgTemplate.MaxLevel);
518 continue;
519 }
520
521 if (bgTemplate.Id != BATTLEGROUND_AA && bgTemplate.Id != BATTLEGROUND_RB)
522 {
523 uint32 startId = fields[5].Get<uint32>();
524 if (GraveyardStruct const* start = sGraveyard->GetGraveyard(startId))
525 {
526 bgTemplate.StartLocation[TEAM_ALLIANCE].Relocate(start->x, start->y, start->z, fields[6].Get<float>());
527 }
528 else
529 {
530 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);
531 continue;
532 }
533
534 startId = fields[7].Get<uint32>();
535 if (GraveyardStruct const* start = sGraveyard->GetGraveyard(startId))
536 {
537 bgTemplate.StartLocation[TEAM_HORDE].Relocate(start->x, start->y, start->z, fields[8].Get<float>());
538 }
539 else
540 {
541 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);
542 continue;
543 }
544 }
545
546 if (!CreateBattleground(&bgTemplate))
547 continue;
548
549 _battlegroundTemplates[bgTypeId] = bgTemplate;
550
551 if (bgTemplate.BattlemasterEntry->mapid[1] == -1) // in this case we have only one mapId
553
554 } while (result->NextRow());
555
556 LOG_INFO("server.loading", ">> Loaded {} battlegrounds in {} ms", _battlegroundTemplates.size(), GetMSTimeDiffToNow(oldMSTime));
557 LOG_INFO("server.loading", " ");
558}
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:428
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:603
int32 mapid[8]
Definition DBCStructure.h:605
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:161
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:153

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->GetSession()->SendPacket(&data);
673}
#define RESURRECTION_INTERVAL
Definition Battleground.h:173
uint32 GetLastResurrectTime() const
Definition Battleground.h:337
WorldSession * GetSession() const
Definition Player.h:2005
Definition WorldPacket.h:26
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition WorldSession.cpp:226
@ SMSG_AREA_SPIRIT_HEALER_TIME
Definition Opcodes.h:770

References Battleground::GetLastResurrectTime(), Player::GetSession(), RESURRECTION_INTERVAL, WorldSession::SendPacket(), and SMSG_AREA_SPIRIT_HEALER_TIME.

◆ SendToBattleground()

void BattlegroundMgr::SendToBattleground ( Player player,
uint32  InstanceID,
BattlegroundTypeId  bgTypeId 
)
650{
651 if (Battleground* bg = GetBattleground(instanceId, bgTypeId))
652 {
653 uint32 mapid = bg->GetMapId();
654 Position const* pos = bg->GetTeamStartPosition(player->GetBgTeamId());
655
656 LOG_DEBUG("bg.battleground", "BattlegroundMgr::SendToBattleground: Sending {} to map {}, {} (bgType {})", player->GetName(), mapid, pos->ToString(), bgTypeId);
657 player->TeleportTo(mapid, pos->GetPositionX(), pos->GetPositionY(), pos->GetPositionZ(), pos->GetOrientation());
658 }
659 else
660 {
661 LOG_ERROR("bg.battleground", "BattlegroundMgr::SendToBattleground: Instance {} (bgType {}) not found while trying to teleport player {}", instanceId, bgTypeId, player->GetName());
662 }
663}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:169
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1338
TeamId GetBgTeamId() const
Definition Player.h:2286
std::string const & GetName() const
Definition Object.h:463
Definition Position.h:27
std::string ToString() const
Definition Position.cpp:52
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:3496

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}
@ CONFIG_DEBUG_ARENA
Definition IWorld.h:161
@ LANG_DEBUG_ARENA_OFF
Definition Language.h:710
@ LANG_DEBUG_ARENA_ON
Definition Language.h:709
@ LANG_DEBUG_ARENA_CONF
Definition Language.h:1330
Definition Chat.h:37
void SendWorldText(std::string_view str)
Definition Chat.cpp:131

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}
@ CONFIG_DEBUG_BATTLEGROUND
Definition IWorld.h:160
@ LANG_DEBUG_BG_OFF
Definition Language.h:712
@ LANG_DEBUG_BG_CONF
Definition Language.h:1329
@ LANG_DEBUG_BG_ON
Definition Language.h:711

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)
100{
101 // update all battlegrounds and delete if needed
102 for (auto& [_, bgData] : bgDataStore)
103 {
104 auto& bgList = bgData._Battlegrounds;
105 auto itrDelete = bgList.begin();
106
107 // first one is template and should not be deleted
108 for (BattlegroundContainer::iterator itr = ++itrDelete; itr != bgList.end();)
109 {
110 itrDelete = itr++;
111 Battleground* bg = itrDelete->second;
112
113 bg->Update(diff);
114 if (bg->ToBeDeleted())
115 {
116 itrDelete->second = nullptr;
117 bgList.erase(itrDelete);
118
119 BattlegroundClientIdsContainer& clients = bgData._ClientBattlegroundIds[bg->GetBracketId()];
120 if (!clients.empty())
121 clients.erase(bg->GetClientInstanceID());
122
123 delete bg;
124 }
125 }
126 }
127
128 // update events
129 for (uint8 qtype = BATTLEGROUND_QUEUE_NONE; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
130 m_BattlegroundQueues[qtype].UpdateEvents(diff);
131
132 // update using scheduled tasks (used only for rated arenas, initial opponent search works differently than periodic queue update)
133 if (!m_QueueUpdateScheduler.empty())
134 {
135 std::vector<uint64> scheduled;
136 std::swap(scheduled, m_QueueUpdateScheduler);
137
138 for (uint8 i = 0; i < scheduled.size(); i++)
139 {
140 uint32 arenaMMRating = scheduled[i] >> 32;
141 uint8 arenaType = scheduled[i] >> 24 & 255;
142 BattlegroundQueueTypeId bgQueueTypeId = BattlegroundQueueTypeId(scheduled[i] >> 16 & 255);
143 BattlegroundTypeId bgTypeId = BattlegroundTypeId((scheduled[i] >> 8) & 255);
144 BattlegroundBracketId bracket_id = BattlegroundBracketId(scheduled[i] & 255);
145 m_BattlegroundQueues[bgQueueTypeId].BattlegroundQueueUpdate(diff, bgTypeId, bracket_id, arenaType, arenaMMRating > 0, arenaMMRating);
146 m_BattlegroundQueues[bgQueueTypeId].BattlegroundQueueAnnouncerUpdate(diff, bgQueueTypeId, bracket_id);
147 }
148 }
149
150 // periodic queue update
152 {
154
155 LOG_TRACE("bg.arena", "BattlegroundMgr: UPDATING ARENA QUEUES");
156
157 // for rated arenas
158 for (uint32 qtype = BATTLEGROUND_QUEUE_2v2; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
159 {
160 for (uint32 bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
161 {
163 }
164 }
165
166 for (uint32 qtype = BATTLEGROUND_QUEUE_AV; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
167 {
168 for (uint32 bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
169 {
171 }
172 }
173 }
174 else
176
177 // arena points auto-distribution
179 {
181 {
183 {
184 sArenaTeamMgr->DistributeArenaPoints();
187 }
188 m_AutoDistributionTimeChecker = 600000; // 10 minutes check
189 }
190 else
192 }
193}
#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
@ CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS
Definition IWorld.h:330
#define LOG_TRACE(filterType__,...)
Definition Log.h:173
@ BATTLEGROUND_QUEUE_2v2
Definition SharedDefines.h:3628
@ BATTLEGROUND_QUEUE_AV
Definition SharedDefines.h:3621
@ MAX_BATTLEGROUND_QUEUE_TYPES
Definition SharedDefines.h:3631
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:707
void BattlegroundQueueAnnouncerUpdate(uint32 diff, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundBracketId bracket_id)
Definition BattlegroundQueue.cpp:959
bool ToBeDeleted() const
Definition Battleground.h:569
void Update(uint32 diff)
Definition Battleground.cpp:247
BattlegroundBracketId GetBracketId() const
Definition Battleground.h:331

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, 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:220
@ ARENA_TYPE_3v3
Definition Battleground.h:219
@ ARENA_TYPE_2v2
Definition Battleground.h:218
@ BATTLEGROUND_QUEUE_5v5
Definition SharedDefines.h:3630
@ BATTLEGROUND_QUEUE_3v3
Definition SharedDefines.h:3629
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 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1164
1165 /* Battleground queues */
1167 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1169
1170 void ToggleArenaTesting();
1171 void ToggleTesting();
1172
1173 void SetHolidayWeekends(uint32 mask);
1174
1175 bool isArenaTesting() const { return m_ArenaTesting; }
1176 bool isTesting() const { return m_Testing; }
1177
1180 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1181 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1182
1185 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1186
1191 void CheckBattleMasters();
1192
1194 {
1195 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1196 if (itr != mBattleMastersMap.end())
1197 return itr->second;
1199 }
1200
1201 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1202 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1203 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1204 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1205 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1206 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1207 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1208 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1209
1210private:
1211 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1214
1215 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1217
1219
1220 std::vector<uint64> m_QueueUpdateScheduler;
1221 bool m_ArenaTesting;
1222 bool m_Testing;
1227
1229 {
1230 auto const& itr = _battlegroundTemplates.find(id);
1231 if (itr != _battlegroundTemplates.end())
1232 return &itr->second;
1233
1234 return nullptr;
1235 }
1236
1238 {
1239 auto const& itr = _battlegroundMapTemplates.find(mapId);
1240 if (itr != _battlegroundMapTemplates.end())
1241 return itr->second;
1242
1243 return nullptr;
1244 }
1245
1246 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1247
1248 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1249 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1252};
1253
1254#define sBattlegroundMgr BattlegroundMgr::instance()
1255
1256#endif
std::unordered_map< uint32, BattlegroundTypeId > BattleMastersMap
Definition BattlegroundMgr.h:29
GroupJoinBattlegroundResult
Definition SharedDefines.h:3635
TeamId
Definition SharedDefines.h:759
HolidayIds
Definition SharedDefines.h:2741
std::map< BattlegroundTypeId, BattlegroundTemplate > BattlegroundTemplateMap
Definition BattlegroundMgr.h:181
Battleground * GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:267
void BuildBattlegroundListPacket(WorldPacket *data, ObjectGuid guid, Player *player, BattlegroundTypeId bgTypeId, uint8 fromWhere)
Definition BattlegroundMgr.cpp:583
void LoadBattleMastersEntry()
Definition BattlegroundMgr.cpp:803
std::map< BattlegroundTypeId, uint8 > BattlegroundSelectionWeightMap
Definition BattlegroundMgr.h:179
void AddToBGFreeSlotQueue(BattlegroundTypeId bgTypeId, Battleground *bg)
Definition BattlegroundMgr.cpp:949
BattlegroundMgr()
Definition BattlegroundMgr.cpp:62
void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId)
Definition BattlegroundMgr.cpp:973
std::vector< Battleground const * > GetActiveBattlegrounds()
Definition BattlegroundMgr.cpp:338
uint32 GetMaxRatingDifference() const
Definition BattlegroundMgr.cpp:781
std::map< BattlegroundTypeId, BattlegroundData > BattlegroundDataContainer
Definition BattlegroundMgr.h:148
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:195
std::map< uint32, BattlegroundTemplate * > BattlegroundMapTemplateContainer
Definition BattlegroundMgr.h:182
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:108
BattlegroundQueue & GetBattlegroundQueue(BattlegroundQueueTypeId bgQueueTypeId)
Definition BattlegroundMgr.h:99
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:261
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:247
Battleground * CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const *bracketEntry, uint8 arenaType, bool isRated)
Definition BattlegroundMgr.cpp:378
void SendToBattleground(Player *player, uint32 InstanceID, BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:649
void InitAutomaticArenaPointDistribution()
Definition BattlegroundMgr.cpp:560
void BuildPlayerLeftBattlegroundPacket(WorldPacket *data, ObjectGuid guid)
Definition BattlegroundMgr.cpp:255
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:126
~BattlegroundMgr()
Definition BattlegroundMgr.cpp:71
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:99
bool isTesting() const
Definition BattlegroundMgr.h:109
static bool IsBGWeekend(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:909
void LoadBattlegroundTemplates()
Definition BattlegroundMgr.cpp:461
Definition BattlegroundQueue.h:64
Definition ObjectGuid.h:118
Definition Player.h:1081

Referenced by BGQueueTypeId().

◆ bgDataStore

◆ bgToQueue

std::unordered_map< int, BattlegroundQueueTypeId > BattlegroundMgr::bgToQueue
static
Initial value:
=
{
}
@ BATTLEGROUND_QUEUE_RB
Definition SharedDefines.h:3627
@ BATTLEGROUND_QUEUE_SA
Definition SharedDefines.h:3625
@ BATTLEGROUND_QUEUE_AB
Definition SharedDefines.h:3623
@ BATTLEGROUND_QUEUE_WS
Definition SharedDefines.h:3622
@ BATTLEGROUND_QUEUE_EY
Definition SharedDefines.h:3624
@ BATTLEGROUND_QUEUE_IC
Definition SharedDefines.h:3626
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 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1076
1077 /* Battleground queues */
1079 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1081
1082 void ToggleArenaTesting();
1083 void ToggleTesting();
1084
1085 void SetHolidayWeekends(uint32 mask);
1086
1087 bool isArenaTesting() const { return m_ArenaTesting; }
1088 bool isTesting() const { return m_Testing; }
1089
1092 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1093 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1094
1097 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1098
1103 void CheckBattleMasters();
1104
1106 {
1107 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1108 if (itr != mBattleMastersMap.end())
1109 return itr->second;
1111 }
1112
1113 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1114 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1115 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1116 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1117 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1118 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1119 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1120 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1121
1122private:
1123 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1126
1127 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1129
1131
1132 std::vector<uint64> m_QueueUpdateScheduler;
1133 bool m_ArenaTesting;
1134 bool m_Testing;
1139
1141 {
1142 auto const& itr = _battlegroundTemplates.find(id);
1143 if (itr != _battlegroundTemplates.end())
1144 return &itr->second;
1145
1146 return nullptr;
1147 }
1148
1150 {
1151 auto const& itr = _battlegroundMapTemplates.find(mapId);
1152 if (itr != _battlegroundMapTemplates.end())
1153 return itr->second;
1154
1155 return nullptr;
1156 }
1157
1158 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1159
1160 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1161 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1164};
1165
1166#define sBattlegroundMgr BattlegroundMgr::instance()
1167
1168#endif

Referenced by BGQueueTypeId().

◆ bgtypeToBattleground

std::unordered_map< int, Battleground * > BattlegroundMgr::bgtypeToBattleground
static
Initial value:
=
{
}
Definition BattlegroundAB.h:251
Definition BattlegroundAV.h:1763
Definition BattlegroundBE.h:47
Definition BattlegroundDS.h:94
Definition BattlegroundEY.h:353
Definition BattlegroundIC.h:891
Definition BattlegroundNA.h:47
Definition BattlegroundRL.h:43
Definition BattlegroundRV.h:82
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 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1109
1110 /* Battleground queues */
1112 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1114
1115 void ToggleArenaTesting();
1116 void ToggleTesting();
1117
1118 void SetHolidayWeekends(uint32 mask);
1119
1120 bool isArenaTesting() const { return m_ArenaTesting; }
1121 bool isTesting() const { return m_Testing; }
1122
1125 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1126 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1127
1130 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1131
1136 void CheckBattleMasters();
1137
1139 {
1140 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1141 if (itr != mBattleMastersMap.end())
1142 return itr->second;
1144 }
1145
1146 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1147 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1148 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1149 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1150 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1151 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1152 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1153 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1154
1155private:
1156 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1159
1160 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1162
1164
1165 std::vector<uint64> m_QueueUpdateScheduler;
1166 bool m_ArenaTesting;
1167 bool m_Testing;
1172
1174 {
1175 auto const& itr = _battlegroundTemplates.find(id);
1176 if (itr != _battlegroundTemplates.end())
1177 return &itr->second;
1178
1179 return nullptr;
1180 }
1181
1183 {
1184 auto const& itr = _battlegroundMapTemplates.find(mapId);
1185 if (itr != _battlegroundMapTemplates.end())
1186 return itr->second;
1187
1188 return nullptr;
1189 }
1190
1191 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1192
1193 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1194 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1197};
1198
1199#define sBattlegroundMgr BattlegroundMgr::instance()
1200
1201#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 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1126
1127 /* Battleground queues */
1129 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1131
1132 void ToggleArenaTesting();
1133 void ToggleTesting();
1134
1135 void SetHolidayWeekends(uint32 mask);
1136
1137 bool isArenaTesting() const { return m_ArenaTesting; }
1138 bool isTesting() const { return m_Testing; }
1139
1142 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1143 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1144
1147 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1148
1153 void CheckBattleMasters();
1154
1156 {
1157 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1158 if (itr != mBattleMastersMap.end())
1159 return itr->second;
1161 }
1162
1163 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1164 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1165 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1166 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1167 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1168 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1169 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1170 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1171
1172private:
1173 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1176
1177 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1179
1181
1182 std::vector<uint64> m_QueueUpdateScheduler;
1183 bool m_ArenaTesting;
1184 bool m_Testing;
1189
1191 {
1192 auto const& itr = _battlegroundTemplates.find(id);
1193 if (itr != _battlegroundTemplates.end())
1194 return &itr->second;
1195
1196 return nullptr;
1197 }
1198
1200 {
1201 auto const& itr = _battlegroundMapTemplates.find(mapId);
1202 if (itr != _battlegroundMapTemplates.end())
1203 return itr->second;
1204
1205 return nullptr;
1206 }
1207
1208 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1209
1210 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1211 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1214};
1215
1216#define sBattlegroundMgr BattlegroundMgr::instance()
1217
1218#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 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1144
1145 /* Battleground queues */
1147 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1149
1150 void ToggleArenaTesting();
1151 void ToggleTesting();
1152
1153 void SetHolidayWeekends(uint32 mask);
1154
1155 bool isArenaTesting() const { return m_ArenaTesting; }
1156 bool isTesting() const { return m_Testing; }
1157
1160 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1161 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1162
1165 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1166
1171 void CheckBattleMasters();
1172
1174 {
1175 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1176 if (itr != mBattleMastersMap.end())
1177 return itr->second;
1179 }
1180
1181 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1182 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1183 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1184 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1185 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1186 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1187 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1188 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1189
1190private:
1191 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1194
1195 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1197
1199
1200 std::vector<uint64> m_QueueUpdateScheduler;
1201 bool m_ArenaTesting;
1202 bool m_Testing;
1207
1209 {
1210 auto const& itr = _battlegroundTemplates.find(id);
1211 if (itr != _battlegroundTemplates.end())
1212 return &itr->second;
1213
1214 return nullptr;
1215 }
1216
1218 {
1219 auto const& itr = _battlegroundMapTemplates.find(mapId);
1220 if (itr != _battlegroundMapTemplates.end())
1221 return itr->second;
1222
1223 return nullptr;
1224 }
1225
1226 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1227
1228 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1229 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1232};
1233
1234#define sBattlegroundMgr BattlegroundMgr::instance()
1235
1236#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 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1146
1147 /* Battleground queues */
1149 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1151
1152 void ToggleArenaTesting();
1153 void ToggleTesting();
1154
1155 void SetHolidayWeekends(uint32 mask);
1156
1157 bool isArenaTesting() const { return m_ArenaTesting; }
1158 bool isTesting() const { return m_Testing; }
1159
1162 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1163 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1164
1167 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1168
1173 void CheckBattleMasters();
1174
1176 {
1177 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1178 if (itr != mBattleMastersMap.end())
1179 return itr->second;
1181 }
1182
1183 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1184 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1185 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1186 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1187 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1188 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1189 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1190 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1191
1192private:
1193 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1196
1197 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1199
1201
1202 std::vector<uint64> m_QueueUpdateScheduler;
1203 bool m_ArenaTesting;
1204 bool m_Testing;
1209
1211 {
1212 auto const& itr = _battlegroundTemplates.find(id);
1213 if (itr != _battlegroundTemplates.end())
1214 return &itr->second;
1215
1216 return nullptr;
1217 }
1218
1220 {
1221 auto const& itr = _battlegroundMapTemplates.find(mapId);
1222 if (itr != _battlegroundMapTemplates.end())
1223 return itr->second;
1224
1225 return nullptr;
1226 }
1227
1228 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1229
1230 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1231 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1234};
1235
1236#define sBattlegroundMgr BattlegroundMgr::instance()
1237
1238#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 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1171
1172 /* Battleground queues */
1174 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1176
1177 void ToggleArenaTesting();
1178 void ToggleTesting();
1179
1180 void SetHolidayWeekends(uint32 mask);
1181
1182 bool isArenaTesting() const { return m_ArenaTesting; }
1183 bool isTesting() const { return m_Testing; }
1184
1187 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1188 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1189
1192 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1193
1198 void CheckBattleMasters();
1199
1201 {
1202 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1203 if (itr != mBattleMastersMap.end())
1204 return itr->second;
1206 }
1207
1208 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1209 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1210 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1211 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1212 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1213 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1214 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1215 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1216
1217private:
1218 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1221
1222 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1224
1226
1227 std::vector<uint64> m_QueueUpdateScheduler;
1228 bool m_ArenaTesting;
1229 bool m_Testing;
1234
1236 {
1237 auto const& itr = _battlegroundTemplates.find(id);
1238 if (itr != _battlegroundTemplates.end())
1239 return &itr->second;
1240
1241 return nullptr;
1242 }
1243
1245 {
1246 auto const& itr = _battlegroundMapTemplates.find(mapId);
1247 if (itr != _battlegroundMapTemplates.end())
1248 return itr->second;
1249
1250 return nullptr;
1251 }
1252
1253 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1254
1255 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1256 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1259};
1260
1261#define sBattlegroundMgr BattlegroundMgr::instance()
1262
1263#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 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1094
1095 /* Battleground queues */
1097 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1099
1100 void ToggleArenaTesting();
1101 void ToggleTesting();
1102
1103 void SetHolidayWeekends(uint32 mask);
1104
1105 bool isArenaTesting() const { return m_ArenaTesting; }
1106 bool isTesting() const { return m_Testing; }
1107
1110 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1111 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1112
1115 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1116
1121 void CheckBattleMasters();
1122
1124 {
1125 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1126 if (itr != mBattleMastersMap.end())
1127 return itr->second;
1129 }
1130
1131 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1132 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1133 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1134 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1135 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1136 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1137 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1138 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1139
1140private:
1141 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1144
1145 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1147
1149
1150 std::vector<uint64> m_QueueUpdateScheduler;
1151 bool m_ArenaTesting;
1152 bool m_Testing;
1157
1159 {
1160 auto const& itr = _battlegroundTemplates.find(id);
1161 if (itr != _battlegroundTemplates.end())
1162 return &itr->second;
1163
1164 return nullptr;
1165 }
1166
1168 {
1169 auto const& itr = _battlegroundMapTemplates.find(mapId);
1170 if (itr != _battlegroundMapTemplates.end())
1171 return itr->second;
1172
1173 return nullptr;
1174 }
1175
1176 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1177
1178 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1179 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1182};
1183
1184#define sBattlegroundMgr BattlegroundMgr::instance()
1185
1186#endif

Referenced by BGTemplateId().


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