From 3d7a10fd08a57d5e46546cd32f16ff2abb8653b6 Mon Sep 17 00:00:00 2001 From: vis2k Date: Sun, 30 Dec 2018 17:29:57 +0100 Subject: [PATCH] NetworkBehaviour.InvokeRpcDelegate simplified --- Mirror/Runtime/NetworkBehaviour.cs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/Mirror/Runtime/NetworkBehaviour.cs b/Mirror/Runtime/NetworkBehaviour.cs index b8198b7fa..50578119f 100644 --- a/Mirror/Runtime/NetworkBehaviour.cs +++ b/Mirror/Runtime/NetworkBehaviour.cs @@ -309,21 +309,12 @@ internal bool InvokeCommandDelegate(int cmdHash, NetworkReader reader) internal bool InvokeRpcDelegate(int cmdHash, NetworkReader reader) { - if (!s_CmdHandlerDelegates.ContainsKey(cmdHash)) + Invoker invoker; + if (s_CmdHandlerDelegates.TryGetValue(cmdHash, out invoker) && + invoker.invokeType == UNetInvokeType.ClientRpc && + invoker.invokeClass.IsInstanceOfType(this)) { - return false; - } - - Invoker inv = s_CmdHandlerDelegates[cmdHash]; - if (inv.invokeType != UNetInvokeType.ClientRpc) - { - return false; - } - - // 'this' instance of invokeClass? - if (inv.invokeClass.IsInstanceOfType(this)) - { - inv.invokeFunction(this, reader); + invoker.invokeFunction(this, reader); return true; } return false;