Skip to content

Commit 6dea85a

Browse files
committed
Fixed messaing issues & removed unsued NetworkedVar methods
1 parent 4820511 commit 6dea85a

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,9 @@ internal void NetworkedVarUpdate()
966966
{
967967
using (BitWriter writer = BitWriter.Get())
968968
{
969+
writer.WriteUInt(networkId);
970+
writer.WriteUShort(networkedObject.GetOrderIndex(this));
971+
969972
uint clientId = NetworkingManager.singleton.ConnectedClientsList[i].ClientId;
970973
for (int j = 0; j < networkedVarFields.Count; j++)
971974
{
@@ -992,38 +995,24 @@ internal void NetworkedVarUpdate()
992995

993996
internal void HandleNetworkedVarDeltas(BitReader reader)
994997
{
995-
ushort index = reader.ReadUShort();
996-
if (index >= networkedVarFields.Count)
998+
for (int i = 0; i < networkedVarFields.Count; i++)
997999
{
998-
if (LogHelper.CurrentLogLevel <= LogLevel.Normal) LogHelper.LogWarning("NetworkedVar index out of range");
999-
return;
1000-
}
1000+
if (!reader.ReadBool())
1001+
continue;
10011002

1002-
networkedVarFields[index].SetDeltaFromReader(reader);
1003+
networkedVarFields[i].SetDeltaFromReader(reader);
1004+
}
10031005
}
10041006

10051007
internal void HandleNetworkedVarUpdate(BitReader reader)
10061008
{
1007-
ushort index = reader.ReadUShort();
1008-
if (index >= networkedVarFields.Count)
1009+
for (int i = 0; i < networkedVarFields.Count; i++)
10091010
{
1010-
if (LogHelper.CurrentLogLevel <= LogLevel.Normal) LogHelper.LogWarning("NetworkedVar index out of range");
1011-
return;
1012-
}
1013-
1014-
networkedVarFields[index].SetFieldFromReader(reader);
1015-
}
1011+
if (!reader.ReadBool())
1012+
continue;
10161013

1017-
internal ushort GetNetworkedVarIndex(INetworkedVar networkedVar)
1018-
{
1019-
int index = networkedVarFields.IndexOf(networkedVar);
1020-
if (index == -1)
1021-
{
1022-
if (LogHelper.CurrentLogLevel <= LogLevel.Error) LogHelper.LogWarning("Unable to find NetworkedVar instance");
1023-
return 0;
1014+
networkedVarFields[i].SetFieldFromReader(reader);
10241015
}
1025-
1026-
return (ushort)index;
10271016
}
10281017

10291018
#endregion

0 commit comments

Comments
 (0)