Core: Some optimizations
- Declare some functions const - Fix some mem leak - Fix some resource leak - Remove unused variables and functions - Remove duplicate functions - Reduce the scope of some variables - Remove unused file --HG-- branch : trunk
This commit is contained in:
@@ -1803,7 +1803,7 @@ void Battleground::HandleKillPlayer(Player *player, Player *killer)
|
||||
|
||||
// return the player's team based on battlegroundplayer info
|
||||
// used in same faction arena matches mainly
|
||||
uint32 Battleground::GetPlayerTeam(uint64 guid)
|
||||
uint32 Battleground::GetPlayerTeam(uint64 guid) const
|
||||
{
|
||||
BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid);
|
||||
if (itr != m_Players.end())
|
||||
@@ -1811,12 +1811,12 @@ uint32 Battleground::GetPlayerTeam(uint64 guid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 Battleground::GetOtherTeam(uint32 teamId)
|
||||
uint32 Battleground::GetOtherTeam(uint32 teamId) const
|
||||
{
|
||||
return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0;
|
||||
}
|
||||
|
||||
bool Battleground::IsPlayerInBattleground(uint64 guid)
|
||||
bool Battleground::IsPlayerInBattleground(uint64 guid) const
|
||||
{
|
||||
BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid);
|
||||
if (itr != m_Players.end())
|
||||
@@ -1935,13 +1935,13 @@ void Battleground::RewardXPAtKill(Player* plr, Player* victim)
|
||||
return;
|
||||
|
||||
uint32 xp = 0;
|
||||
uint32 count = 0;
|
||||
uint32 sum_level = 0;
|
||||
Player* member_with_max_level = NULL;
|
||||
Player* not_gray_member_with_max_level = NULL;
|
||||
|
||||
if (Group *pGroup = plr->GetGroup())//should be always in a raid group while in any bg
|
||||
{
|
||||
uint32 count = 0;
|
||||
uint32 sum_level = 0;
|
||||
for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
Player* member = itr->getSource();
|
||||
|
||||
@@ -373,7 +373,7 @@ class Battleground
|
||||
uint32 GetScriptId() const { return ScriptId; }
|
||||
uint32 GetBattlemasterEntry() const;
|
||||
uint32 GetBonusHonorFromKill(uint32 kills) const;
|
||||
bool IsRandom() { return m_IsRandom; }
|
||||
bool IsRandom() const { return m_IsRandom; }
|
||||
|
||||
// Set methods:
|
||||
void SetName(char const* Name) { m_Name = Name; }
|
||||
@@ -569,9 +569,9 @@ class Battleground
|
||||
virtual bool HandlePlayerUnderMap(Player * /*plr*/) { return false; }
|
||||
|
||||
// since arenas can be AvA or Hvh, we have to get the "temporary" team of a player
|
||||
uint32 GetPlayerTeam(uint64 guid);
|
||||
uint32 GetOtherTeam(uint32 teamId);
|
||||
bool IsPlayerInBattleground(uint64 guid);
|
||||
uint32 GetPlayerTeam(uint64 guid) const;
|
||||
uint32 GetOtherTeam(uint32 teamId) const;
|
||||
bool IsPlayerInBattleground(uint64 guid) const;
|
||||
|
||||
void SetDeleteThis() {m_SetDeleteThis = true;}
|
||||
|
||||
|
||||
@@ -900,7 +900,6 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket *data, const uint6
|
||||
else // battleground
|
||||
{
|
||||
size_t count_pos = data->wpos();
|
||||
uint32 count = 0;
|
||||
*data << uint32(0); // number of bg instances
|
||||
|
||||
if (Battleground* bgTemplate = sBattlegroundMgr.GetBattlegroundTemplate(bgTypeId))
|
||||
@@ -908,6 +907,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket *data, const uint6
|
||||
// expected bracket entry
|
||||
if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(),plr->getLevel()))
|
||||
{
|
||||
uint32 count = 0;
|
||||
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
|
||||
for (std::set<uint32>::iterator itr = m_ClientBattlegroundIds[bgTypeId][bracketId].begin(); itr != m_ClientBattlegroundIds[bgTypeId][bracketId].end();++itr)
|
||||
{
|
||||
|
||||
@@ -258,7 +258,7 @@ void BattlegroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* g
|
||||
(*lastPlayerAddedPointer) %= COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME;
|
||||
}
|
||||
|
||||
uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id)
|
||||
uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id) const
|
||||
{
|
||||
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
|
||||
if (!ginfo->ArenaType)
|
||||
|
||||
@@ -80,7 +80,7 @@ class BattlegroundQueue
|
||||
bool IsPlayerInvited(const uint64& pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime);
|
||||
bool GetPlayerGroupInfoData(const uint64& guid, GroupQueueInfo* ginfo);
|
||||
void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id);
|
||||
uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id);
|
||||
uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id) const;
|
||||
|
||||
typedef std::map<uint64, PlayerQueueInfo> QueuedPlayersMap;
|
||||
QueuedPlayersMap m_QueuedPlayers;
|
||||
|
||||
Reference in New Issue
Block a user