Skip to content

Commit 81ceb88

Browse files
committed
Fixed SyncedVar issues
1 parent 5d0f176 commit 81ceb88

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

MLAPI/Data/FieldType.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using MLAPI.NetworkingManagerComponents.Binary;
22
using System;
33
using UnityEngine;
4-
using System.Collections.Generic;
54

65
namespace MLAPI.Data
76
{
@@ -25,12 +24,12 @@ internal static bool ObjectEqual(object o1, object o2)
2524
Array ar1 = (Array)o1;
2625
Array ar2 = (Array)o2;
2726
if (ar1.Length != ar2.Length)
28-
return false;
27+
return false;
2928

3029
int i = 0;
3130
foreach (object item in ar1)
3231
{
33-
if (item != ar2.GetValue(i))
32+
if (!ObjectEqual(item, ar2.GetValue(i)))
3433
return false;
3534
i++;
3635
}
@@ -228,6 +227,7 @@ internal static object ReadFieldType(BitReader reader, Type type, ref object old
228227
Type elementType = type.GetElementType();
229228
Array array = Array.CreateInstance(elementType, arrayLength);
230229
for (int i = 0; i < arrayLength; i++) array.SetValue(ReadFieldType(reader, elementType), i);
230+
oldValueRef = array;
231231
return array;
232232
}
233233
}

MLAPI/NetworkingManagerComponents/Core/InternalMessageHandler.Receive.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ internal static void HandleSyncVarUpdate(uint clientId, BitReader reader, int ch
244244
SpawnManager.spawnedObjects[netId].GetBehaviourAtOrderIndex(orderIndex).OnSyncVarUpdate(FieldTypeHelper.ReadFieldType(reader,
245245
field.FieldInfo.FieldType, ref field.FieldValue), i);
246246
}
247+
SpawnManager.spawnedObjects[netId].GetBehaviourAtOrderIndex(orderIndex).OnSyncVarUpdate();
247248
}
248249

249250
internal static void HandleAddObjects(uint clientId, BitReader reader, int channelId)

0 commit comments

Comments
 (0)