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
return NetworkBehaviourProcessor.ValidateFunction(md) &&
NetworkBehaviourProcessor.ValidateParameters(md, RemoteCallType.Command);
return NetworkBehaviourProcessor.ValidateRemoteCallAndParameters(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)));
}
// 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
public static bool ValidateFunction(MethodReference md)
static bool ValidateFunction(MethodReference md)
{
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
public static bool ValidateParameters(MethodReference method, RemoteCallType callType)
static bool ValidateParameters(MethodReference method, RemoteCallType callType)
{
for (int i = 0; i < method.Parameters.Count; ++i)
{

View File

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

View File

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