Skip to content

Commit b309cc3

Browse files
fix: truncate when reverting writes during NetworkBehaviour synchronize (#2749)
* fix truncate buffer back to the position. * style adding comment * update adding change log entry
1 parent 4e246ff commit b309cc3

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ Additional documentation and release notes are available at [Multiplayer Documen
88

99
## [Unreleased]
1010

11+
### Added
12+
1113
### Fixed
1214

1315
- Fixed a bug where having a class with Rpcs that inherits from a class without Rpcs that inherits from NetworkVariable would cause a compile error. (#2751)
16+
- Fixed issue where `NetworkBehaviour.Synchronize` was not truncating the write buffer if nothing was serialized during `NetworkBehaviour.OnSynchronize` causing an additional 6 bytes to be written per `NetworkBehaviour` component instance. (#2749)
17+
18+
### Changed
1419

1520
## [1.7.0] - 2023-10-11
1621

com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,8 @@ internal bool Synchronize<T>(ref BufferSerializer<T> serializer, ulong targetCli
993993
if (finalPosition == positionBeforeSynchronize || threwException)
994994
{
995995
writer.Seek(positionBeforeWrite);
996+
// Truncate back to the size before
997+
writer.Truncate();
996998
return false;
997999
}
9981000
else

0 commit comments

Comments
 (0)