aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Battlegrounds/BattlegroundMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Battlegrounds/BattlegroundMgr.cpp')
-rw-r--r--src/server/game/Battlegrounds/BattlegroundMgr.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index b2856d6ef7b..45888bf1332 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -342,10 +342,10 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundQueueTypeId que
return nullptr;
}
- PVPDifficultyEntry const* bracketEntry = DB2Manager::GetBattlegroundBracketById(bg_template->BattlemasterEntry->MapID[0], bracketId);
+ PVPDifficultyEntry const* bracketEntry = DB2Manager::GetBattlegroundBracketById(bg_template->MapIDs.front(), bracketId);
if (!bracketEntry)
{
- TC_LOG_ERROR("bg.battleground", "Battleground: CreateNewBattleground: bg bracket entry not found for map {} bracket id {}", bg_template->BattlemasterEntry->MapID[0], bracketId);
+ TC_LOG_ERROR("bg.battleground", "Battleground: CreateNewBattleground: bg bracket entry not found for map {} bracket id {}", bg_template->MapIDs.front(), bracketId);
return nullptr;
}
@@ -380,6 +380,11 @@ void BattlegroundMgr::LoadBattlegroundTemplates()
return;
}
+ std::unordered_map<BattlegroundTypeId, std::vector<int32>> mapsByBattleground;
+ for (BattlemasterListXMapEntry const* battlemasterListXMap : sBattlemasterListXMapStore)
+ if (sBattlemasterListStore.HasRecord(battlemasterListXMap->BattlemasterListID) && sMapStore.HasRecord(battlemasterListXMap->MapID))
+ mapsByBattleground[BattlegroundTypeId(battlemasterListXMap->BattlemasterListID)].push_back(battlemasterListXMap->MapID);
+
uint32 count = 0;
do
@@ -406,6 +411,7 @@ void BattlegroundMgr::LoadBattlegroundTemplates()
bgTemplate.Weight = fields[4].GetUInt8();
bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[5].GetString());
bgTemplate.BattlemasterEntry = bl;
+ bgTemplate.MapIDs = std::move(mapsByBattleground[bgTypeId]);
if (bgTemplate.Id != BATTLEGROUND_AA && !IsRandomBattleground(bgTemplate.Id))
{
@@ -434,8 +440,8 @@ void BattlegroundMgr::LoadBattlegroundTemplates()
}
}
- if (bgTemplate.BattlemasterEntry->MapID[1] == -1) // in this case we have only one mapId
- _battlegroundMapTemplates[bgTemplate.BattlemasterEntry->MapID[0]] = &_battlegroundTemplates[bgTypeId];
+ if (bgTemplate.MapIDs.size() == 1)
+ _battlegroundMapTemplates[bgTemplate.MapIDs.front()] = &_battlegroundTemplates[bgTypeId];
++count;
}
@@ -681,15 +687,12 @@ BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId)
if (BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId))
{
std::vector<BattlegroundTypeId> ids;
- ids.reserve(16);
+ ids.reserve(bgTemplate->MapIDs.size());
std::vector<double> weights;
- weights.reserve(16);
+ weights.reserve(bgTemplate->MapIDs.size());
double totalWeight = 0.0;
- for (int32 mapId : bgTemplate->BattlemasterEntry->MapID)
+ for (int32 mapId : bgTemplate->MapIDs)
{
- if (mapId == -1)
- break;
-
if (BattlegroundTemplate const* bg = GetBattlegroundTemplateByMapId(mapId))
{
ids.push_back(bg->Id);