AzerothCore 3.3.5a
OpenSource WoW Emulator
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
63 :
64 m_ArenaTesting(false),
65 m_Testing(false),
69{
70}
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
73{
75}
void DeleteAllBattlegrounds()
Definition BattlegroundMgr.cpp:83

References DeleteAllBattlegrounds().

Member Function Documentation

◆ AddBattleground()

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

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

Referenced by CreateBattleground().

◆ AddToBGFreeSlotQueue()

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

References bgDataStore.

◆ BGArenaType()

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

References QueueToArenaType, and sScriptMgr.

Referenced by Update().

◆ BGQueueTypeId()

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

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
711{
712 if (BattlegroundMgr::queueToBg.find(bgQueueTypeId) == BattlegroundMgr::queueToBg.end())
713 {
714 return BattlegroundTypeId(0);
715 }
716
717 return BattlegroundMgr::queueToBg[bgQueueTypeId];
718}
BattlegroundTypeId
Definition SharedDefines.h:3734
static std::unordered_map< int, BattlegroundTypeId > queueToBg
Definition BattlegroundMgr.h:999

References queueToBg.

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

◆ BGTypeToWeekendHolidayId()

HolidayIds BattlegroundMgr::BGTypeToWeekendHolidayId ( BattlegroundTypeId  bgTypeId)
static
869{
870 switch (bgTypeId)
871 {
872 case BATTLEGROUND_AV:
874 case BATTLEGROUND_EY:
876 case BATTLEGROUND_WS:
878 case BATTLEGROUND_SA:
880 case BATTLEGROUND_AB:
882 case BATTLEGROUND_IC:
884 default:
885 return HOLIDAY_NONE;
886 }
887}
@ BATTLEGROUND_IC
Definition SharedDefines.h:3747
@ BATTLEGROUND_WS
Definition SharedDefines.h:3737
@ BATTLEGROUND_EY
Definition SharedDefines.h:3742
@ BATTLEGROUND_AV
Definition SharedDefines.h:3736
@ BATTLEGROUND_SA
Definition SharedDefines.h:3744
@ BATTLEGROUND_AB
Definition SharedDefines.h:3738
@ HOLIDAY_NONE
Definition SharedDefines.h:2981
@ HOLIDAY_CALL_TO_ARMS_AB
Definition SharedDefines.h:2989
@ HOLIDAY_CALL_TO_ARMS_EY
Definition SharedDefines.h:2996
@ HOLIDAY_CALL_TO_ARMS_SA
Definition SharedDefines.h:3002
@ HOLIDAY_CALL_TO_ARMS_IC
Definition SharedDefines.h:3006
@ HOLIDAY_CALL_TO_ARMS_AV
Definition SharedDefines.h:2987
@ HOLIDAY_CALL_TO_ARMS_WS
Definition SharedDefines.h:2988

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

Referenced by IsBGWeekend().

◆ BuildBattlegroundListPacket()

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

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

◆ BuildBattlegroundStatusPacket()

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

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

◆ BuildGroupJoinedBattlegroundPacket()

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

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

◆ BuildPlayerJoinedBattlegroundPacket()

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

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

◆ BuildPlayerLeftBattlegroundPacket()

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

References WorldPacket::Initialize(), and SMSG_BATTLEGROUND_PLAYER_LEFT.

◆ CheckBattleMasters()

