Skip to content

Commit 1204628

Browse files
Fixed ZigZagDecode
1 parent 7519d87 commit 1204628

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

MLAPI/NetworkingManagerComponents/Binary/BitReader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ public byte ReadByte()
7070
public void SkipPadded() => bitCount += (8 - (bitCount % 8)) % 8;
7171
public ushort ReadUShort() => (ushort)ReadULong();
7272
public uint ReadUInt() => (uint)ReadULong();
73-
public sbyte ReadSByte() => (sbyte)ZigZagDecode(ReadByte(), 1);
74-
public short ReadShort() => (short)ZigZagDecode(ReadUShort(), 2);
75-
public int ReadInt() => (int)ZigZagDecode(ReadUInt(), 4);
76-
public long ReadLong() => ZigZagDecode(ReadULong(), 8);
73+
public sbyte ReadSByte() => (sbyte)ZigZagDecode(ReadByte());
74+
public short ReadShort() => (short)ZigZagDecode(ReadUShort());
75+
public int ReadInt() => (int)ZigZagDecode(ReadUInt());
76+
public long ReadLong() => ZigZagDecode(ReadULong());
7777

7878
public float[] ReadFloatArray(int known = -1) => ReadArray(ReadFloat, known);
7979
public uint ReadFloatArray(float[] buffer, int known = -1) => ReadArray(ReadFloat, buffer, known);
@@ -171,7 +171,7 @@ private T ReadFloating<T>()
171171
}
172172
return result;
173173
}
174-
private static long ZigZagDecode(ulong d, int bytes) => (long)(((d << (bytes * 8 - 1)) & 1) | (d >> 1));
174+
private static long ZigZagDecode(ulong d) => (long)(((d << 63) & 1) | (d >> 1));
175175

176176
public void Dispose()
177177
{

0 commit comments

Comments
 (0)