[11429] Cleanup code for m_ClientBattleGroundIds.

This commit is contained in:
VladimirMangos 2011-05-04 15:28:37 +04:00
parent 75a9379fa7
commit e47031b55c
3 changed files with 9 additions and 7 deletions

View file

@ -1459,13 +1459,14 @@ uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeI
// the following works, because std::set is default ordered with "<" // the following works, because std::set is default ordered with "<"
// the optimalization would be to use as bitmask std::vector<uint32> - but that would only make code unreadable // the optimalization would be to use as bitmask std::vector<uint32> - but that would only make code unreadable
uint32 lastId = 0; uint32 lastId = 0;
for(std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][bracket_id].begin(); itr != m_ClientBattleGroundIds[bgTypeId][bracket_id].end();) ClientBattleGroundIdSet& ids = m_ClientBattleGroundIds[bgTypeId][bracket_id];
for(ClientBattleGroundIdSet::const_iterator itr = ids.begin(); itr != ids.end();)
{ {
if( (++lastId) != *itr) //if there is a gap between the ids, we will break.. if( (++lastId) != *itr) //if there is a gap between the ids, we will break..
break; break;
lastId = *itr; lastId = *itr;
} }
m_ClientBattleGroundIds[bgTypeId][bracket_id].insert(lastId + 1); ids.insert(lastId + 1);
return lastId + 1; return lastId + 1;
} }
@ -1831,7 +1832,8 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, ObjectGuid
if(PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(),plr->getLevel())) if(PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(),plr->getLevel()))
{ {
BattleGroundBracketId bracketId = bracketEntry->GetBracketId(); BattleGroundBracketId bracketId = bracketEntry->GetBracketId();
for(std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][bracketId].begin(); itr != m_ClientBattleGroundIds[bgTypeId][bracketId].end();++itr) ClientBattleGroundIdSet const& ids = m_ClientBattleGroundIds[bgTypeId][bracketId];
for(ClientBattleGroundIdSet::const_iterator itr = ids.begin(); itr != ids.end();++itr)
{ {
*data << uint32(*itr); *data << uint32(*itr);
++count; ++count;

View file

@ -216,8 +216,7 @@ class BattleGroundMgr
uint32 CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id); uint32 CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id);
void DeleteClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id, uint32 clientInstanceID) void DeleteClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id, uint32 clientInstanceID)
{ {
if (!m_ClientBattleGroundIds[bgTypeId][bracket_id].empty()) m_ClientBattleGroundIds[bgTypeId][bracket_id].erase(clientInstanceID);
m_ClientBattleGroundIds[bgTypeId][bracket_id].erase(clientInstanceID);
} }
void CreateInitialBattleGrounds(); void CreateInitialBattleGrounds();
@ -287,7 +286,8 @@ class BattleGroundMgr
/* Battlegrounds */ /* Battlegrounds */
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID]; BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
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 typedef std::set<uint32> ClientBattleGroundIdSet;
ClientBattleGroundIdSet m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; //the instanceids just visible for the client
uint32 m_NextRatingDiscardUpdate; uint32 m_NextRatingDiscardUpdate;
time_t m_NextAutoDistributionTime; time_t m_NextAutoDistributionTime;
uint32 m_AutoDistributionTimeChecker; uint32 m_AutoDistributionTimeChecker;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11428" #define REVISION_NR "11429"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__