void BattlegroundMgr::CheckBattleMasters ( )
856{
857 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
858 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
859 {
860 if ((itr->second.npcflag & UNIT_NPC_FLAG_BATTLEMASTER) && mBattleMastersMap.find(itr->second.Entry) == mBattleMastersMap.end())
861 {
862 LOG_ERROR("sql.sql", "CreatureTemplate (Entry: {}) has UNIT_NPC_FLAG_BATTLEMASTER but no data in `battlemaster_entry` table. Removing flag!", itr->second.Entry);
863 const_cast<CreatureTemplate*>(&itr->second)->npcflag &= ~UNIT_NPC_FLAG_BATTLEMASTER;
864 }
865 }
866}
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition CreatureData.h:292
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
#define sObjectMgr
Definition ObjectMgr.h:1650
@ 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
430{
431 // Create the BG
432 Battleground* bg = GetBattlegroundTemplate(bgTemplate->Id);
433
434 if (!bg)
435 {
436 bg = BattlegroundMgr::bgtypeToBattleground[bgTemplate->Id];
437
438 ASSERT(bg);
439
440 if (bgTemplate->Id == BATTLEGROUND_RB)
441 bg->SetRandom(true);
442
443 bg->SetBgTypeID(bgTemplate->Id);
444 bg->SetInstanceID(0);
445 AddBattleground(bg);
446 }
447
448 bg->SetMapId(bgTemplate->BattlemasterEntry->mapid[0]);
449 bg->SetName(bgTemplate->BattlemasterEntry->name[sWorld->GetDefaultDbcLocale()]);
450 bg->SetArenaorBGType(bgTemplate->IsArena());
451 bg->SetMinPlayersPerTeam(bgTemplate->MinPlayersPerTeam);
452 bg->SetMaxPlayersPerTeam(bgTemplate->MaxPlayersPerTeam);
453 bg->SetTeamStartPosition(TEAM_ALLIANCE, bgTemplate->StartLocation[TEAM_ALLIANCE]);
454 bg->SetTeamStartPosition(TEAM_HORDE, bgTemplate->StartLocation[TEAM_HORDE]);
455 bg->SetStartMaxDist(bgTemplate->MaxStartDistSq);
456 bg->SetLevelRange(bgTemplate->MinLevel, bgTemplate->MaxLevel);
457 bg->SetScriptId(bgTemplate->ScriptId);
458
459 return true;
460}
#define ASSERT
Definition Errors.h:68
@ TEAM_HORDE
Definition SharedDefines.h:761
void AddBattleground(Battleground *bg)
Definition BattlegroundMgr.cpp:966
Battleground * GetBattlegroundTemplate(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:327
static std::unordered_map< int, Battleground * > bgtypeToBattleground
Definition BattlegroundMgr.h:1014
Definition Battleground.h:294
void SetMapId(uint32 MapID)
Definition Battleground.h:435
void SetInstanceID(uint32 InstanceID)
Definition Battleground.h:363
void SetRandom(bool isRandom)
Definition Battleground.h:375
void SetScriptId(uint32 scriptId)
Definition Battleground.h:374
void SetBgTypeID(BattlegroundTypeId TypeID)
Definition Battleground.h:360
void SetMinPlayersPerTeam(uint32 MinPlayers)
Definition Battleground.h:381
void SetStartMaxDist(float startMaxDist)
Definition Battleground.h:446
void SetName(std::string_view name)
Definition Battleground.h:359
void SetLevelRange(uint32 min, uint32 max)
Definition Battleground.h:369
void SetArenaorBGType(bool _isArena)
Definition Battleground.h:372
void SetTeamStartPosition(TeamId teamId, Position const &pos)
Definition Battleground.cpp:661
void SetMaxPlayersPerTeam(uint32 MaxPlayers)
Definition Battleground.h:380

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

Referenced by LoadBattlegroundTemplates().

◆ CreateClientVisibleInstanceId()

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

References bgDataStore, and IsArenaType().

Referenced by CreateNewBattleground().

◆ CreateNewBattleground()

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

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

◆ DeleteAllBattlegrounds()

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

References bgDataStore.

Referenced by ~BattlegroundMgr().

◆ GetActiveBattlegrounds()

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

References bgDataStore, STATUS_IN_PROGRESS, and STATUS_WAIT_JOIN.

◆ GetBattleground()

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

References BATTLEGROUND_TYPE_NONE, and bgDataStore.

Referenced by GetBattlegroundThroughClientInstance(), and SendToBattleground().

◆ GetBattlegroundQueue()

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

References bgDataStore.

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

◆ GetBattlegroundTemplateByMapId()

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

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

◆ GetBattleMasterBG()

BattlegroundTypeId BattlegroundMgr::GetBattleMasterBG ( uint32  entry) const
inline
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)
946{
947 return bgDataStore[bgTypeId].BGFreeSlotQueue;
948}

References bgDataStore.

◆ GetMaxRatingDifference()

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

References CONFIG_ARENA_MAX_RATING_DIFFERENCE, and sWorld.

◆ GetPrematureFinishTime()

uint32 BattlegroundMgr::GetPrematureFinishTime ( ) const
800{
802}
@ CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER
Definition WorldConfig.h:260

References CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER, and sWorld.

◆ GetRandomBG()

BattlegroundTypeId BattlegroundMgr::GetRandomBG ( BattlegroundTypeId  id,
uint32  minLevel 
)
private
916{
917 if (BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId))
918 {
919 std::vector<BattlegroundTypeId> ids;
920 ids.reserve(16);
921 std::vector<double> weights;
922 weights.reserve(16);
923
924 for (int32 mapId : bgTemplate->BattlemasterEntry->mapid)
925 {
926 if (mapId == -1)
927 break;
928
930 {
931 if (bg->MinLevel <= minLevel)
932 {
933 ids.push_back(bg->Id);
934 weights.push_back(bg->Weight);
935 }
936 }
937 }
938
940 }
941
943}
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
795{
796 return sWorld->getIntConfig(CONFIG_ARENA_RATING_DISCARD_TIMER);
797}
@ CONFIG_ARENA_RATING_DISCARD_TIMER
Definition WorldConfig.h:278

References CONFIG_ARENA_RATING_DISCARD_TIMER, and sWorld.

◆ InitAutomaticArenaPointDistribution()

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

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

◆ instance()

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

References instance().

Referenced by instance().

◆ isArenaTesting()

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

References m_ArenaTesting.

◆ IsArenaType()

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

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

Referenced by CreateClientVisibleInstanceId().

◆ IsBGWeekend()

bool BattlegroundMgr::IsBGWeekend ( BattlegroundTypeId  bgTypeId)
static
911{
913}
bool IsHolidayActive(HolidayIds id)
Definition GameEventMgr.cpp:1950
static HolidayIds BGTypeToWeekendHolidayId(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:868

References BGTypeToWeekendHolidayId(), and IsHolidayActive().

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

◆ isTesting()

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

References m_Testing.

◆ LoadBattlegroundTemplates()

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

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

◆ LoadBattleMastersEntry()

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

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 
)
975{
976 bgDataStore[bgTypeId]._Battlegrounds.erase(instanceId);
977}

