Skip to content

fix: snapshot system. Properly gating the SnapshotSystem from being u… #852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public enum __NExec
Client = 2
}

// todo: transitional. For the next release, only Snapshot should remain
// The booleans allow iterative development and testing in the meantime
static private bool s_UseClassicDelta = true;
static private bool s_UseSnapshot = false;

#pragma warning disable 414
#pragma warning disable IDE1006 // disable naming rule violation check
[NonSerialized]
Expand Down Expand Up @@ -593,15 +588,15 @@ private void NetworkVariableUpdate(ulong clientId, int behaviourIndex)
return;
}

if (s_UseSnapshot)
if (NetworkManager.UseSnapshot)
{
for (int k = 0; k < NetworkVariableFields.Count; k++)
{
NetworkManager.SnapshotSystem.Store(NetworkObjectId, behaviourIndex, k, NetworkVariableFields[k]);
}
}

if (s_UseClassicDelta)
if (NetworkManager.UseClassicDelta)
{
for (int j = 0; j < m_ChannelMappedNetworkVariableIndexes.Count; j++)
{
Expand Down
5 changes: 5 additions & 0 deletions com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public class NetworkManager : MonoBehaviour, INetworkUpdateSystem, IProfilableTr
private static ProfilerMarker s_InvokeRpc = new ProfilerMarker($"{nameof(NetworkManager)}.{nameof(InvokeRpc)}");
#endif

// todo: transitional. For the next release, only Snapshot should remain
// The booleans allow iterative development and testing in the meantime
static internal bool UseClassicDelta = true;
static internal bool UseSnapshot = false;

internal RpcQueueContainer RpcQueueContainer { get; private set; }
internal NetworkTickSystem NetworkTickSystem { get; private set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ public void Dispose()

public void NetworkUpdate(NetworkUpdateStage updateStage)
{
if (!NetworkManager.UseSnapshot)
{
return;
}

if (updateStage == NetworkUpdateStage.EarlyUpdate)
{
if (m_NetworkManager.IsServer)
Expand All @@ -158,7 +163,7 @@ public void NetworkUpdate(NetworkUpdateStage updateStage)
SendSnapshot(clientId);
}
}
else
else if (m_NetworkManager.IsConnectedClient)
{
SendSnapshot(m_NetworkManager.ServerClientId);
}
Expand Down