diff options
Diffstat (limited to 'src/server/game/Battlegrounds')
-rw-r--r-- | src/server/game/Battlegrounds/BattlegroundMgr.cpp | 34 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/BattlegroundMgr.h | 9 |
2 files changed, 36 insertions, 7 deletions
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 2739854926b..b6716c248ae 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -32,6 +32,7 @@ #include "Player.h" #include "SharedDefines.h" #include "World.h" +#include "WorldSession.h" bool BattlegroundTemplate::IsArena() const { @@ -64,7 +65,7 @@ uint8 BattlegroundTemplate::GetMaxLevel() const BattlegroundMgr::BattlegroundMgr() : m_NextRatedArenaUpdate(sWorld->getIntConfig(CONFIG_ARENA_RATED_UPDATE_TIMER)), - m_UpdateTimer(0), m_ArenaTesting(false), m_Testing(false) + m_UpdateTimer(0), m_ArenaTesting(0), m_Testing(false) { } BattlegroundMgr::~BattlegroundMgr() @@ -300,6 +301,15 @@ BattlegroundScriptTemplate const* BattlegroundMgr::FindBattlegroundScriptTemplat return Trinity::Containers::MapGetValuePtr(_battlegroundScriptTemplates, { mapId, BATTLEGROUND_TYPE_NONE }); } +void BattlegroundMgr::QueuePlayerForArena(Player const* player, uint8 teamSize, uint8 roles) +{ + WorldPackets::Battleground::BattlemasterJoinArena packet((WorldPacket(CMSG_BATTLEMASTER_JOIN_ARENA))); + packet.TeamSizeIndex = teamSize; + packet.Roles = roles; + + player->GetSession()->HandleBattlemasterJoinArena(packet); +} + uint32 BattlegroundMgr::CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id) { if (IsArenaType(bgTypeId)) @@ -507,10 +517,23 @@ void BattlegroundMgr::ToggleTesting() sWorld->SendWorldText(m_Testing ? LANG_DEBUG_BG_ON : LANG_DEBUG_BG_OFF); } -void BattlegroundMgr::ToggleArenaTesting() +bool BattlegroundMgr::ToggleArenaTesting(uint32 battlemasterListId) { - m_ArenaTesting = !m_ArenaTesting; - sWorld->SendWorldText(m_ArenaTesting ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF); + if (battlemasterListId != 0) + { + BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(static_cast<BattlegroundTypeId>(battlemasterListId)); + if (!bgTemplate) + return false; + + if (!bgTemplate->IsArena()) + return false; + } + + if (m_ArenaTesting != battlemasterListId) + sWorld->SendWorldText((battlemasterListId != 0) ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF); + + m_ArenaTesting = battlemasterListId; + return true; } bool BattlegroundMgr::IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId) @@ -686,6 +709,9 @@ BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId) { if (BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId)) { + if (bgTemplate->IsArena() && isArenaTesting()) + return static_cast<BattlegroundTypeId>(m_ArenaTesting); + std::vector<BattlegroundTemplate const*> ids; ids.reserve(bgTemplate->MapIDs.size()); for (int32 mapId : bgTemplate->MapIDs) diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index b31b0193af0..8aa341cbca8 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -126,10 +126,11 @@ class TC_GAME_API BattlegroundMgr void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundBracketId bracket_id); uint32 GetPrematureFinishTime() const; - void ToggleArenaTesting(); + // Return whether toggling was successful. In case of a non-existing battlemasterListId, or this battlemasterListId is not an arena, this would return false. + bool ToggleArenaTesting(uint32 battlemasterListId); void ToggleTesting(); - bool isArenaTesting() const { return m_ArenaTesting; } + bool isArenaTesting() const { return m_ArenaTesting != 0; } bool isTesting() const { return m_Testing; } static bool IsRandomBattleground(uint32 battlemasterListId); @@ -162,6 +163,8 @@ class TC_GAME_API BattlegroundMgr void LoadBattlegroundScriptTemplate(); BattlegroundScriptTemplate const* FindBattlegroundScriptTemplate(uint32 mapId, BattlegroundTypeId bgTypeId) const; + static void QueuePlayerForArena(Player const* player, uint8 teamSize, uint8 roles); + private: uint32 CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id); static bool IsArenaType(BattlegroundTypeId bgTypeId); @@ -185,7 +188,7 @@ class TC_GAME_API BattlegroundMgr std::vector<ScheduledQueueUpdate> m_QueueUpdateScheduler; uint32 m_NextRatedArenaUpdate; uint32 m_UpdateTimer; - bool m_ArenaTesting; + uint32 m_ArenaTesting; bool m_Testing; BattleMastersMap mBattleMastersMap; |