Skip to content

Commit

Permalink
Core: Fix crash in ~ScriptMgr
Browse files Browse the repository at this point in the history
  • Loading branch information
Machiavell1 committed Mar 14, 2011
1 parent 68c09e8 commit 1e773eb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
34 changes: 19 additions & 15 deletions src/server/game/Scripting/ScriptMgr.cpp
Expand Up @@ -140,6 +140,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) \
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/server/game/Scripting/ScriptMgr.h
Expand Up @@ -760,7 +760,7 @@ class ScriptMgr
friend class ScriptObject;

ScriptMgr();
~ScriptMgr();
virtual ~ScriptMgr();

uint32 _scriptCount;

Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/server/worldserver/WorldThread/WorldRunnable.cpp
Expand Up @@ -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();
}

0 comments on commit 1e773eb

Please sign in to comment.