References bgDataStore.

◆ RemoveFromBGFreeSlotQueue()

void BattlegroundMgr::RemoveFromBGFreeSlotQueue ( BattlegroundTypeId  bgTypeId,
uint32  instanceId 
)
956{
957 BGFreeSlotQueueContainer& queues = bgDataStore[bgTypeId].BGFreeSlotQueue;
958 for (BGFreeSlotQueueContainer::iterator itr = queues.begin(); itr != queues.end(); ++itr)
959 if ((*itr)->GetInstanceID() == instanceId)
960 {
961 queues.erase(itr);
962 return;
963 }
964}
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 
)
774{
775 //This method must be atomic, @todo add mutex
776 //we will use only 1 number created of bgTypeId and bracket_id
777 uint64 const scheduleId = ((uint64)arenaMatchmakerRating << 32) | ((uint64)arenaType << 24) | ((uint64)bgQueueTypeId << 16) | ((uint64)bgTypeId << 8) | (uint64)bracket_id;
778 if (std::find(m_QueueUpdateScheduler.begin(), m_QueueUpdateScheduler.end(), scheduleId) == m_QueueUpdateScheduler.end())
779 m_QueueUpdateScheduler.emplace_back(scheduleId);
780}
std::vector< uint64 > m_QueueUpdateScheduler
Definition BattlegroundMgr.h:153

References m_QueueUpdateScheduler.

◆ SendAreaSpiritHealerQueryOpcode()

void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode ( Player player,
Battleground bg,
ObjectGuid  guid 
)
667{
669 uint32 time_ = RESURRECTION_INTERVAL - bg->GetLastResurrectTime(); // resurrect every X seconds
670 if (time_ == uint32(-1))
671 time_ = 0;
672 data << guid << time_;
673 player->GetSession()->SendPacket(&data);
674}
#define RESURRECTION_INTERVAL
Definition Battleground.h:163
uint32 GetLastResurrectTime() const
Definition Battleground.h:327
WorldSession * GetSession() const
Definition Player.h:2011
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 
)
651{
652 if (Battleground* bg = GetBattleground(instanceId, bgTypeId))
653 {
654 uint32 mapid = bg->GetMapId();
655 Position const* pos = bg->GetTeamStartPosition(player->GetBgTeamId());
656
657 LOG_DEBUG("bg.battleground", "BattlegroundMgr::SendToBattleground: Sending {} to map {}, {} (bgType {})", player->GetName(), mapid, pos->ToString(), bgTypeId);
658 player->TeleportTo(mapid, pos->GetPositionX(), pos->GetPositionY(), pos->GetPositionZ(), pos->GetOrientation());
659 }
660 else
661 {
662 LOG_ERROR("bg.battleground", "BattlegroundMgr::SendToBattleground: Instance {} (bgType {}) not found while trying to teleport player {}", instanceId, bgTypeId, player->GetName());
663 }
664}
#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:2292
std::string const & GetName() const
Definition Object.h:514
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)
763{
764 for (uint32 bgtype = 1; bgtype < MAX_BATTLEGROUND_TYPE_ID; ++bgtype)
765 {
766 if (bgtype == BATTLEGROUND_RB)
767 continue;
769 bgt->SetHoliday(mask & (1 << bgtype));
770 }
771}
#define MAX_BATTLEGROUND_TYPE_ID
Definition SharedDefines.h:3751

References BATTLEGROUND_RB, GetBattlegroundTemplate(), and MAX_BATTLEGROUND_TYPE_ID.

◆ ToggleArenaTesting()

void BattlegroundMgr::ToggleArenaTesting ( )
749{
750 if (sWorld->getBoolConfig(CONFIG_DEBUG_ARENA))
751 {
752 m_ArenaTesting = true;
754 }
755 else
756 {
759 }
760}
@ LANG_DEBUG_ARENA_OFF
Definition Language.h:711
@ LANG_DEBUG_ARENA_ON
Definition Language.h:710
@ LANG_DEBUG_ARENA_CONF
Definition Language.h:1335
@ CONFIG_DEBUG_ARENA
Definition WorldConfig.h:121
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 ( )
735{
736 if (sWorld->getBoolConfig(CONFIG_DEBUG_BATTLEGROUND))
737 {
738 m_Testing = true;
740 }
741 else
742 {
745 }
746}
@ LANG_DEBUG_BG_OFF
Definition Language.h:713
@ LANG_DEBUG_BG_CONF
Definition Language.h:1334
@ LANG_DEBUG_BG_ON
Definition Language.h:712
@ CONFIG_DEBUG_BATTLEGROUND
Definition WorldConfig.h:120

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

◆ Update()

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

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

◆ WeekendHolidayIdToBGType()

Member Data Documentation

◆ _battlegroundMapTemplates

BattlegroundMapTemplateContainer BattlegroundMgr::_battlegroundMapTemplates
private

◆ _battlegroundTemplates

BattlegroundTemplateMap BattlegroundMgr::_battlegroundTemplates
private

◆ ArenaTypeToQueue

