Skip to content
Merged
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
2 changes: 1 addition & 1 deletion com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com).

## [Unreleased]
## [1.7.0] - 2023-10-11

### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public int FillWriterWithBytes(ref DataStreamWriter writer, int maxBytes = 0)
return 0;
}

var maxLength = maxBytes == 0 ? writer.Capacity : maxBytes;
var maxLength = maxBytes == 0 ? writer.Capacity : Math.Min(maxBytes, writer.Capacity);
var copyLength = Math.Min(maxLength, Length);

unsafe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,13 +784,21 @@ private void SendBatchedMessages(SendTarget sendTarget, BatchedSendQueue queue)
{
return;
}

var mtu = 0;
if (NetworkManager)
{
var ngoClientId = NetworkManager.ConnectionManager.TransportIdToClientId(sendTarget.ClientId);
mtu = NetworkManager.GetPeerMTU(ngoClientId);
}

new SendBatchedMessagesJob
{
Driver = m_Driver.ToConcurrent(),
Target = sendTarget,
Queue = queue,
ReliablePipeline = m_ReliableSequencedPipeline,
MTU = NetworkManager ? NetworkManager.GetPeerMTU(sendTarget.ClientId) + m_Driver.MaxHeaderSize(sendTarget.NetworkPipeline) : 0,
MTU = mtu,
}.Run();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,23 @@ public void BatchedSendQueue_FillWriterWithBytes_WriterCapacityEqualToLength()
AssertIsTestMessage(data);
}

[Test]
public void BatchedSendQueue_FillWriterWithBytes_MaxBytesGreaterThanCapacity()
{
var dataLength = k_TestMessageSize + BatchedSendQueue.PerMessageOverhead;

using var q = new BatchedSendQueue(k_TestQueueCapacity);
using var data = new NativeArray<byte>(dataLength, Allocator.Temp);

q.PushMessage(m_TestMessage);
q.PushMessage(m_TestMessage);

var writer = new DataStreamWriter(data);
Assert.AreEqual(dataLength, q.FillWriterWithBytes(ref writer, dataLength * 2));
AssertIsTestMessage(data);
Assert.False(writer.HasFailedWrites);
}

[Test]
public void BatchedSendQueue_Consume_LessThanLength()
{
Expand Down
2 changes: 1 addition & 1 deletion com.unity.netcode.gameobjects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.unity.netcode.gameobjects",
"displayName": "Netcode for GameObjects",
"description": "Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.",
"version": "1.6.0",
"version": "1.7.0",
"unity": "2020.3",
"dependencies": {
"com.unity.nuget.mono-cecil": "1.10.1",
Expand Down