From 6f5ee572488abffb476cf5a5a114ba931eb08567 Mon Sep 17 00:00:00 2001 From: vis2k Date: Mon, 17 Dec 2018 23:20:37 +0100 Subject: [PATCH] NetworkServer.OnCommandMessage: removed unnecessary GetComponent call and unnecessary .gameObject calls by using NetworkIdentity.spawned directly --- Mirror/Runtime/NetworkServer.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Mirror/Runtime/NetworkServer.cs b/Mirror/Runtime/NetworkServer.cs index bffb8b11d..9f5f64b22 100644 --- a/Mirror/Runtime/NetworkServer.cs +++ b/Mirror/Runtime/NetworkServer.cs @@ -846,17 +846,11 @@ static void OnCommandMessage(NetworkMessage netMsg) { CommandMessage message = netMsg.ReadMessage(); - var cmdObject = FindLocalObject(message.netId); - if (cmdObject == null) - { - Debug.LogWarning("Instance not found when handling Command message [netId=" + message.netId + "]"); - return; - } - - NetworkIdentity identity = cmdObject.GetComponent(); + NetworkIdentity identity; + NetworkIdentity.spawned.TryGetValue(message.netId, out identity); if (identity == null) { - Debug.LogWarning("NetworkIdentity deleted when handling Command message [netId=" + message.netId + "]"); + Debug.LogWarning("Spawned object not found when handling Command message [netId=" + message.netId + "]"); return; }