Skip to content

Commit

Permalink
fix: fixing ResizeBuffer
Browse files Browse the repository at this point in the history
ResizeBuffer was not resizing when new length was less than 1 byte over capacity
  • Loading branch information
James-Frowen committed May 20, 2022
1 parent 853e581 commit 2232c11
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Assets/Mirage/Runtime/Serialization/NetworkWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ public NetworkWriter(int minByteCapacity, bool allowResize)

void ResizeBuffer(int minBitCapacity)
{
int minByteCapacity = minBitCapacity / 8;
// +7 to round up to next byte
int minByteCapacity = (minBitCapacity + 7) / 8;
int size = managedBuffer.Length;
while (size < minByteCapacity)
{
Expand Down

0 comments on commit 2232c11

Please sign in to comment.