Skip to content

Commit

Permalink
feat: server distribution config (#3132)
Browse files Browse the repository at this point in the history
* feat: server distribution config

* Update ConnectionApprovedMessage.cs
  • Loading branch information
DSchroer authored Nov 20, 2024
1 parent 90f97fd commit 487e469
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ namespace Unity.Netcode
{
internal struct ServiceConfig : INetworkSerializable
{
private const int k_AddServerRedistribution = 1;

public uint Version;
public bool IsRestoredSession;
public ulong CurrentSessionOwner;
public bool ServerRedistribution;

public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
Expand All @@ -16,12 +19,22 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
BytePacker.WriteValueBitPacked(serializer.GetFastBufferWriter(), Version);
serializer.SerializeValue(ref IsRestoredSession);
BytePacker.WriteValueBitPacked(serializer.GetFastBufferWriter(), CurrentSessionOwner);

if (Version >= k_AddServerRedistribution)
{
serializer.SerializeValue(ref ServerRedistribution);
}
}
else
{
ByteUnpacker.ReadValueBitPacked(serializer.GetFastBufferReader(), out Version);
serializer.SerializeValue(ref IsRestoredSession);
ByteUnpacker.ReadValueBitPacked(serializer.GetFastBufferReader(), out CurrentSessionOwner);

if (Version >= k_AddServerRedistribution)
{
serializer.SerializeValue(ref ServerRedistribution);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ internal struct ClientConfig : INetworkSerializable
/// is not bypass feature compatible.
/// </summary>
private const int k_BypassFeatureCompatible = 1;
public int Version => k_BypassFeatureCompatible;
private const int k_ServerDistributionCompatible = k_BypassFeatureCompatible + 1;
public int Version => k_ServerDistributionCompatible;
public uint TickRate;
public bool EnableSceneManagement;

Expand Down

0 comments on commit 487e469

Please sign in to comment.