From 95082334af5a7522d88ed46ae0861f217e6baac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= Date: Wed, 21 Mar 2018 08:37:15 +0100 Subject: [PATCH] Changed spawnedObjects counting code --- MLAPI/MonoBehaviours/Core/NetworkingManager.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/MLAPI/MonoBehaviours/Core/NetworkingManager.cs b/MLAPI/MonoBehaviours/Core/NetworkingManager.cs index 96c80e2..9ea41d1 100644 --- a/MLAPI/MonoBehaviours/Core/NetworkingManager.cs +++ b/MLAPI/MonoBehaviours/Core/NetworkingManager.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.Networking; +using System.Linq; namespace MLAPI { @@ -1136,14 +1137,9 @@ namespace MLAPI int sizeOfStream = 16 + ((connectedClients.Count - 1) * 4); - int amountOfObjectsToSend = 0; - foreach (KeyValuePair pair in SpawnManager.spawnedObjects) - { - if (pair.Value.ServerOnly) - continue; - else - amountOfObjectsToSend++; - } + + int amountOfObjectsToSend = SpawnManager.spawnedObjects.Values.Count(x => x.ServerOnly == false); + if(NetworkConfig.HandleObjectSpawning) { sizeOfStream += 4;