std::unordered_map< uint32, BattlegroundQueueTypeId > BattlegroundMgr::ArenaTypeToQueue
static
Initial value:
=
{
}
@ ARENA_TYPE_5v5
Definition Battleground.h:210
@ ARENA_TYPE_3v3
Definition Battleground.h:209
@ ARENA_TYPE_2v2
Definition Battleground.h:208
@ BATTLEGROUND_QUEUE_5v5
Definition SharedDefines.h:3885
@ BATTLEGROUND_QUEUE_3v3
Definition SharedDefines.h:3884
1107{
1108 BattlegroundContainer _Battlegrounds;
1109 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1110 BGFreeSlotQueueContainer BGFreeSlotQueue;
1111};
1112
1114{
1116 uint16 MinPlayersPerTeam;
1117 uint16 MaxPlayersPerTeam;
1118 uint8 MinLevel;
1119 uint8 MaxLevel;
1120 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1121 float MaxStartDistSq;
1122 uint8 Weight;
1123 uint32 ScriptId;
1124 BattlemasterListEntry const* BattlemasterEntry;
1125
1126 bool IsArena() const;
1127};
1128
1129class BattlegroundMgr
1130{
1131private:
1134
1135public:
1136 static BattlegroundMgr* instance();
1137
1138 void Update(uint32 diff);
1139
1140 /* Packet Building */
1143 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1145 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);
1147
1148 /* Battlegrounds */
1152 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1153 std::vector<Battleground const*> GetActiveBattlegrounds();
1154
1155 void AddBattleground(Battleground* bg);
1156 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1158 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1160
1163
1164 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1165
1166 /* Battleground queues */
1168 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1170
1171 void ToggleArenaTesting();
1172 void ToggleTesting();
1173
1174 void SetHolidayWeekends(uint32 mask);
1175
1176 bool isArenaTesting() const { return m_ArenaTesting; }
1177 bool isTesting() const { return m_Testing; }
1178
1181 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1182 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1183
1186 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1187
1192 void CheckBattleMasters();
1193
1195 {
1196 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1197 if (itr != mBattleMastersMap.end())
1198 return itr->second;
1200 }
1201
1202 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1203 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1204 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1205 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1206 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1207 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1208 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1209 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1210
1211private:
1212 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1215
1216 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1218
1220
1221 std::vector<uint64> m_QueueUpdateScheduler;
1222 bool m_ArenaTesting;
1223 bool m_Testing;
1228
1230 {
1231 auto const& itr = _battlegroundTemplates.find(id);
1232 if (itr != _battlegroundTemplates.end())
1233 return &itr->second;
1234
1235 return nullptr;
1236 }
1237
1239 {
1240 auto const& itr = _battlegroundMapTemplates.find(mapId);
1241 if (itr != _battlegroundMapTemplates.end())
1242 return itr->second;
1243
1244 return nullptr;
1245 }
1246
1247 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1248
1249 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1250 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1253};
1254
1255#define sBattlegroundMgr BattlegroundMgr::instance()
1256
1257#endif
std::unordered_map< uint32, BattlegroundTypeId > BattleMastersMap
Definition BattlegroundMgr.h:29
GroupJoinBattlegroundResult
Definition SharedDefines.h:3890
TeamId
Definition SharedDefines.h:759
HolidayIds
Definition SharedDefines.h:2980
std::map< BattlegroundTypeId, BattlegroundTemplate > BattlegroundTemplateMap
Definition BattlegroundMgr.h:181
Battleground * GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:268
void BuildBattlegroundListPacket(WorldPacket *data, ObjectGuid guid, Player *player, BattlegroundTypeId bgTypeId, uint8 fromWhere)
Definition BattlegroundMgr.cpp:584
void LoadBattleMastersEntry()
Definition BattlegroundMgr.cpp:804
std::map< BattlegroundTypeId, uint8 > BattlegroundSelectionWeightMap
Definition BattlegroundMgr.h:179
void AddToBGFreeSlotQueue(BattlegroundTypeId bgTypeId, Battleground *bg)
Definition BattlegroundMgr.cpp:950
BattlegroundMgr()
Definition BattlegroundMgr.cpp:63
void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId)
Definition BattlegroundMgr.cpp:974
std::vector< Battleground const * > GetActiveBattlegrounds()
Definition BattlegroundMgr.cpp:339
uint32 GetMaxRatingDifference() const
Definition BattlegroundMgr.cpp:782
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:196
std::map< uint32, BattlegroundTemplate * > BattlegroundMapTemplateContainer
Definition BattlegroundMgr.h:182
BGFreeSlotQueueContainer & GetBGFreeSlotQueueStore(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:945
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition BattlegroundMgr.cpp:686
bool isArenaTesting() const
Definition BattlegroundMgr.h:108
BattlegroundQueue & GetBattlegroundQueue(BattlegroundQueueTypeId bgQueueTypeId)
Definition BattlegroundMgr.h:99
void ToggleArenaTesting()
Definition BattlegroundMgr.cpp:748
static BattlegroundTypeId BGTemplateId(BattlegroundQueueTypeId bgQueueTypeId)
Definition BattlegroundMgr.cpp:710
void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId)
Definition BattlegroundMgr.cpp:955
void BuildPlayerJoinedBattlegroundPacket(WorldPacket *data, Player *player)
Definition BattlegroundMgr.cpp:262
void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
Definition BattlegroundMgr.cpp:773
void BuildGroupJoinedBattlegroundPacket(WorldPacket *data, GroupJoinBattlegroundResult result)
Definition BattlegroundMgr.cpp:248
Battleground * CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const *bracketEntry, uint8 arenaType, bool isRated)
Definition BattlegroundMgr.cpp:379
void SendToBattleground(Player *player, uint32 InstanceID, BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:650
void InitAutomaticArenaPointDistribution()
Definition BattlegroundMgr.cpp:561
void BuildPlayerLeftBattlegroundPacket(WorldPacket *data, ObjectGuid guid)
Definition BattlegroundMgr.cpp:256
void SetHolidayWeekends(uint32 mask)
Definition BattlegroundMgr.cpp:762
void ToggleTesting()
Definition BattlegroundMgr.cpp:734
uint32 GetRatingDiscardTimer() const
Definition BattlegroundMgr.cpp:794
static std::unordered_map< int, bgMapRef > getBgFromMap
Definition BattlegroundMgr.h:1049
static std::unordered_map< int, bgTypeRef > getBgFromTypeID
Definition BattlegroundMgr.h:1051
static BattlegroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday)
Definition BattlegroundMgr.cpp:889
BattlegroundTypeId GetBattleMasterBG(uint32 entry) const
Definition BattlegroundMgr.h:126
~BattlegroundMgr()
Definition BattlegroundMgr.cpp:72
uint32 GetPrematureFinishTime() const
Definition BattlegroundMgr.cpp:799
void SendAreaSpiritHealerQueryOpcode(Player *player, Battleground *bg, ObjectGuid guid)
Definition BattlegroundMgr.cpp:666
void Update(uint32 diff)
Definition BattlegroundMgr.cpp:100
bool isTesting() const
Definition BattlegroundMgr.h:109
static bool IsBGWeekend(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:910
void LoadBattlegroundTemplates()
Definition BattlegroundMgr.cpp:462
Definition BattlegroundQueue.h:64
Definition ObjectGuid.h:118
Definition Player.h:1083

Referenced by BGQueueTypeId().

◆ bgDataStore

◆ bgToQueue

std::unordered_map< int, BattlegroundQueueTypeId > BattlegroundMgr::bgToQueue
static
Initial value:
=
{
}
@ BATTLEGROUND_QUEUE_RB
Definition SharedDefines.h:3882
@ BATTLEGROUND_QUEUE_SA
Definition SharedDefines.h:3880
@ BATTLEGROUND_QUEUE_AB
Definition SharedDefines.h:3878
@ BATTLEGROUND_QUEUE_WS
Definition SharedDefines.h:3877
@ BATTLEGROUND_QUEUE_EY
Definition SharedDefines.h:3879
@ BATTLEGROUND_QUEUE_IC
Definition SharedDefines.h:3881
1019{
1020 BattlegroundContainer _Battlegrounds;
1021 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1022 BGFreeSlotQueueContainer BGFreeSlotQueue;
1023};
1024
1026{
1028 uint16 MinPlayersPerTeam;
1029 uint16 MaxPlayersPerTeam;
1030 uint8 MinLevel;
1031 uint8 MaxLevel;
1032 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1033 float MaxStartDistSq;
1034 uint8 Weight;
1035 uint32 ScriptId;
1036 BattlemasterListEntry const* BattlemasterEntry;
1037
1038 bool IsArena() const;
1039};
1040
1041class BattlegroundMgr
1042{
1043private:
1046
1047public:
1048 static BattlegroundMgr* instance();
1049
1050 void Update(uint32 diff);
1051
1052 /* Packet Building */
1055 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1057 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);
1059
1060 /* Battlegrounds */
1064 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1065 std::vector<Battleground const*> GetActiveBattlegrounds();
1066
1067 void AddBattleground(Battleground* bg);
1068 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1070 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1072
1075
1076 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1077
1078 /* Battleground queues */
1080 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1082
1083 void ToggleArenaTesting();
1084 void ToggleTesting();
1085
1086 void SetHolidayWeekends(uint32 mask);
1087
1088 bool isArenaTesting() const { return m_ArenaTesting; }
1089 bool isTesting() const { return m_Testing; }
1090
1093 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1094 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1095
1098 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1099
1104 void CheckBattleMasters();
1105
1107 {
1108 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1109 if (itr != mBattleMastersMap.end())
1110 return itr->second;
1112 }
1113
1114 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1115 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1116 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1117 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1118 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1119 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1120 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1121 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1122
1123private:
1124 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1127
1128 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1130
1132
1133 std::vector<uint64> m_QueueUpdateScheduler;
1134 bool m_ArenaTesting;
1135 bool m_Testing;
1140
1142 {
1143 auto const& itr = _battlegroundTemplates.find(id);
1144 if (itr != _battlegroundTemplates.end())
1145 return &itr->second;
1146
1147 return nullptr;
1148 }
1149
1151 {
1152 auto const& itr = _battlegroundMapTemplates.find(mapId);
1153 if (itr != _battlegroundMapTemplates.end())
1154 return itr->second;
1155
1156 return nullptr;
1157 }
1158
1159 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1160
1161 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1162 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1165};
1166
1167#define sBattlegroundMgr BattlegroundMgr::instance()
1168
1169#endif

