mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Core/Scripting: Fix loading of spell/aurascripts
* Broken since 9cc97f226d
* There is still a crash when using lazy unloading which I
will fix in a later commit (this commit should fix at least
the static build and normal usage of the dynamic build).
* Closes #16948
This commit is contained in:
@@ -5282,7 +5282,10 @@ void ObjectMgr::ValidateSpellScripts()
|
||||
spellScript->_Register();
|
||||
|
||||
if (!spellScript->_Validate(spellEntry))
|
||||
{
|
||||
itr->second.second = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (auraScript)
|
||||
@@ -5291,9 +5294,17 @@ void ObjectMgr::ValidateSpellScripts()
|
||||
auraScript->_Register();
|
||||
|
||||
if (!auraScript->_Validate(spellEntry))
|
||||
{
|
||||
itr->second.second = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Enable the script when all checks passed
|
||||
itr->second.second = true;
|
||||
}
|
||||
else
|
||||
itr->second.second = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ struct ScriptInfo
|
||||
|
||||
typedef std::multimap<uint32, ScriptInfo> ScriptMap;
|
||||
typedef std::map<uint32, ScriptMap > ScriptMapMap;
|
||||
typedef std::multimap<uint32 /*spell id*/, std::pair<uint32 /*script id*/, bool /*disabled*/>> SpellScriptsContainer;
|
||||
typedef std::multimap<uint32 /*spell id*/, std::pair<uint32 /*script id*/, bool /*enabled*/>> SpellScriptsContainer;
|
||||
typedef std::pair<SpellScriptsContainer::iterator, SpellScriptsContainer::iterator> SpellScriptsBounds;
|
||||
TC_GAME_API extern ScriptMapMap sSpellScripts;
|
||||
TC_GAME_API extern ScriptMapMap sEventScripts;
|
||||
|
||||
@@ -296,7 +296,7 @@ public:
|
||||
virtual void BeforeReleaseContext(std::string const& /*context*/) { }
|
||||
|
||||
/// Called before SwapContext
|
||||
virtual void BeforeSwapContext() { }
|
||||
virtual void BeforeSwapContext(bool /*initialize*/) { }
|
||||
|
||||
/// Called before Unload
|
||||
virtual void BeforeUnload() { }
|
||||
@@ -482,8 +482,12 @@ public:
|
||||
ids_removed_.insert(ids_to_remove.begin(), ids_to_remove.end());
|
||||
}
|
||||
|
||||
void BeforeSwapContext() final override
|
||||
void BeforeSwapContext(bool initialize) override
|
||||
{
|
||||
// Never swap creature or gameobject scripts when initializing
|
||||
if (initialize)
|
||||
return;
|
||||
|
||||
// Add the recently added scripts to the deleted scripts to replace
|
||||
// default AI's with recently added core scripts.
|
||||
ids_removed_.insert(static_cast<Base*>(this)->GetRecentlyAddedScriptIDs().begin(),
|
||||
@@ -566,9 +570,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void BeforeSwapContext() final override
|
||||
void BeforeSwapContext(bool initialize) override
|
||||
{
|
||||
if (swapped)
|
||||
// Never swap outdoor pvp scripts when initializing
|
||||
if ((!initialize) && swapped)
|
||||
{
|
||||
sOutdoorPvPMgr->InitOutdoorPvP();
|
||||
swapped = false;
|
||||
@@ -599,7 +604,7 @@ public:
|
||||
swapped = true;
|
||||
}
|
||||
|
||||
void BeforeSwapContext() final override
|
||||
void BeforeSwapContext(bool initialize) override
|
||||
{
|
||||
swapped = false;
|
||||
}
|
||||
@@ -629,7 +634,7 @@ public:
|
||||
swapped = true;
|
||||
}
|
||||
|
||||
void BeforeSwapContext() final override
|
||||
void BeforeSwapContext(bool initialize) override
|
||||
{
|
||||
if (swapped)
|
||||
{
|
||||
@@ -683,8 +688,7 @@ public:
|
||||
|
||||
void SwapContext(bool initialize) final override
|
||||
{
|
||||
if (!initialize)
|
||||
this->BeforeSwapContext();
|
||||
this->BeforeSwapContext(initialize);
|
||||
|
||||
_recently_added_ids.clear();
|
||||
}
|
||||
@@ -813,7 +817,7 @@ public:
|
||||
ChatHandler::invalidateCommandTable();
|
||||
}
|
||||
|
||||
void BeforeSwapContext() final override
|
||||
void BeforeSwapContext(bool /*initialize*/) override
|
||||
{
|
||||
ChatHandler::invalidateCommandTable();
|
||||
}
|
||||
@@ -846,9 +850,9 @@ public:
|
||||
_scripts.erase(context);
|
||||
}
|
||||
|
||||
void SwapContext(bool) final override
|
||||
void SwapContext(bool initialize) final override
|
||||
{
|
||||
this->BeforeSwapContext();
|
||||
this->BeforeSwapContext(initialize);
|
||||
}
|
||||
|
||||
void RemoveUsedScriptsFromContainer(std::unordered_set<std::string>& scripts) final override
|
||||
@@ -1159,10 +1163,10 @@ void CreateSpellOrAuraScripts(uint32 spellId, std::list<T*>& scriptVector, F&& e
|
||||
for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
|
||||
{
|
||||
// When the script is disabled continue with the next one
|
||||
if (itr->second.second)
|
||||
if (!itr->second.second)
|
||||
continue;
|
||||
|
||||
SpellScriptLoader* tmpscript = ScriptRegistry<SpellScriptLoader>::Instance()->GetScriptById(itr->second.first);
|
||||
SpellScriptLoader* tmpscript = sScriptMgr->GetSpellScriptLoader(itr->second.first);
|
||||
if (!tmpscript)
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user