From b3a4c3159c7626298d3ed5d5f40062e2d7189cfb Mon Sep 17 00:00:00 2001 From: vis2k Date: Sun, 30 Dec 2018 17:29:07 +0100 Subject: [PATCH] NetworkBehaviour.InvokeCommandDelegate 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 ebac3c7ab..b8198b7fa 100644 --- a/Mirror/Runtime/NetworkBehaviour.cs +++ b/Mirror/Runtime/NetworkBehaviour.cs @@ -296,21 +296,12 @@ static bool GetInvokerForHash(int cmdHash, UNetInvokeType invokeType, out CmdDel internal bool InvokeCommandDelegate(int cmdHash, NetworkReader reader) { - if (!s_CmdHandlerDelegates.ContainsKey(cmdHash)) + Invoker invoker; + if (s_CmdHandlerDelegates.TryGetValue(cmdHash, out invoker) && + invoker.invokeType == UNetInvokeType.Command && + invoker.invokeClass.IsInstanceOfType(this)) { - return false; - } - - Invoker inv = s_CmdHandlerDelegates[cmdHash]; - if (inv.invokeType != UNetInvokeType.Command) - { - return false; - } - - // 'this' instance of invokeClass? - if (inv.invokeClass.IsInstanceOfType(this)) - { - inv.invokeFunction(this, reader); + invoker.invokeFunction(this, reader); return true; } return false;