Skip to content

Commit 3170aa2

Browse files
authored
Merge branch 'develop-2.0.0' into backport/fix/scene-validation-after-host-migration
2 parents 6799a6e + e34dba5 commit 3170aa2

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎com.unity.netcode.gameobjects/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
2323
### Fixed
2424

2525
- Issue where a client promoted to session owner could throw an exception when synchronizing a newly joining client. (#4217)
26+
- 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)
2627
- 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)
2728
- 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)
2829
- 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)

‎com.unity.netcode.gameobjects/Runtime/Serialization/FastBufferWriter.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public unsafe BitWriter EnterBitwiseContext()
193193

194194
internal unsafe void Grow(int additionalSizeRequired)
195195
{
196-
var desiredSize = Handle->Capacity * 2;
196+
var desiredSize = Math.Max(Handle->Capacity * 2, 1);
197197
while (desiredSize < Position + additionalSizeRequired)
198198
{
199199
desiredSize *= 2;

‎com.unity.netcode.gameobjects/Tests/Editor/Serialization/FastBufferWriterTests.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,17 @@ public void WhenBufferGrowthRequiredIsMoreThanDouble_BufferGrowsEnoughToContainR
15241524
}
15251525
}
15261526

1527+
[Test]
1528+
public void WhenGrowingWriterStartsWithZeroSize_BufferGrows()
1529+
{
1530+
using var growingWriter = new FastBufferWriter(0, Allocator.Temp, 64);
1531+
Assert.IsTrue(growingWriter.TryBeginWrite(4));
1532+
Assert.AreEqual(4, growingWriter.Capacity);
1533+
1534+
growingWriter.WriteByteSafe(1);
1535+
Assert.AreEqual(new byte[] { 1 }, growingWriter.ToArray());
1536+
}
1537+
15271538
[Test]
15281539
public void WhenTryingToWritePastMaxCapacity_GrowthDoesNotOccurAndTryBeginWriteReturnsFalse()
15291540
{

0 commit comments

Comments
 (0)