Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Fixed

- Issue where a growable `FastBufferWriter` created with a size of 0 never returned from its first write or `TryBeginWrite` call that needed the buffer to grow. (#4223)
- Issue where a `FastBufferReader` created with an offset and the default length of -1 read past the end of its source. The `ArraySegment<byte>` overload that takes an offset now applies it from the start of the segment. (#4221)
- Issue where a client synchronized while a `NetworkList<T>` still had unsent changes applied those changes twice, resulting in duplicate entries and index-based events landing on the wrong elements on that client. (#4215)
- Issue where showing a `NetworkObject` with `NetworkShow` while its `NetworkVariable` updates were held back by `NetworkVariableUpdateTraits` stopped those pending changes from being sent until the variable was modified again. (#4215)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public unsafe BitWriter EnterBitwiseContext()

internal unsafe void Grow(int additionalSizeRequired)
{
var desiredSize = Handle->Capacity * 2;
var desiredSize = Math.Max(Handle->Capacity * 2, 1);
while (desiredSize < Position + additionalSizeRequired)
{
desiredSize *= 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,17 @@ public void WhenBufferGrowthRequiredIsMoreThanDouble_BufferGrowsEnoughToContainR
}
}

[Test]
public void WhenGrowingWriterStartsWithZeroSize_BufferGrows()
{
using var growingWriter = new FastBufferWriter(0, Allocator.Temp, 64);
Assert.IsTrue(growingWriter.TryBeginWrite(4));
Assert.AreEqual(4, growingWriter.Capacity);

growingWriter.WriteByteSafe(1);
Assert.AreEqual(new byte[] { 1 }, growingWriter.ToArray());
}

[Test]
public void WhenTryingToWritePastMaxCapacity_GrowthDoesNotOccurAndTryBeginWriteReturnsFalse()
{
Expand Down
Loading