Skip to content

Commit

Permalink
fix: fixedstring byte writing and comparing up port (#3009)
Browse files Browse the repository at this point in the history
* fix

Fixing no byte serializer issue with FixedString serialization.

* update

Removing the `GenerateSerializationForType` attribute from previous fix.

* update

Updating change log.
  • Loading branch information
NoelStephensUnity authored Aug 13, 2024
1 parent 133c125 commit 57797b7
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
1 change: 1 addition & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Fixed

- Fixed issue where `FixedStringSerializer<T>` was using `NetworkVariableSerialization<byte>.AreEqual` to determine if two bytes were equal causes an exception to be thrown due to no byte serializer having been defined. (#3009)
- Fixed issue using collections within `NetworkVariable` where the collection would not detect changes to items or nested items. (#3004)
- Fixed issue where `List`, `Dictionary`, and `HashSet` collections would not uniquely duplicate nested collections. (#3004)
- Fixed issue where `NotAuthorityTarget` would include the service observer in the list of targets to send the RPC to as opposed to excluding the service observer as it should. (#3000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public enum StaleDataHandling
#pragma warning restore IDE0001
[Serializable]
[GenerateSerializationForGenericParameter(0)]
[GenerateSerializationForType(typeof(byte))]
public class AnticipatedNetworkVariable<T> : NetworkVariableBase
{
[SerializeField]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Unity.Netcode
/// <typeparam name="T">the unmanaged type for <see cref="NetworkVariable{T}"/> </typeparam>
[Serializable]
[GenerateSerializationForGenericParameter(0)]
[GenerateSerializationForType(typeof(byte))]
public class NetworkVariable<T> : NetworkVariableBase
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ public unsafe void WriteDelta(FastBufferWriter writer, ref T value, ref T previo
{
var val = value[i];
var prevVal = previousValue[i];
if (!NetworkVariableSerialization<byte>.AreEqual(ref val, ref prevVal))
if (val != prevVal)
{
++numChanges;
changes.Set(i);
Expand All @@ -960,19 +960,11 @@ public unsafe void WriteDelta(FastBufferWriter writer, ref T value, ref T previo
BytePacker.WriteValuePacked(writer, value.Length);
writer.WriteValueSafe(changes);
var ptr = value.GetUnsafePtr();
var prevPtr = previousValue.GetUnsafePtr();
for (var i = 0; i < value.Length; ++i)
{
if (changes.IsSet(i))
{
if (i < previousValue.Length)
{
NetworkVariableSerialization<byte>.WriteDelta(writer, ref ptr[i], ref prevPtr[i]);
}
else
{
NetworkVariableSerialization<byte>.Write(writer, ref ptr[i]);
}
writer.WriteByteSafe(ptr[i]);
}
}
}
Expand Down

0 comments on commit 57797b7

Please sign in to comment.