Referenced by BGQueueTypeId().

◆ bgtypeToBattleground

std::unordered_map< int, Battleground * > BattlegroundMgr::bgtypeToBattleground
static
Initial value:
=
{
}
Definition BattlegroundAB.h:251
Definition BattlegroundAV.h:1758
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
1052{
1053 BattlegroundContainer _Battlegrounds;
1054 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1055 BGFreeSlotQueueContainer BGFreeSlotQueue;
1056};
1057
1059{
1061 uint16 MinPlayersPerTeam;
1062 uint16 MaxPlayersPerTeam;
1063 uint8 MinLevel;
1064 uint8 MaxLevel;
1065 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1066 float MaxStartDistSq;
1067 uint8 Weight;
1068 uint32 ScriptId;
1069 BattlemasterListEntry const* BattlemasterEntry;
1070
1071 bool IsArena() const;
1072};
1073
1074class BattlegroundMgr
1075{
1076private:
1079
1080public:
1081 static BattlegroundMgr* instance();
1082
1083 void Update(uint32 diff);
1084
1085 /* Packet Building */
1088 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1090 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);
1092
1093 /* Battlegrounds */
1097 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1098 std::vector<Battleground const*> GetActiveBattlegrounds();
1099
1100 void AddBattleground(Battleground* bg);
1101 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1103 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1105
1108
1109 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1110
1111 /* Battleground queues */
1113 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1115
1116 void ToggleArenaTesting();
1117 void ToggleTesting();
1118
1119 void SetHolidayWeekends(uint32 mask);
1120
1121 bool isArenaTesting() const { return m_ArenaTesting; }
1122 bool isTesting() const { return m_Testing; }
1123
1126 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1127 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1128
1131 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1132
1137 void CheckBattleMasters();
1138
1140 {
1141 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1142 if (itr != mBattleMastersMap.end())
1143 return itr->second;
1145 }
1146
1147 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1148 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1149 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1150 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1151 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1152 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1153 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1154 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1155
1156private:
1157 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1160
1161 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1163
1165
1166 std::vector<uint64> m_QueueUpdateScheduler;
1167 bool m_ArenaTesting;
1168 bool m_Testing;
1173
1175 {
1176 auto const& itr = _battlegroundTemplates.find(id);
1177 if (itr != _battlegroundTemplates.end())
1178 return &itr->second;
1179
1180 return nullptr;
1181 }
1182
1184 {
1185 auto const& itr = _battlegroundMapTemplates.find(mapId);
1186 if (itr != _battlegroundMapTemplates.end())
1187 return itr->second;
1188
1189 return nullptr;
1190 }
1191
1192 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1193
1194 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1195 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1198};
1199
1200#define sBattlegroundMgr BattlegroundMgr::instance()
1201
1202#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); }, },
}
1069{
1070 BattlegroundContainer _Battlegrounds;
1071 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1072 BGFreeSlotQueueContainer BGFreeSlotQueue;
1073};
1074
1076{
1078 uint16 MinPlayersPerTeam;
1079 uint16 MaxPlayersPerTeam;
1080 uint8 MinLevel;
1081 uint8 MaxLevel;
1082 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1083 float MaxStartDistSq;
1084 uint8 Weight;
1085 uint32 ScriptId;
1086 BattlemasterListEntry const* BattlemasterEntry;
1087
1088 bool IsArena() const;
1089};
1090
1091class BattlegroundMgr
1092{
1093private:
1096
1097public:
1098 static BattlegroundMgr* instance();
1099
1100 void Update(uint32 diff);
1101
1102 /* Packet Building */
1105 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1107 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);
1109
1110 /* Battlegrounds */
1114 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1115 std::vector<Battleground const*> GetActiveBattlegrounds();
1116
1117 void AddBattleground(Battleground* bg);
1118 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1120 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1122
1125
1126 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1127
1128 /* Battleground queues */
1130 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1132
1133 void ToggleArenaTesting();
1134 void ToggleTesting();
1135
1136 void SetHolidayWeekends(uint32 mask);
1137
1138 bool isArenaTesting() const { return m_ArenaTesting; }
1139 bool isTesting() const { return m_Testing; }
1140
1143 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1144 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1145
1148 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1149
1154 void CheckBattleMasters();
1155
1157 {
1158 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1159 if (itr != mBattleMastersMap.end())
1160 return itr->second;
1162 }
1163
1164 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1165 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1166 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1167 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1168 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1169 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1170 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1171 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1172
1173private:
1174 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1177
1178 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1180
1182
1183 std::vector<uint64> m_QueueUpdateScheduler;
1184 bool m_ArenaTesting;
1185 bool m_Testing;
1190
1192 {
1193 auto const& itr = _battlegroundTemplates.find(id);
1194 if (itr != _battlegroundTemplates.end())
1195 return &itr->second;
1196
1197 return nullptr;
1198 }
1199
1201 {
1202 auto const& itr = _battlegroundMapTemplates.find(mapId);
1203 if (itr != _battlegroundMapTemplates.end())
1204 return itr->second;
1205
1206 return nullptr;
1207 }
1208
1209 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1210
1211 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1212 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1215};
1216
1217#define sBattlegroundMgr BattlegroundMgr::instance()
1218
1219#endif

