From 400caec7099addf7329396800341c0f9070da734 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Mon, 21 Feb 2022 06:36:48 +0100 Subject: [PATCH] feat(Core/Battlegrounds): Min level of selected random bg must be lower than pvp bracket level. (#10752) --- src/server/game/Battlegrounds/BattlegroundMgr.cpp | 11 +++++++---- src/server/game/Battlegrounds/BattlegroundMgr.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 422e9b3b9..83db84524 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -259,7 +259,7 @@ uint32 BattlegroundMgr::GetNextClientVisibleInstanceId() // create a new battleground that will really be used to play Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId originalBgTypeId, uint32 minLevel, uint32 maxLevel, uint8 arenaType, bool isRated) { - BattlegroundTypeId bgTypeId = GetRandomBG(originalBgTypeId); + BattlegroundTypeId bgTypeId = GetRandomBG(originalBgTypeId, minLevel); if (originalBgTypeId == BATTLEGROUND_AA) originalBgTypeId = bgTypeId; @@ -769,7 +769,7 @@ bool BattlegroundMgr::IsBGWeekend(BattlegroundTypeId bgTypeId) return IsHolidayActive(BGTypeToWeekendHolidayId(bgTypeId)); } -BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId) +BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId, uint32 minLevel) { if (GetBattlegroundTemplateByTypeId(bgTypeId)) { @@ -786,8 +786,11 @@ BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId) if (CreateBattlegroundData const* bg = GetBattlegroundTemplateByMapId(mapId)) { - ids.push_back(bg->bgTypeId); - weights.push_back(bg->Weight); + if (bg->LevelMin <= minLevel) + { + ids.push_back(bg->bgTypeId); + weights.push_back(bg->Weight); + } } } diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index f4a19e5f8..b57420205 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -134,7 +134,7 @@ public: private: bool CreateBattleground(CreateBattlegroundData& data); uint32 GetNextClientVisibleInstanceId(); - BattlegroundTypeId GetRandomBG(BattlegroundTypeId id); + BattlegroundTypeId GetRandomBG(BattlegroundTypeId id, uint32 minLevel); typedef std::map BattlegroundTemplateContainer; BattlegroundTemplateContainer m_BattlegroundTemplates;