Move prohibitedHooks check to a method
This commit is contained in:
@@ -57,6 +57,14 @@ namespace Barotrauma
|
|||||||
"ContentPackageManager",
|
"ContentPackageManager",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static void ValidatePatchTarget(MethodInfo methodInfo)
|
||||||
|
{
|
||||||
|
if (prohibitedHooks.Any(h => methodInfo.DeclaringType.FullName.StartsWith(h)))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Hooks into the modding environment are prohibited.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Harmony harmony;
|
private Harmony harmony;
|
||||||
|
|
||||||
private Dictionary<string, Dictionary<string, (LuaCsHookCallback, ACsMod)>> hookFunctions;
|
private Dictionary<string, Dictionary<string, (LuaCsHookCallback, ACsMod)>> hookFunctions;
|
||||||
@@ -300,10 +308,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Identifier, Method and Patch arguments must not be null.");
|
throw new ArgumentNullException("Identifier, Method and Patch arguments must not be null.");
|
||||||
}
|
}
|
||||||
if (prohibitedHooks.Any(h => method.DeclaringType.FullName.StartsWith(h)))
|
ValidatePatchTarget(method);
|
||||||
{
|
|
||||||
throw new ArgumentException("Hooks into Modding Environment are prohibited.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var funcAddr = (long)method.MethodHandle.GetFunctionPointer();
|
var funcAddr = (long)method.MethodHandle.GetFunctionPointer();
|
||||||
var patches = Harmony.GetPatchInfo(method);
|
var patches = Harmony.GetPatchInfo(method);
|
||||||
|
|||||||
@@ -157,11 +157,7 @@ namespace Barotrauma
|
|||||||
GameMain.LuaCs.HandleException(new ArgumentNullException("Identifier, Method and Patch arguments must not be null."), exceptionType: ExceptionType.Both);
|
GameMain.LuaCs.HandleException(new ArgumentNullException("Identifier, Method and Patch arguments must not be null."), exceptionType: ExceptionType.Both);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (prohibitedHooks.Any(h => method.DeclaringType.FullName.StartsWith(h)))
|
ValidatePatchTarget(method);
|
||||||
{
|
|
||||||
GameMain.LuaCs.HandleException(new ArgumentException("Hooks into Modding Environment are prohibited."), exceptionType: ExceptionType.Both);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var funcAddr = ((long)method.MethodHandle.GetFunctionPointer());
|
var funcAddr = ((long)method.MethodHandle.GetFunctionPointer());
|
||||||
var patches = Harmony.GetPatchInfo(method);
|
var patches = Harmony.GetPatchInfo(method);
|
||||||
|
|||||||
Reference in New Issue
Block a user