Skip to content

Commit 2f289a3

Browse files
committed
move SessionStateToken into SessionConfig
1 parent d683276 commit 2f289a3

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

com.unity.netcode.gameobjects/Runtime/Configuration/SessionConfig.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ internal class SessionConfig
88
public const uint NoFeatureCompatibility = 0;
99
public const uint BypassFeatureCompatible = 1;
1010
public const uint ServerDistributionCompatible = 2;
11+
public const uint SessionStateToken = 3;
1112

1213
// The most current session version (!!!!set this when you increment!!!!!)
13-
public static uint PackageSessionVersion => ServerDistributionCompatible;
14+
public static uint PackageSessionVersion => SessionStateToken;
1415

1516
internal uint SessionVersion;
1617

com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ConnectionApprovedMessage.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ internal struct ServiceConfig : INetworkSerializable
99
public bool IsRestoredSession;
1010
public ulong CurrentSessionOwner;
1111
public bool ServerRedistribution;
12+
public ulong SessionStateToken;
1213

1314
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
1415
{
@@ -22,6 +23,11 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
2223
{
2324
serializer.SerializeValue(ref ServerRedistribution);
2425
}
26+
27+
if (SessionVersion >= SessionConfig.SessionStateToken)
28+
{
29+
serializer.SerializeValue(ref SessionStateToken);
30+
}
2531
}
2632
else
2733
{
@@ -37,19 +43,26 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
3743
{
3844
ServerRedistribution = false;
3945
}
46+
47+
if (SessionVersion >= SessionConfig.SessionStateToken)
48+
{
49+
serializer.SerializeValue(ref SessionStateToken);
50+
}
51+
else
52+
{
53+
SessionStateToken = 0;
54+
}
4055
}
4156
}
4257
}
4358

4459
internal struct ConnectionApprovedMessage : INetworkMessage
4560
{
46-
private const int k_AddSessionStateToken = 3;
4761
private const int k_AddCMBServiceConfig = 2;
4862
private const int k_VersionAddClientIds = 1;
49-
public int Version => k_AddSessionStateToken;
63+
public int Version => k_AddCMBServiceConfig;
5064

5165
public ulong OwnerClientId;
52-
public ulong SessionStateToken;
5366
public int NetworkTick;
5467
// The cloud state service should set this if we are restoring a session
5568
public ServiceConfig ServiceConfig;
@@ -110,10 +123,6 @@ public void Serialize(FastBufferWriter writer, int targetVersion)
110123
// ============================================================
111124

112125
BytePacker.WriteValueBitPacked(writer, OwnerClientId);
113-
if (targetVersion >= k_AddSessionStateToken)
114-
{
115-
writer.WriteValueSafe(SessionStateToken);
116-
}
117126
BytePacker.WriteValueBitPacked(writer, NetworkTick);
118127
if (IsDistributedAuthority)
119128
{
@@ -205,10 +214,6 @@ public bool Deserialize(FastBufferReader reader, ref NetworkContext context, int
205214
// ============================================================
206215
m_ReceiveMessageVersion = receivedMessageVersion;
207216
ByteUnpacker.ReadValueBitPacked(reader, out OwnerClientId);
208-
if (receivedMessageVersion >= k_AddSessionStateToken)
209-
{
210-
reader.ReadValueSafe(out SessionStateToken);
211-
}
212217
ByteUnpacker.ReadValueBitPacked(reader, out NetworkTick);
213218
if (networkManager.DistributedAuthorityMode)
214219
{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!655991488 &1
4+
MultiplayerManager:
5+
m_ObjectHideFlags: 0
6+
m_EnableMultiplayerRoles: 0
7+
m_StrippingTypes: {}

testproject/ProjectSettings/Packages/com.unity.services.core/Settings.json

Whitespace-only changes.

0 commit comments

Comments
 (0)