diff --git a/Assets/Mirror/Editor/Weaver/Processors/NetworkBehaviourProcessor.cs b/Assets/Mirror/Editor/Weaver/Processors/NetworkBehaviourProcessor.cs index 77b2916a0..98921d7e0 100644 --- a/Assets/Mirror/Editor/Weaver/Processors/NetworkBehaviourProcessor.cs +++ b/Assets/Mirror/Editor/Weaver/Processors/NetworkBehaviourProcessor.cs @@ -364,7 +364,7 @@ void GenerateRegisterRemoteDelegate(ILProcessor worker, MethodReference register worker.Emit(OpCodes.Ldnull); worker.Emit(OpCodes.Ldftn, func); - worker.Emit(OpCodes.Newobj, weaverTypes.CmdDelegateConstructor); + worker.Emit(OpCodes.Newobj, weaverTypes.RemoteCallDelegateConstructor); // worker.Emit(OpCodes.Call, registerMethod); } @@ -380,7 +380,7 @@ void GenerateRegisterCommandDelegate(ILProcessor worker, MethodReference registe worker.Emit(OpCodes.Ldnull); worker.Emit(OpCodes.Ldftn, func); - worker.Emit(OpCodes.Newobj, weaverTypes.CmdDelegateConstructor); + worker.Emit(OpCodes.Newobj, weaverTypes.RemoteCallDelegateConstructor); // requiresAuthority ? 1 : 0 worker.Emit(requiresAuthority ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0); diff --git a/Assets/Mirror/Editor/Weaver/WeaverTypes.cs b/Assets/Mirror/Editor/Weaver/WeaverTypes.cs index 041254835..6529faab4 100644 --- a/Assets/Mirror/Editor/Weaver/WeaverTypes.cs +++ b/Assets/Mirror/Editor/Weaver/WeaverTypes.cs @@ -16,7 +16,7 @@ public class WeaverTypes public MethodReference NetworkClientConnectionReference; - public MethodReference CmdDelegateConstructor; + public MethodReference RemoteCallDelegateConstructor; public MethodReference NetworkServerGetActive; public MethodReference NetworkServerGetLocalClientActive; @@ -78,8 +78,8 @@ public WeaverTypes(AssemblyDefinition assembly, Logger Log, ref bool WeavingFail TypeReference NetworkClientType = Import(typeof(NetworkClient)); NetworkClientGetActive = Resolvers.ResolveMethod(NetworkClientType, assembly, Log, "get_active", ref WeavingFailed); - TypeReference cmdDelegateReference = Import(); - CmdDelegateConstructor = Resolvers.ResolveMethod(cmdDelegateReference, assembly, Log, ".ctor", ref WeavingFailed); + TypeReference RemoteCallDelegateType = Import(); + RemoteCallDelegateConstructor = Resolvers.ResolveMethod(RemoteCallDelegateType, assembly, Log, ".ctor", ref WeavingFailed); TypeReference NetworkBehaviourType = Import(); TypeReference RemoteProcedureCallsType = Import(typeof(RemoteCalls.RemoteProcedureCalls)); diff --git a/Assets/Mirror/Runtime/RemoteProcedureCalls.cs b/Assets/Mirror/Runtime/RemoteProcedureCalls.cs index e43e2ab39..5972ba18e 100644 --- a/Assets/Mirror/Runtime/RemoteProcedureCalls.cs +++ b/Assets/Mirror/Runtime/RemoteProcedureCalls.cs @@ -4,17 +4,17 @@ namespace Mirror.RemoteCalls { - // command function delegate - public delegate void CmdDelegate(NetworkBehaviour obj, NetworkReader reader, NetworkConnectionToClient senderConnection); + // remote call function delegate + public delegate void RemoteCallDelegate(NetworkBehaviour obj, NetworkReader reader, NetworkConnectionToClient senderConnection); class Invoker { public Type invokeClass; public MirrorInvokeType invokeType; - public CmdDelegate invokeFunction; + public RemoteCallDelegate invokeFunction; public bool cmdRequiresAuthority; - public bool AreEqual(Type invokeClass, MirrorInvokeType invokeType, CmdDelegate invokeFunction) + public bool AreEqual(Type invokeClass, MirrorInvokeType invokeType, RemoteCallDelegate invokeFunction) { return (this.invokeClass == invokeClass && this.invokeType == invokeType && @@ -43,7 +43,7 @@ internal static int GetMethodHash(Type invokeClass, string methodName) } } - internal static int RegisterDelegate(Type invokeClass, string cmdName, MirrorInvokeType invokerType, CmdDelegate func, bool cmdRequiresAuthority = true) + internal static int RegisterDelegate(Type invokeClass, string cmdName, MirrorInvokeType invokerType, RemoteCallDelegate func, bool cmdRequiresAuthority = true) { // type+func so Inventory.RpcUse != Equipment.RpcUse int cmdHash = GetMethodHash(invokeClass, cmdName); @@ -67,7 +67,7 @@ internal static int RegisterDelegate(Type invokeClass, string cmdName, MirrorInv return cmdHash; } - static bool CheckIfDeligateExists(Type invokeClass, MirrorInvokeType invokerType, CmdDelegate func, int cmdHash) + static bool CheckIfDeligateExists(Type invokeClass, MirrorInvokeType invokerType, RemoteCallDelegate func, int cmdHash) { if (cmdHandlerDelegates.ContainsKey(cmdHash)) { @@ -85,12 +85,12 @@ static bool CheckIfDeligateExists(Type invokeClass, MirrorInvokeType invokerType return false; } - public static void RegisterCommandDelegate(Type invokeClass, string cmdName, CmdDelegate func, bool requiresAuthority) + public static void RegisterCommandDelegate(Type invokeClass, string cmdName, RemoteCallDelegate func, bool requiresAuthority) { RegisterDelegate(invokeClass, cmdName, MirrorInvokeType.Command, func, requiresAuthority); } - public static void RegisterRpcDelegate(Type invokeClass, string rpcName, CmdDelegate func) + public static void RegisterRpcDelegate(Type invokeClass, string rpcName, RemoteCallDelegate func) { RegisterDelegate(invokeClass, rpcName, MirrorInvokeType.ClientRpc, func); } @@ -139,7 +139,7 @@ internal static CommandInfo GetCommandInfo(int cmdHash, NetworkBehaviour invokin } /// Gets the handler function by hash. Useful for profilers and debuggers. - public static CmdDelegate GetDelegate(int cmdHash) + public static RemoteCallDelegate GetDelegate(int cmdHash) { if (cmdHandlerDelegates.TryGetValue(cmdHash, out Invoker invoker)) { diff --git a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs index 513dcecf4..0de73d8bf 100644 --- a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs @@ -224,12 +224,12 @@ public void GetDelegate() // get handler int cmdHash = RemoteProcedureCalls.GetMethodHash(typeof(NetworkBehaviourDelegateComponent), nameof(NetworkBehaviourDelegateComponent.Delegate)); - CmdDelegate func = RemoteProcedureCalls.GetDelegate(cmdHash); - CmdDelegate expected = NetworkBehaviourDelegateComponent.Delegate; + RemoteCallDelegate func = RemoteProcedureCalls.GetDelegate(cmdHash); + RemoteCallDelegate expected = NetworkBehaviourDelegateComponent.Delegate; Assert.That(func, Is.EqualTo(expected)); // invalid hash should return null handler - CmdDelegate funcNull = RemoteProcedureCalls.GetDelegate(1234); + RemoteCallDelegate funcNull = RemoteProcedureCalls.GetDelegate(1234); Assert.That(funcNull, Is.Null); // clean up