Implement generic script loaders to greatly reduce code duplication
This commit is contained in:
@@ -1585,17 +1585,16 @@ namespace Game
|
||||
foreach (var script in spellScriptsStorage.ToList())
|
||||
{
|
||||
SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(script.Key);
|
||||
Dictionary<SpellScriptLoader, uint> SpellScriptLoaders = Global.ScriptMgr.CreateSpellScriptLoaders(script.Key);
|
||||
|
||||
Dictionary<SpellScriptLoader, uint> SpellScriptLoaders = Global.ScriptMgr.CreateSpellScriptLoaders(script.Key);
|
||||
foreach (var pair in SpellScriptLoaders)
|
||||
{
|
||||
SpellScript spellScript = pair.Key.GetSpellScript();
|
||||
AuraScript auraScript = pair.Key.GetAuraScript();
|
||||
bool valid = true;
|
||||
|
||||
if (spellScript == null && auraScript == null)
|
||||
if (spellScript == null)
|
||||
{
|
||||
Log.outError(LogFilter.Scripts, "Functions GetSpellScript() and GetAuraScript() of script `{0}` do not return objects - script skipped", GetScriptName(pair.Value));
|
||||
Log.outError(LogFilter.Scripts, "Functions GetSpellScript() of script `{0}` do not return object - script skipped", GetScriptName(pair.Value));
|
||||
valid = false;
|
||||
}
|
||||
|
||||
@@ -1607,6 +1606,22 @@ namespace Game
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
spellScriptsStorage.Remove(pair.Value);
|
||||
}
|
||||
|
||||
Dictionary<AuraScriptLoader, uint> AuraScriptLoaders = Global.ScriptMgr.CreateAuraScriptLoaders(script.Key);
|
||||
foreach (var pair in AuraScriptLoaders)
|
||||
{
|
||||
AuraScript auraScript = pair.Key.GetAuraScript();
|
||||
bool valid = true;
|
||||
|
||||
if (auraScript == null)
|
||||
{
|
||||
Log.outError(LogFilter.Scripts, "Functions GetAuraScript() of script `{0}` do not return object - script skipped", GetScriptName(pair.Value));
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (auraScript != null)
|
||||
{
|
||||
auraScript._Init(pair.Key.GetName(), spellEntry.Id);
|
||||
@@ -1639,6 +1654,9 @@ namespace Game
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return 0;
|
||||
|
||||
if (!scriptNamesStorage.Contains(name))
|
||||
return 0;
|
||||
|
||||
return (uint)scriptNamesStorage.IndexOf(name);
|
||||
}
|
||||
public uint GetAreaTriggerScriptId(uint triggerid)
|
||||
|
||||
Reference in New Issue
Block a user