From 08a20ef8a2514c709249de370435fa36c47f9ec9 Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 31 May 2010 20:53:43 +0200 Subject: Random BG: never select a disabled bg --HG-- branch : trunk --- src/game/BattleGroundMgr.cpp | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'src/game/BattleGroundMgr.cpp') 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()); -- cgit v1.2.3