Referenced by CreateNewBattleground().

◆ getBgFromMap

std::unordered_map< int, bgMapRef > BattlegroundMgr::getBgFromMap = {}
static
1087{
1088 BattlegroundContainer _Battlegrounds;
1089 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1090 BGFreeSlotQueueContainer BGFreeSlotQueue;
1091};
1092
1094{
1096 uint16 MinPlayersPerTeam;
1097 uint16 MaxPlayersPerTeam;
1098 uint8 MinLevel;
1099 uint8 MaxLevel;
1100 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1101 float MaxStartDistSq;
1102 uint8 Weight;
1103 uint32 ScriptId;
1104 BattlemasterListEntry const* BattlemasterEntry;
1105
1106 bool IsArena() const;
1107};
1108
1109class BattlegroundMgr
1110{
1111private:
1114
1115public:
1116 static BattlegroundMgr* instance();
1117
1118 void Update(uint32 diff);
1119
1120 /* Packet Building */
1123 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1125 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);
1127
1128 /* Battlegrounds */
1132 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1133 std::vector<Battleground const*> GetActiveBattlegrounds();
1134
1135 void AddBattleground(Battleground* bg);
1136 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1138 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1140
1143
1144 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1145
1146 /* Battleground queues */
1148 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1150
1151 void ToggleArenaTesting();
1152 void ToggleTesting();
1153
1154 void SetHolidayWeekends(uint32 mask);
1155
1156 bool isArenaTesting() const { return m_ArenaTesting; }
1157 bool isTesting() const { return m_Testing; }
1158
1161 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1162 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1163
1166 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1167
1172 void CheckBattleMasters();
1173
1175 {
1176 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1177 if (itr != mBattleMastersMap.end())
1178 return itr->second;
1180 }
1181
1182 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1183 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1184 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1185 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1186 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1187 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1188 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1189 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1190
1191private:
1192 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1195
1196 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1198
1200
1201 std::vector<uint64> m_QueueUpdateScheduler;
1202 bool m_ArenaTesting;
1203 bool m_Testing;
1208
1210 {
1211 auto const& itr = _battlegroundTemplates.find(id);
1212 if (itr != _battlegroundTemplates.end())
1213 return &itr->second;
1214
1215 return nullptr;
1216 }
1217
1219 {
1220 auto const& itr = _battlegroundMapTemplates.find(mapId);
1221 if (itr != _battlegroundMapTemplates.end())
1222 return itr->second;
1223
1224 return nullptr;
1225 }
1226
1227 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1228
1229 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1230 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1233};
1234
1235#define sBattlegroundMgr BattlegroundMgr::instance()
1236
1237#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);
}
}
}
}
1089{
1090 BattlegroundContainer _Battlegrounds;
1091 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1092 BGFreeSlotQueueContainer BGFreeSlotQueue;
1093};
1094
1096{
1098 uint16 MinPlayersPerTeam;
1099 uint16 MaxPlayersPerTeam;
1100 uint8 MinLevel;
1101 uint8 MaxLevel;
1102 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1103 float MaxStartDistSq;
1104 uint8 Weight;
1105 uint32 ScriptId;
1106 BattlemasterListEntry const* BattlemasterEntry;
1107
1108 bool IsArena() const;
1109};
1110
1111class BattlegroundMgr
1112{
1113private:
1116
1117public:
1118 static BattlegroundMgr* instance();
1119
1120 void Update(uint32 diff);
1121
1122 /* Packet Building */
1125 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1127 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);
1129
1130 /* Battlegrounds */
1134 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1135 std::vector<Battleground const*> GetActiveBattlegrounds();
1136
1137 void AddBattleground(Battleground* bg);
1138 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1140 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1142
1145
1146 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1147
1148 /* Battleground queues */
1150 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1152
1153 void ToggleArenaTesting();
1154 void ToggleTesting();
1155
1156 void SetHolidayWeekends(uint32 mask);
1157
1158 bool isArenaTesting() const { return m_ArenaTesting; }
1159 bool isTesting() const { return m_Testing; }
1160
1163 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1164 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1165
1168 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1169
1174 void CheckBattleMasters();
1175
1177 {
1178 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1179 if (itr != mBattleMastersMap.end())
1180 return itr->second;
1182 }
1183
1184 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1185 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1186 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1187 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1188 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1189 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1190 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1191 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1192
1193private:
1194 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1197
1198 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1200
1202
1203 std::vector<uint64> m_QueueUpdateScheduler;
1204 bool m_ArenaTesting;
1205 bool m_Testing;
1210
1212 {
1213 auto const& itr = _battlegroundTemplates.find(id);
1214 if (itr != _battlegroundTemplates.end())
1215 return &itr->second;
1216
1217 return nullptr;
1218 }
1219
1221 {
1222 auto const& itr = _battlegroundMapTemplates.find(mapId);
1223 if (itr != _battlegroundMapTemplates.end())
1224 return itr->second;
1225
1226 return nullptr;
1227 }
1228
1229 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1230
1231 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1232 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1235};
1236
1237#define sBattlegroundMgr BattlegroundMgr::instance()
1238
1239#endif

