diff options
-rw-r--r-- | src/game/BattleGroundHandler.cpp | 4 | ||||
-rw-r--r-- | src/game/BattleGroundMgr.cpp | 41 | ||||
-rw-r--r-- | src/game/BattleGroundMgr.h | 5 |
3 files changed, 22 insertions, 28 deletions
diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 15e3c1e2018..e779f2a8ab1 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -651,10 +651,6 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recv_data) return; } - //check if any arena enabled - if (!sBattleGroundMgr.isAnyArenaEnabled()) - return; - //check existance BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(BATTLEGROUND_AA); if (!bg) diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index c998d3a8a35..b41c708a236 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -1550,42 +1550,35 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI { // get the template BG BattleGround *bg_template = GetBattleGroundTemplate(bgTypeId); + BattleGroundTypeIdList *enabledBGsOrArenas = NULL; + if (!bg_template) { sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId); return NULL; } + bool isRandom = false; - //for arenas there is random map used if (bg_template->isArena()) + enabledBGsOrArenas = &m_EnabledArenas; + else if (bgTypeId == BATTLEGROUND_RB) { - if (!isAnyArenaEnabled()) // it's checked in handler but just to be sure - return NULL; - uint8 size = m_EnabledArenas.size() - 1; - bgTypeId = m_EnabledArenas[urand(0,size)]; - bg_template = GetBattleGroundTemplate(bgTypeId); - if (!bg_template) - { - sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId); - return NULL; - } + enabledBGsOrArenas = &m_EnabledBGs; + isRandom = true; } - bool isRandom = false; - - if (bgTypeId==BATTLEGROUND_RB) + if (enabledBGsOrArenas) { - // BATTLEGROUND_IC not works - BattleGroundTypeId random_bgs[] = {BATTLEGROUND_AV, BATTLEGROUND_WS, BATTLEGROUND_AB, BATTLEGROUND_EY, BATTLEGROUND_SA}; - uint32 bg_num = urand(0,4); - bgTypeId = random_bgs[bg_num]; + if (!enabledBGsOrArenas->size()) + return NULL; + uint8 size = enabledBGsOrArenas->size() - 1; + bgTypeId = enabledBGsOrArenas->at(urand(0,size)); bg_template = GetBattleGroundTemplate(bgTypeId); if (!bg_template) { sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId); return NULL; } - isRandom = true; } BattleGround *bg = NULL; @@ -1812,9 +1805,13 @@ void BattleGroundMgr::CreateInitialBattleGrounds() if (!CreateBattleGround(bgTypeID, IsArena, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, bl->name[sWorld.GetDefaultDbcLocale()], bl->mapid[0], AStartLoc[0], AStartLoc[1], AStartLoc[2], AStartLoc[3], HStartLoc[0], HStartLoc[1], HStartLoc[2], HStartLoc[3])) continue; - if (IsArena && bgTypeID != BATTLEGROUND_AA) - m_EnabledArenas.push_back(bgTypeID); - + if (IsArena) + { + if (bgTypeID != BATTLEGROUND_AA) + m_EnabledArenas.push_back(bgTypeID); + } + else if (bgTypeID != BATTLEGROUND_RB) + m_EnabledBGs.push_back(bgTypeID); ++count; } while (result->NextRow()); diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h index dae25ac91cb..569651a95b3 100644 --- a/src/game/BattleGroundMgr.h +++ b/src/game/BattleGroundMgr.h @@ -254,13 +254,14 @@ class BattleGroundMgr static BattleGroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday); static bool IsBGWeekend(BattleGroundTypeId bgTypeId); void DoCompleteAchievement(uint32 achievement, Player * player = NULL); - bool isAnyArenaEnabled() const { return m_EnabledArenas.size() != 0; } private: BattleMastersMap mBattleMastersMap; + typedef std::vector<BattleGroundTypeId> BattleGroundTypeIdList; /* Battlegrounds */ BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID]; - std::vector<BattleGroundTypeId> m_EnabledArenas; + BattleGroundTypeIdList m_EnabledArenas; + BattleGroundTypeIdList m_EnabledBGs; std::vector<uint64> m_QueueUpdateScheduler; std::set<uint32> m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; //the instanceids just visible for the client uint32 m_NextRatingDiscardUpdate; |