mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Scripting: Fix acquiring of references between script swaps
* Delay unloading of shared libraries to the next update tick
to prevent crashes in the destructor of the last referenced
script instance.
* Closes #17557
(cherry picked from commit 445746c402)
This commit is contained in:
@@ -987,7 +987,7 @@ void ScriptMgr::Initialize()
|
||||
FillSpellSummary();
|
||||
|
||||
// Load core scripts
|
||||
SetScriptContext("___static___");
|
||||
SetScriptContext(GetNameOfStaticContext());
|
||||
|
||||
// SmartAI
|
||||
AddSC_SmartScripts();
|
||||
@@ -1042,6 +1042,12 @@ void ScriptMgr::SwapScriptContext(bool initialize)
|
||||
_currentContext.clear();
|
||||
}
|
||||
|
||||
std::string const& ScriptMgr::GetNameOfStaticContext()
|
||||
{
|
||||
static std::string const name = "___static___";
|
||||
return name;
|
||||
}
|
||||
|
||||
void ScriptMgr::ReleaseScriptContext(std::string const& context)
|
||||
{
|
||||
sScriptRegistryCompositum->ReleaseContext(context);
|
||||
|
||||
Reference in New Issue
Block a user