From 98f984182a75bcf06ac8612dd1c838a62da805c1 Mon Sep 17 00:00:00 2001 From: vis2k Date: Sun, 30 Dec 2018 17:30:43 +0100 Subject: [PATCH] NetworkBehaviour.InvokeSyncEventDelegate simplified --- Mirror/Runtime/NetworkBehaviour.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Mirror/Runtime/NetworkBehaviour.cs b/Mirror/Runtime/NetworkBehaviour.cs index 50578119f..a76367f3a 100644 --- a/Mirror/Runtime/NetworkBehaviour.cs +++ b/Mirror/Runtime/NetworkBehaviour.cs @@ -322,19 +322,14 @@ internal bool InvokeRpcDelegate(int cmdHash, NetworkReader reader) internal bool InvokeSyncEventDelegate(int cmdHash, NetworkReader reader) { - if (!s_CmdHandlerDelegates.ContainsKey(cmdHash)) + Invoker invoker; + if (s_CmdHandlerDelegates.TryGetValue(cmdHash, out invoker) && + invoker.invokeType == UNetInvokeType.SyncEvent) { - return false; + invoker.invokeFunction(this, reader); + return true; } - - Invoker inv = s_CmdHandlerDelegates[cmdHash]; - if (inv.invokeType != UNetInvokeType.SyncEvent) - { - return false; - } - - inv.invokeFunction(this, reader); - return true; + return false; } internal static string GetCmdHashHandlerName(int cmdHash)