From df109debf42e9199bfc9c10a579618f93bf28f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= <2108U9@gmail.com> Date: Tue, 17 Apr 2018 19:49:53 +0200 Subject: [PATCH] Fixed potential issue when syncing only targeted messages --- MLAPI/MLAPI.csproj | 2 +- MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/MLAPI/MLAPI.csproj b/MLAPI/MLAPI.csproj index 86817ba..b429cfa 100644 --- a/MLAPI/MLAPI.csproj +++ b/MLAPI/MLAPI.csproj @@ -36,7 +36,7 @@ true - ..\..\MLAPI-Examples\Assets\MLAPI\ + ..\..\MLAPI-Examples\Assets\MLAPI\Lib\ DEBUG;TRACE full AnyCPU diff --git a/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs b/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs index 31f37e9..d96ca22 100644 --- a/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs +++ b/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs @@ -744,6 +744,17 @@ namespace MLAPI.MonoBehaviours.Core InternalMessageHandler.Send(ownerClientId, "MLAPI_SYNC_VAR_UPDATE", "MLAPI_INTERNAL", stream.ToArray()); //Send only to target } + if (nonTargetDirtyCount == 0) + { + //Seems like ONLY targeted syncedVars was changed. Thus we need to remove the dirty tags and return; + for (int i = 0; i < syncedVarFields.Count; i++) + { + syncedVarFields[i].FieldValue = syncedVarFields[i].FieldInfo.GetValue(this); + syncedVarFields[i].Dirty = false; + } + return; + } + //It's sync time. This is the NON target receivers packet. using (MemoryStream stream = new MemoryStream()) {