Random BG: never select a disabled bg

--HG--
branch : trunk
This commit is contained in:
Spp
2010-05-31 20:53:43 +02:00
parent 973c837729
commit 08a20ef8a2
3 changed files with 25 additions and 31 deletions
-4
View File
@@ -651,10 +651,6 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recv_data)
return; return;
} }
//check if any arena enabled
if (!sBattleGroundMgr.isAnyArenaEnabled())
return;
//check existance //check existance
BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(BATTLEGROUND_AA); BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(BATTLEGROUND_AA);
if (!bg) if (!bg)
+22 -25
View File
@@ -1550,42 +1550,35 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
{ {
// get the template BG // get the template BG
BattleGround *bg_template = GetBattleGroundTemplate(bgTypeId); BattleGround *bg_template = GetBattleGroundTemplate(bgTypeId);
BattleGroundTypeIdList *enabledBGsOrArenas = NULL;
if (!bg_template) if (!bg_template)
{ {
sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId); sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId);
return NULL; return NULL;
} }
//for arenas there is random map used
if (bg_template->isArena())
{
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;
}
}
bool isRandom = false; bool isRandom = false;
if (bgTypeId==BATTLEGROUND_RB) if (bg_template->isArena())
enabledBGsOrArenas = &m_EnabledArenas;
else if (bgTypeId == BATTLEGROUND_RB)
{ {
// BATTLEGROUND_IC not works enabledBGsOrArenas = &m_EnabledBGs;
BattleGroundTypeId random_bgs[] = {BATTLEGROUND_AV, BATTLEGROUND_WS, BATTLEGROUND_AB, BATTLEGROUND_EY, BATTLEGROUND_SA}; isRandom = true;
uint32 bg_num = urand(0,4); }
bgTypeId = random_bgs[bg_num];
if (enabledBGsOrArenas)
{
if (!enabledBGsOrArenas->size())
return NULL;
uint8 size = enabledBGsOrArenas->size() - 1;
bgTypeId = enabledBGsOrArenas->at(urand(0,size));
bg_template = GetBattleGroundTemplate(bgTypeId); bg_template = GetBattleGroundTemplate(bgTypeId);
if (!bg_template) if (!bg_template)
{ {
sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId); sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId);
return NULL; return NULL;
} }
isRandom = true;
} }
BattleGround *bg = NULL; 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])) 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; continue;
if (IsArena && bgTypeID != BATTLEGROUND_AA) if (IsArena)
m_EnabledArenas.push_back(bgTypeID); {
if (bgTypeID != BATTLEGROUND_AA)
m_EnabledArenas.push_back(bgTypeID);
}
else if (bgTypeID != BATTLEGROUND_RB)
m_EnabledBGs.push_back(bgTypeID);
++count; ++count;
} while (result->NextRow()); } while (result->NextRow());
+3 -2
View File
@@ -254,13 +254,14 @@ class BattleGroundMgr
static BattleGroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday); static BattleGroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday);
static bool IsBGWeekend(BattleGroundTypeId bgTypeId); static bool IsBGWeekend(BattleGroundTypeId bgTypeId);
void DoCompleteAchievement(uint32 achievement, Player * player = NULL); void DoCompleteAchievement(uint32 achievement, Player * player = NULL);
bool isAnyArenaEnabled() const { return m_EnabledArenas.size() != 0; }
private: private:
BattleMastersMap mBattleMastersMap; BattleMastersMap mBattleMastersMap;
typedef std::vector<BattleGroundTypeId> BattleGroundTypeIdList;
/* Battlegrounds */ /* Battlegrounds */
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID]; BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
std::vector<BattleGroundTypeId> m_EnabledArenas; BattleGroundTypeIdList m_EnabledArenas;
BattleGroundTypeIdList m_EnabledBGs;
std::vector<uint64> m_QueueUpdateScheduler; std::vector<uint64> m_QueueUpdateScheduler;
std::set<uint32> m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; //the instanceids just visible for the client std::set<uint32> m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; //the instanceids just visible for the client
uint32 m_NextRatingDiscardUpdate; uint32 m_NextRatingDiscardUpdate;