diff options
author | megamage <none@none> | 2009-08-06 17:45:37 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-08-06 17:45:37 -0500 |
commit | 7f8ce1d80950b2bd680d0f8cc8ad44e4835e0d1a (patch) | |
tree | c351b74f6b247e0edc25a4e566c011ac3717a1e7 /src/game/BattleGround.cpp | |
parent | e8556b879d36ad8899d6eb40e98f6de6d420a275 (diff) |
[8315] Fixed memory leaks (mostly at server shutdown) and code cleanups. Author: VladimirMangos
* Fixed leak in BattleGround::m_PlayerScores at BattleGround::Reset,
add and use BattleGroundScoreMap typedef
* Delete AreaTeam objects stored in global map at shutdown
* Delete Corpse objects stored in global map at shutdown
* Store guild bank log entries as objectes instead pointers in log event lists
--HG--
branch : trunk
Diffstat (limited to 'src/game/BattleGround.cpp')
-rw-r--r-- | src/game/BattleGround.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 3f9aa26def7..0135968b4be 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -207,16 +207,13 @@ BattleGround::~BattleGround() // (this is done automatically in mapmanager update, when the instance is reset after the reset time) int size = m_BgCreatures.size(); for(int i = 0; i < size; ++i) - { DelCreature(i); - } + size = m_BgObjects.size(); for(int i = 0; i < size; ++i) - { DelObject(i); - } - if(GetInstanceID()) // not spam by useless queries in case BG templates + if (GetInstanceID()) // not spam by useless queries in case BG templates { // delete creature and go respawn times WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'",GetInstanceID()); @@ -233,6 +230,9 @@ BattleGround::~BattleGround() ((BattleGroundMap*)map)->SetUnload(); // remove from bg free slot queue this->RemoveFromBGFreeSlotQueue(); + + for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr) + delete itr->second; } void BattleGround::Update(uint32 diff) @@ -967,7 +967,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac participant = true; } - std::map<uint64, BattleGroundScore*>::iterator itr2 = m_PlayerScores.find(guid); + BattleGroundScoreMap::iterator itr2 = m_PlayerScores.find(guid); if (itr2 != m_PlayerScores.end()) { delete itr2->second; // delete player's score @@ -1109,6 +1109,9 @@ void BattleGround::Reset() m_InBGFreeSlotQueue = false; m_Players.clear(); + + for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr) + delete itr->second; m_PlayerScores.clear(); ResetBGSubclass(); @@ -1348,7 +1351,7 @@ bool BattleGround::HasFreeSlots() const void BattleGround::UpdatePlayerScore(Player *Source, uint32 type, uint32 value) { //this procedure is called from virtual function implemented in bg subclass - std::map<uint64, BattleGroundScore*>::const_iterator itr = m_PlayerScores.find(Source->GetGUID()); + BattleGroundScoreMap::const_iterator itr = m_PlayerScores.find(Source->GetGUID()); if(itr == m_PlayerScores.end()) // player not found... return; |