Skip to content

Commit a22f534

Browse files
committed
Added bit padding
1 parent 8ddf11a commit a22f534

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

MLAPI/NetworkingManagerComponents/Binary/BitReader.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,18 @@ public BitReader(Stream source)
2525

2626

2727
public int ReadByte() => source.ReadByte();
28+
2829
public byte ReadByteDirect() => (byte)source.ReadByte();
30+
2931
public bool ReadBit() => bitSource.ReadBit();
3032

33+
public bool ReadBool() => ReadBit();
34+
35+
public void SkipPadBits()
36+
{
37+
while (!bitSource.BitAligned) ReadBit();
38+
}
39+
3140
public object ReadObjectPacked(Type type)
3241
{
3342
if (type == typeof(byte))
@@ -859,8 +868,6 @@ public uint[] ReadUIntArrayDiff(uint[] readTo = null, long knownLength = -1)
859868
return writeTo;
860869
}
861870

862-
public bool ReadBool() => ReadBit();
863-
864871
public long[] ReadLongArray(long[] readTo = null, long knownLength = -1)
865872
{
866873
if (knownLength < 0) knownLength = (long)ReadUInt64Packed();

MLAPI/NetworkingManagerComponents/Binary/BitWriter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ public void WriteRotation(Quaternion rotation, int bytesPerAngle)
353353

354354
public void WriteBool(bool value) => WriteBit(value);
355355

356+
public void WritePadBits()
357+
{
358+
while (!bitSink.BitAligned) WriteBit(false);
359+
}
360+
356361
/// <summary>
357362
/// Write the lower half (lower nibble) of a byte.
358363
/// </summary>

0 commit comments

Comments
 (0)