Core/Scripts: Fixes ValidateSpellScripts, and type mismatch of parameters

This commit is contained in:
hondacrx
2018-01-13 23:17:54 -05:00
parent a96e26329f
commit bde833d452
4 changed files with 36 additions and 8 deletions
+28 -1
View File
@@ -99,7 +99,7 @@ namespace Game.Scripting
var constructors = type.GetConstructors();
if (constructors.Length == 0)
{
Log.outError(LogFilter.Scripts, "Type: {0} contains no Public Constructors. Can't load script.", type.Name);
Log.outError(LogFilter.Scripts, "Script: {0} contains no Public Constructors. Can't load script.", type.Name);
continue;
}
@@ -108,6 +108,33 @@ namespace Game.Scripting
var genericType = type;
string name = type.Name;
bool validArgs = true;
int i = 0;
foreach (var constructor in constructors)
{
var parameters = constructor.GetParameters();
if (parameters.Length != attribute.Args.Length)
continue;
foreach (var arg in constructor.GetParameters())
{
if (arg.ParameterType != attribute.Args[i++].GetType())
{
validArgs = false;
break;
}
}
if (validArgs)
break;
}
if (!validArgs)
{
Log.outError(LogFilter.Scripts, "Script: {0} contains no Public Constructors with the right parameter types. Can't load script.", type.Name);
continue;
}
switch (type.BaseType.Name)
{
case "SpellScript":