◆ 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:
1114{
1115 BattlegroundContainer _Battlegrounds;
1116 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1117 BGFreeSlotQueueContainer BGFreeSlotQueue;
1118};
1119
1121{
1123 uint16 MinPlayersPerTeam;
1124 uint16 MaxPlayersPerTeam;
1125 uint8 MinLevel;
1126 uint8 MaxLevel;
1127 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1128 float MaxStartDistSq;
1129 uint8 Weight;
1130 uint32 ScriptId;
1131 BattlemasterListEntry const* BattlemasterEntry;
1132
1133 bool IsArena() const;
1134};
1135
1136class BattlegroundMgr
1137{
1138private:
1141
1142public:
1143 static BattlegroundMgr* instance();
1144
1145 void Update(uint32 diff);
1146
1147 /* Packet Building */
1150 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1152 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);
1154
1155 /* Battlegrounds */
1159 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1160 std::vector<Battleground const*> GetActiveBattlegrounds();
1161
1162 void AddBattleground(Battleground* bg);
1163 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1165 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1167
1170
1171 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1172
1173 /* Battleground queues */
1175 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1177
1178 void ToggleArenaTesting();
1179 void ToggleTesting();
1180
1181 void SetHolidayWeekends(uint32 mask);
1182
1183 bool isArenaTesting() const { return m_ArenaTesting; }
1184 bool isTesting() const { return m_Testing; }
1185
1188 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1189 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1190
1193 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1194
1199 void CheckBattleMasters();
1200
1202 {
1203 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1204 if (itr != mBattleMastersMap.end())
1205 return itr->second;
1207 }
1208
1209 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1210 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1211 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1212 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1213 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1214 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1215 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1216 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1217
1218private:
1219 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1222
1223 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1225
1227
1228 std::vector<uint64> m_QueueUpdateScheduler;
1229 bool m_ArenaTesting;
1230 bool m_Testing;
1235
1237 {
1238 auto const& itr = _battlegroundTemplates.find(id);
1239 if (itr != _battlegroundTemplates.end())
1240 return &itr->second;
1241
1242 return nullptr;
1243 }
1244
1246 {
1247 auto const& itr = _battlegroundMapTemplates.find(mapId);
1248 if (itr != _battlegroundMapTemplates.end())
1249 return itr->second;
1250
1251 return nullptr;
1252 }
1253
1254 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1255
1256 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1257 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1260};
1261
1262#define sBattlegroundMgr BattlegroundMgr::instance()
1263
1264#endif

