diff options
author | Machiavelli <machiavelli.trinity@gmail.com> | 2011-03-14 09:44:02 +0100 |
---|---|---|
committer | Machiavelli <machiavelli.trinity@gmail.com> | 2011-03-14 09:44:02 +0100 |
commit | 31a2c9b82b9b6a8ddee75dd546ad89869e484f73 (patch) | |
tree | 6cd42969066c74e8752acbbfdea6951a18370624 /src | |
parent | 1eed7c53a96aa0e58e71ff08bd86dd9a997eeea3 (diff) |
Core: Fix crash in ~ScriptMgr
Fixes: #854
Fixes: #918
Fixes: #917
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Scripting/ScriptMgr.cpp | 34 | ||||
-rwxr-xr-x | src/server/game/Scripting/ScriptMgr.h | 5 | ||||
-rwxr-xr-x | src/server/worldserver/WorldThread/WorldRunnable.cpp | 1 |
3 files changed, 24 insertions, 16 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 8f8e4175476..8434289ce96 100755 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -141,6 +141,25 @@ ScriptMgr::ScriptMgr() ScriptMgr::~ScriptMgr() { +} + +void ScriptMgr::Initialize() +{ + uint32 oldMSTime = getMSTime(); + + LoadDatabase(); + + sLog->outString("Loading C++ scripts"); + + FillSpellSummary(); + AddScripts(); + + sLog->outString(">> Loaded %u C++ scripts in %u ms", GetScriptCount(), GetMSTimeDiffToNow(oldMSTime)); + sLog->outString(); +} + +void ScriptMgr::Unload() +{ #define SCR_CLEAR(T) \ FOR_SCRIPTS(T, itr, end) \ delete itr->second; \ @@ -175,21 +194,6 @@ ScriptMgr::~ScriptMgr() #undef SCR_CLEAR } -void ScriptMgr::Initialize() -{ - uint32 oldMSTime = getMSTime(); - - LoadDatabase(); - - sLog->outString("Loading C++ scripts"); - - FillSpellSummary(); - AddScripts(); - - sLog->outString(">> Loaded %u C++ scripts in %u ms", GetScriptCount(), GetMSTimeDiffToNow(oldMSTime)); - sLog->outString(); -} - void ScriptMgr::LoadDatabase() { sScriptSystemMgr->LoadVersion(); diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index c2e6a911c62..2078e6bc65f 100755 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -760,7 +760,7 @@ class ScriptMgr friend class ScriptObject; ScriptMgr(); - ~ScriptMgr(); + virtual ~ScriptMgr(); uint32 _scriptCount; @@ -775,6 +775,9 @@ class ScriptMgr void IncrementScriptCount() { ++_scriptCount; } uint32 GetScriptCount() const { return _scriptCount; } + public: /* Unloading */ + void Unload(); + public: /* SpellScriptLoader */ void CreateSpellScripts(uint32 spell_id, std::list<SpellScript*>& script_vector); diff --git a/src/server/worldserver/WorldThread/WorldRunnable.cpp b/src/server/worldserver/WorldThread/WorldRunnable.cpp index 472dd0abf5b..664e767d11f 100755 --- a/src/server/worldserver/WorldThread/WorldRunnable.cpp +++ b/src/server/worldserver/WorldThread/WorldRunnable.cpp @@ -92,4 +92,5 @@ void WorldRunnable::run() sMapMgr->UnloadAll(); // unload all grids (including locked in memory) sObjectAccessor->UnloadAll(); // unload 'i_player2corpse' storage and remove from world + sScriptMgr->Unload(); } |