Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
BattlegroundMgr.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef SF_BATTLEGROUNDMGR_H
7#define SF_BATTLEGROUNDMGR_H
8
9#include "Battleground.h"
10#include "BattlegroundQueue.h"
11#include "Common.h"
12#include "DBCEnums.h"
13#include "Platform/Singleton.h"
14
15typedef std::map<uint32, Battleground*> BattlegroundContainer;
16typedef std::set<uint32> BattlegroundClientIdsContainer;
17
19
20#define WS_CURRENCY_RESET_TIME 20001 // Custom worldstate
21
43
50
52{
53 friend class Skyfire::Singleton<BattlegroundMgr, Skyfire::NullMutex>;
54
55private:
58
59public:
60 void Update(uint32 diff);
61
62 /* Packet Building */
63 void BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, uint64 guid);
64 void BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint64 guid);
65 void BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId);
66 void BuildStatusFailedPacket(WorldPacket* data, Battleground* bg, Player* pPlayer, uint8 QueueSlot, GroupJoinBattlegroundResult result);
67 void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value);
68 void BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg);
69 void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, Player* player, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType);
70 void BuildPlaySoundPacket(WorldPacket* data, uint32 soundId);
71 void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid);
72
73 /* Battlegrounds */
74 Battleground* GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId);
75 Battleground* GetBattleground(uint32 InstanceID, BattlegroundTypeId bgTypeId);
76 Battleground* GetBattlegroundTemplate(BattlegroundTypeId bgTypeId);
77 Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
78
79 void AddBattleground(Battleground* bg);
80 void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
81 void AddToBGFreeSlotQueue(BattlegroundTypeId bgTypeId, Battleground* bg);
82 void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
83 BGFreeSlotQueueContainer& GetBGFreeSlotQueueStore(BattlegroundTypeId bgTypeId);
84
87
88 void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
89
90 /* Battleground queues */
91 BattlegroundQueue& GetBattlegroundQueue(BattlegroundQueueTypeId bgQueueTypeId) { return m_BattlegroundQueues[bgQueueTypeId]; }
92 void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
94
95 void ToggleArenaTesting();
96 void ToggleTesting();
97
98 void SetHolidayWeekends(uint32 mask);
99
100 bool isArenaTesting() const { return m_ArenaTesting; }
101 bool isTesting() const { return m_Testing; }
102
105 static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
106
109 static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
110
115 {
116 BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
117 if (itr != mBattleMastersMap.end())
118 return itr->second;
120 }
121
122private:
125 static bool IsArenaType(BattlegroundTypeId bgTypeId);
127
128 typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
130
132
146
147 typedef std::map<BattlegroundTypeId, uint8> BattlegroundSelectionWeightMap; // TypeId and its selectionWeight
150 std::vector<ScheduledQueueUpdate> m_QueueUpdateScheduler;
155};
156
157#define sBattlegroundMgr Skyfire::Singleton<BattlegroundMgr, Skyfire::NullMutex>::instance()
158#endif
std::map< uint32, Battleground * > BattlegroundContainer
std::set< uint32 > BattlegroundClientIdsContainer
UNORDERED_MAP< uint32, BattlegroundTypeId > BattleMastersMap
std::list< Battleground * > BGFreeSlotQueueContainer
#define MAX_BATTLEGROUND_BRACKETS
Definition DBCEnums.h:34
BattlegroundBracketId
Definition DBCEnums.h:28
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
BattlegroundQueueTypeId
@ MAX_BATTLEGROUND_QUEUE_TYPES
BattlegroundTypeId
HolidayIds
#define UNORDERED_MAP
Battleground * GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId)
void BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value)
void BuildPlayerJoinedBattlegroundPacket(WorldPacket *data, uint64 guid)
bool CreateBattleground(CreateBattlegroundData &data)
void AddToBGFreeSlotQueue(BattlegroundTypeId bgTypeId, Battleground *bg)
BattlegroundSelectionWeightMap m_BGSelectionWeights
std::vector< ScheduledQueueUpdate > m_QueueUpdateScheduler
std::map< BattlegroundTypeId, uint8 > BattlegroundSelectionWeightMap
Battleground * GetBattleground(uint32 InstanceID, BattlegroundTypeId bgTypeId)
void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId)
uint32 GetMaxRatingDifference() const
BattlegroundTypeId GetRandomBG(BattlegroundTypeId id)
void CreateInitialBattlegrounds()
std::map< BattlegroundTypeId, BattlegroundData > BattlegroundDataContainer
BattlegroundQueue m_BattlegroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES]
static bool IsArenaType(BattlegroundTypeId bgTypeId)
BGFreeSlotQueueContainer & GetBGFreeSlotQueueStore(BattlegroundTypeId bgTypeId)
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
bool isArenaTesting() const
BattlegroundQueue & GetBattlegroundQueue(BattlegroundQueueTypeId bgQueueTypeId)
void AddBattleground(Battleground *bg)
void BuildBattlegroundStatusPacket(WorldPacket *data, Battleground *bg, Player *player, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType)
static BattlegroundTypeId BGTemplateId(BattlegroundQueueTypeId bgQueueTypeId)
void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId)
BattleMastersMap mBattleMastersMap
void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
Battleground * CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const *bracketEntry, uint8 arenaType, bool isRated)
BattlegroundSelectionWeightMap m_ArenaSelectionWeights
void SendToBattleground(Player *player, uint32 InstanceID, BattlegroundTypeId bgTypeId)
void SetHolidayWeekends(uint32 mask)
void BuildPvpLogDataPacket(WorldPacket *data, Battleground *bg)
uint32 GetRatingDiscardTimer() const
static BattlegroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday)
void BuildStatusFailedPacket(WorldPacket *data, Battleground *bg, Player *pPlayer, uint8 QueueSlot, GroupJoinBattlegroundResult result)
static HolidayIds BGTypeToWeekendHolidayId(BattlegroundTypeId bgTypeId)
void BuildBattlegroundListPacket(WorldPacket *data, uint64 guid, Player *player, BattlegroundTypeId bgTypeId)
BattlegroundTypeId GetBattleMasterBG(uint32 entry) const
Battleground * GetBattlegroundTemplate(BattlegroundTypeId bgTypeId)
void BuildPlaySoundPacket(WorldPacket *data, uint32 soundId)
void BuildPlayerLeftBattlegroundPacket(WorldPacket *data, uint64 guid)
uint32 GetPrematureFinishTime() const
uint32 CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
void Update(uint32 diff)
uint32 m_NextRatedArenaUpdate
bool isTesting() const
void SendAreaSpiritHealerQueryOpcode(Player *player, Battleground *bg, uint64 guid)
static bool IsBGWeekend(BattlegroundTypeId bgTypeId)
static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId)
BattlegroundDataContainer bgDataStore
BattlegroundContainer m_Battlegrounds
BattlegroundClientIdsContainer m_ClientBattlegroundIds[MAX_BATTLEGROUND_BRACKETS]
BGFreeSlotQueueContainer BGFreeSlotQueue
bool operator==(ScheduledQueueUpdate const &right) const
BattlegroundTypeId bgTypeId