aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/BattleGround.cpp6
-rw-r--r--src/game/BattleGroundMgr.cpp21
-rw-r--r--src/game/BattleGroundMgr.h1
-rw-r--r--src/mangosd/WorldRunnable.cpp4
-rw-r--r--src/shared/revision_nr.h2
5 files changed, 27 insertions, 7 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 49d5224c223..cb122fddbcf 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -1359,6 +1359,9 @@ void BattleGround::SpawnBGCreature(uint32 type, uint32 respawntime)
*/
bool BattleGround::DelCreature(uint32 type)
{
+ if(!m_BgCreatures[type])
+ return true;
+
Creature *cr = HashMapHolder<Creature>::Find(m_BgCreatures[type]);
if(!cr)
{
@@ -1374,6 +1377,9 @@ bool BattleGround::DelCreature(uint32 type)
bool BattleGround::DelObject(uint32 type)
{
+ if(!m_BgObjects[type])
+ return true;
+
GameObject *obj = HashMapHolder<GameObject>::Find(m_BgObjects[type]);
if(!obj)
{
diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp
index ddc31f27dfc..f86b6f4915a 100644
--- a/src/game/BattleGroundMgr.cpp
+++ b/src/game/BattleGroundMgr.cpp
@@ -1044,16 +1044,25 @@ BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTe
BattleGroundMgr::~BattleGroundMgr()
{
- BattleGroundSet::iterator itr, next;
- for(itr = m_BattleGrounds.begin(); itr != m_BattleGrounds.end(); itr = next)
+ DeleteAlllBattleGrounds();
+}
+
+void BattleGroundMgr::DeleteAlllBattleGrounds()
+{
+ for(BattleGroundSet::iterator itr = m_BattleGrounds.begin(); itr != m_BattleGrounds.end();)
{
- next = itr;
- ++next;
BattleGround * bg = itr->second;
- m_BattleGrounds.erase(itr);
+ m_BattleGrounds.erase(itr++);
delete bg;
}
- m_BattleGrounds.clear();
+
+ // destroy template battlegrounds that listed only in queues (other already terminated)
+ for(uint32 bgTypeId = 0; bgTypeId < MAX_BATTLEGROUND_TYPE_ID; ++bgTypeId)
+ {
+ // ~BattleGround call unregistring BG from queue
+ while(!BGFreeSlotQueue[bgTypeId].empty())
+ delete BGFreeSlotQueue[bgTypeId].front();
+ }
}
// used to update running battlegrounds, and delete finished ones
diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h
index 578c9c3fe01..2b684487e1e 100644
--- a/src/game/BattleGroundMgr.h
+++ b/src/game/BattleGroundMgr.h
@@ -208,6 +208,7 @@ class BattleGroundMgr
void RemoveBattleGround(uint32 instanceID) { m_BattleGrounds.erase(instanceID); }
void CreateInitialBattleGrounds();
+ void DeleteAlllBattleGrounds();
void SendToBattleGround(Player *pl, uint32 InstanceID);
diff --git a/src/mangosd/WorldRunnable.cpp b/src/mangosd/WorldRunnable.cpp
index 072d3e496c3..0229f7f0f5c 100644
--- a/src/mangosd/WorldRunnable.cpp
+++ b/src/mangosd/WorldRunnable.cpp
@@ -29,6 +29,7 @@
#include "Timer.h"
#include "ObjectAccessor.h"
#include "MapManager.h"
+#include "BattleGroundMgr.h"
#include "Database/DatabaseEnv.h"
@@ -77,6 +78,9 @@ void WorldRunnable::run()
sWorld.KickAll(); // save and kick all players
sWorld.UpdateSessions( 1 ); // real players unload required UpdateSessions call
+ // unload battleground templates before different singletons destroyed
+ sBattleGroundMgr.DeleteAlllBattleGrounds();
+
sWorldSocketMgr->StopNetwork();
MapManager::Instance().UnloadAll(); // unload all grids (including locked in memory)
diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h
index 62411a004fa..4ffcae7a663 100644
--- a/src/shared/revision_nr.h
+++ b/src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "7256"
+ #define REVISION_NR "7257"
#endif // __REVISION_NR_H__