Referenced by BGArenaType().

◆ queueToBg

std::unordered_map< int, BattlegroundTypeId > BattlegroundMgr::queueToBg
static
Initial value:
1037{
1038 BattlegroundContainer _Battlegrounds;
1039 std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
1040 BGFreeSlotQueueContainer BGFreeSlotQueue;
1041};
1042
1044{
1046 uint16 MinPlayersPerTeam;
1047 uint16 MaxPlayersPerTeam;
1048 uint8 MinLevel;
1049 uint8 MaxLevel;
1050 std::array<Position, PVP_TEAMS_COUNT> StartLocation;
1051 float MaxStartDistSq;
1052 uint8 Weight;
1053 uint32 ScriptId;
1054 BattlemasterListEntry const* BattlemasterEntry;
1055
1056 bool IsArena() const;
1057};
1058
1059class BattlegroundMgr
1060{
1061private:
1064
1065public:
1066 static BattlegroundMgr* instance();
1067
1068 void Update(uint32 diff);
1069
1070 /* Packet Building */
1073 void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
1075 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);
1077
1078 /* Battlegrounds */
1082 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
1083 std::vector<Battleground const*> GetActiveBattlegrounds();
1084
1085 void AddBattleground(Battleground* bg);
1086 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
1088 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
1090
1093
1094 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
1095
1096 /* Battleground queues */
1098 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
1100
1101 void ToggleArenaTesting();
1102 void ToggleTesting();
1103
1104 void SetHolidayWeekends(uint32 mask);
1105
1106 bool isArenaTesting() const { return m_ArenaTesting; }
1107 bool isTesting() const { return m_Testing; }
1108
1111 static bool IsArenaType(BattlegroundTypeId bgTypeId);
1112 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
1113
1116 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
1117
1122 void CheckBattleMasters();
1123
1125 {
1126 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
1127 if (itr != mBattleMastersMap.end())
1128 return itr->second;
1130 }
1131
1132 static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
1133 static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
1134 static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
1135 static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
1136 static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
1137 static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
1138 static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
1139 static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
1140
1141private:
1142 bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
1145
1146 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
1148
1150
1151 std::vector<uint64> m_QueueUpdateScheduler;
1152 bool m_ArenaTesting;
1153 bool m_Testing;
1158
1160 {
1161 auto const& itr = _battlegroundTemplates.find(id);
1162 if (itr != _battlegroundTemplates.end())
1163 return &itr->second;
1164
1165 return nullptr;
1166 }
1167
1169 {
1170 auto const& itr = _battlegroundMapTemplates.find(mapId);
1171 if (itr != _battlegroundMapTemplates.end())
1172 return itr->second;
1173
1174 return nullptr;
1175 }
1176
1177 typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
1178
1179 typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
1180 typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
1183};
1184
1185#define sBattlegroundMgr BattlegroundMgr::instance()
1186
1187#endif

Referenced by BGTemplateId().


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