aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Scripting/ScriptMgr.cpp
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2016-04-12 16:52:29 +0200
committerNaios <naios-dev@live.de>2016-04-12 16:52:29 +0200
commite82a934387b03a0a70e4d402eb5729c24728a698 (patch)
tree5487bcace2d4f926e79132ec65a8be89beb47373 /src/server/game/Scripting/ScriptMgr.cpp
parent410cf0dd05e2765cf7806a9165f976a2bcc199d2 (diff)
Core/Scripting: Fix an assertion which was triggered at lazy unloading
* Also fixes 2 warnings
Diffstat (limited to 'src/server/game/Scripting/ScriptMgr.cpp')
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 63c4b69f3e9..ca1cd71363e 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -166,7 +166,8 @@ class ScriptRegistryCompositum
public:
void SetScriptNameInContext(std::string const& scriptname, std::string const& context)
{
- ASSERT(_scriptnames_to_context.find(scriptname) == _scriptnames_to_context.end());
+ ASSERT(_scriptnames_to_context.find(scriptname) == _scriptnames_to_context.end(),
+ "Scriptname was assigned to this context already!");
_scriptnames_to_context.insert(std::make_pair(scriptname, context));
}
@@ -180,15 +181,18 @@ public:
void ReleaseContext(std::string const& context) final override
{
+ for (auto const registry : _registries)
+ registry->ReleaseContext(context);
+
+ // Clear the script names in context after calling the release hooks
+ // since it's possible that new references to a shared library
+ // are acquired when releasing.
for (auto itr = _scriptnames_to_context.begin();
itr != _scriptnames_to_context.end();)
if (itr->second == context)
itr = _scriptnames_to_context.erase(itr);
else
++itr;
-
- for (auto const registry : _registries)
- registry->ReleaseContext(context);
}
void SwapContext(bool initialize) final override
@@ -604,7 +608,7 @@ public:
swapped = true;
}
- void BeforeSwapContext(bool initialize) override
+ void BeforeSwapContext(bool /*initialize*/) override
{
swapped = false;
}
@@ -634,7 +638,7 @@ public:
swapped = true;
}
- void BeforeSwapContext(bool initialize) override
+ void BeforeSwapContext(bool /*initialize*/) override
{
if (swapped)
{