Weaver NetworkBehaviourProcessor: ValidateRemoteCallAndParameters function added to be used from Command/Rpc/TargetRpcProcessors

This commit is contained in:
vis2k 2020-08-26 13:08:46 +02:00
parent fbad5d2401
commit 2e178b7eaf
4 changed files with 12 additions and 8 deletions

View File

@ -133,8 +133,7 @@ public static bool ValidateCommand(MethodDefinition md)
} }
// validate // validate
return NetworkBehaviourProcessor.ValidateFunction(md) && return NetworkBehaviourProcessor.ValidateRemoteCallAndParameters(md, RemoteCallType.Command);
NetworkBehaviourProcessor.ValidateParameters(md, RemoteCallType.Command);
} }
} }
} }

View File

@ -874,8 +874,15 @@ public static void AddInvokeParameters(ICollection<ParameterDefinition> collecti
collection.Add(new ParameterDefinition("senderConnection", ParameterAttributes.None, Weaver.CurrentAssembly.MainModule.ImportReference(WeaverTypes.NetworkConnectionType))); collection.Add(new ParameterDefinition("senderConnection", ParameterAttributes.None, Weaver.CurrentAssembly.MainModule.ImportReference(WeaverTypes.NetworkConnectionType)));
} }
// check if a Command/TargetRpc/Rpc function & parameters are valid for weaving
public static bool ValidateRemoteCallAndParameters(MethodReference method, RemoteCallType callType)
{
return ValidateFunction(method) &&
ValidateParameters(method, callType);
}
// check if a Command/TargetRpc/Rpc function is valid for weaving // check if a Command/TargetRpc/Rpc function is valid for weaving
public static bool ValidateFunction(MethodReference md) static bool ValidateFunction(MethodReference md)
{ {
if (md.ReturnType.FullName == WeaverTypes.IEnumeratorType.FullName) if (md.ReturnType.FullName == WeaverTypes.IEnumeratorType.FullName)
{ {
@ -896,7 +903,7 @@ public static bool ValidateFunction(MethodReference md)
} }
// check if all Command/TargetRpc/Rpc function's parameters are valid for weaving // check if all Command/TargetRpc/Rpc function's parameters are valid for weaving
public static bool ValidateParameters(MethodReference method, RemoteCallType callType) static bool ValidateParameters(MethodReference method, RemoteCallType callType)
{ {
for (int i = 0; i < method.Parameters.Count; ++i) for (int i = 0; i < method.Parameters.Count; ++i)
{ {

View File

@ -111,8 +111,7 @@ public static bool ValidateRpc(MethodDefinition md)
} }
// validate // validate
return NetworkBehaviourProcessor.ValidateFunction(md) && return NetworkBehaviourProcessor.ValidateRemoteCallAndParameters(md, RemoteCallType.ClientRpc);
NetworkBehaviourProcessor.ValidateParameters(md, RemoteCallType.ClientRpc);
} }
} }
} }

View File

@ -140,8 +140,7 @@ public static bool ValidateTargetRpc(MethodDefinition md)
} }
// validate // validate
return NetworkBehaviourProcessor.ValidateFunction(md) && return NetworkBehaviourProcessor.ValidateRemoteCallAndParameters(md, RemoteCallType.TargetRpc);
NetworkBehaviourProcessor.ValidateParameters(md, RemoteCallType.TargetRpc);
} }
} }
} }