Skip to content

Commit adde79f

Browse files
committed
fixes decoding arrays
1 parent e9db628 commit adde79f

File tree

1 file changed

+1
-3
lines changed
  • Assets/Plugins/Colyseus/Serializer/Schema

1 file changed

+1
-3
lines changed

Assets/Plugins/Colyseus/Serializer/Schema/Schema.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ public void Decode(byte[] bytes, Iterator it = null)
485485
ISchemaCollection currentValue = valueRef.Clone();
486486

487487
int newLength = Convert.ToInt32(decode.DecodeNumber(bytes, it));
488-
int numChanges = Convert.ToInt32(decode.DecodeNumber(bytes, it));
488+
int numChanges = Math.Min(Convert.ToInt32(decode.DecodeNumber(bytes, it)), newLength);
489489

490490
hasChange = (numChanges > 0);
491491

@@ -494,8 +494,6 @@ public void Decode(byte[] bytes, Iterator it = null)
494494
// ensure current array has the same length as encoded one
495495
if (currentValue.Count > newLength)
496496
{
497-
numChanges -= currentValue.Count - newLength;
498-
499497
for (var i = newLength; i < currentValue.Count; i++)
500498
{
501499
var item = currentValue[i];

0 commit comments

Comments
 (0)