Skip to content

chore: adjust ConnectionRequestMessage to use ClientConfig version as opposed to NGO version #3098

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
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
23 changes: 0 additions & 23 deletions com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ public class NetworkManagerEditor : NetcodeEditorBase<NetworkManager>
private SerializedProperty m_NetworkProfileMetrics;
private SerializedProperty m_NetworkMessageMetrics;

#if CMB_SERVICE_DEVELOPMENT
private SerializedProperty m_MajorVersion;
private SerializedProperty m_MinorVersion;
private SerializedProperty m_PatchVersion;
#endif

private NetworkManager m_NetworkManager;
private bool m_Initialized;

Expand Down Expand Up @@ -125,11 +119,6 @@ private void Initialize()
m_NetworkProfileMetrics = m_NetworkConfigProperty.FindPropertyRelative("NetworkProfileMetrics");
#if MULTIPLAYER_TOOLS
m_NetworkMessageMetrics = m_NetworkConfigProperty.FindPropertyRelative("NetworkMessageMetrics");
#endif
#if CMB_SERVICE_DEVELOPMENT
m_MajorVersion = serializedObject.FindProperty(nameof(NetworkManager.MajorVersion));
m_MinorVersion = serializedObject.FindProperty(nameof(NetworkManager.MinorVersion));
m_PatchVersion = serializedObject.FindProperty(nameof(NetworkManager.PatchVersion));
#endif
m_RpcHashSizeProperty = m_NetworkConfigProperty.FindPropertyRelative("RpcHashSize");
m_PrefabsList = m_NetworkConfigProperty
Expand Down Expand Up @@ -170,11 +159,6 @@ private void CheckNullProperties()
#if MULTIPLAYER_TOOLS
m_NetworkMessageMetrics = m_NetworkConfigProperty.FindPropertyRelative("NetworkMessageMetrics");
#endif
#if CMB_SERVICE_DEVELOPMENT
m_MajorVersion = serializedObject.FindProperty(nameof(NetworkManager.MajorVersion));
m_MinorVersion = serializedObject.FindProperty(nameof(NetworkManager.MinorVersion));
m_PatchVersion = serializedObject.FindProperty(nameof(NetworkManager.PatchVersion));
#endif

m_RpcHashSizeProperty = m_NetworkConfigProperty.FindPropertyRelative("RpcHashSize");
m_PrefabsList = m_NetworkConfigProperty
Expand All @@ -192,13 +176,6 @@ private void DisplayNetworkManagerProperties()
EditorGUILayout.PropertyField(m_LogLevelProperty);
EditorGUILayout.Space();

#if CMB_SERVICE_DEVELOPMENT
EditorGUILayout.LabelField("Version:", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(m_MajorVersion);
EditorGUILayout.PropertyField(m_MinorVersion);
EditorGUILayout.PropertyField(m_PatchVersion);
EditorGUILayout.Space();
#endif
EditorGUILayout.LabelField("Network Settings", EditorStyles.boldLabel);
#if MULTIPLAYER_SERVICES_SDK_INSTALLED
EditorGUILayout.PropertyField(m_NetworkTopologyProperty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ private void SendConnectionRequest()

if (NetworkManager.CMBServiceConnection)
{
message.ClientConfig.NGOVersion = NetworkManager.GetNGOVersion();
message.ClientConfig.TickRate = NetworkManager.NetworkConfig.TickRate;
message.ClientConfig.EnableSceneManagement = NetworkManager.NetworkConfig.EnableSceneManagement;
}
Expand Down
44 changes: 0 additions & 44 deletions com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -887,29 +887,6 @@ internal T Value
internal Override<ushort> PortOverride;


[HideInInspector]
[SerializeField]
[Range(0, 255)]
internal byte MajorVersion;
[HideInInspector]
[SerializeField]
[Range(0, 255)]
internal byte MinorVersion;
[HideInInspector]
[SerializeField]
[Range(0, 255)]
internal byte PatchVersion;

internal NGOVersion GetNGOVersion()
{
return new NGOVersion()
{
Major = MajorVersion,
Minor = MinorVersion,
Patch = PatchVersion
};
}

#if UNITY_EDITOR
internal static INetworkManagerHelper NetworkManagerHelper;

Expand Down Expand Up @@ -941,34 +918,13 @@ private PackageInfo GetPackageInfo(string packageName)
return AssetDatabase.FindAssets("package").Select(AssetDatabase.GUIDToAssetPath).Where(x => AssetDatabase.LoadAssetAtPath<TextAsset>(x) != null).Select(PackageInfo.FindForAssetPath).Where(x => x != null).First(x => x.name == packageName);
}

private void SetPackageVersion()
{
var packageInfo = GetPackageInfo("com.unity.netcode.gameobjects");
if (packageInfo != null)
{
var versionSplit = packageInfo.version.Split(".");
if (versionSplit.Length == 3)
{
MajorVersion = byte.Parse(versionSplit[0]);
MinorVersion = byte.Parse(versionSplit[1]);
PatchVersion = byte.Parse(versionSplit[2]);
}
}
}

internal void OnValidate()
{
if (NetworkConfig == null)
{
return; // May occur when the component is added
}

#if !CMB_SERVICE_DEVELOPMENT
SetPackageVersion();
#else
Debug.Log($"Major:({MajorVersion}) Minor({MinorVersion}) Patch({PatchVersion})");
#endif

if (GetComponentInChildren<NetworkObject>() != null)
{
if (NetworkLog.CurrentLogLevel <= LogLevel.Normal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,37 @@

namespace Unity.Netcode
{
internal struct NGOVersion : INetworkSerializable
{
public byte Major;
public byte Minor;
public byte Patch;

public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
serializer.SerializeValue(ref Major);
serializer.SerializeValue(ref Minor);
serializer.SerializeValue(ref Patch);
}
}

/// <summary>
/// Only used when connecting to the distributed authority service
/// </summary>
internal struct ClientConfig : INetworkSerializable
{
public NGOVersion NGOVersion;
/// <summary>
/// We start at version 1, where anything less than version 1 on the service side
/// is not bypass feature compatible.
/// </summary>
private const int k_BypassFeatureCompatible = 1;
public int Version => k_BypassFeatureCompatible;
public uint TickRate;
public bool EnableSceneManagement;

// Only gets deserialized but should never be used unless testing
public int RemoteClientVersion;

public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
serializer.SerializeNetworkSerializable(ref NGOVersion);
if (serializer.IsWriter)
{
var writer = serializer.GetFastBufferWriter();
writer.WriteValueSafe(TickRate);
BytePacker.WriteValueBitPacked(writer, Version);
BytePacker.WriteValueBitPacked(writer, TickRate);
writer.WriteValueSafe(EnableSceneManagement);
}
else
{
var reader = serializer.GetFastBufferReader();
reader.ReadValueSafe(out TickRate);
ByteUnpacker.ReadValueBitPacked(reader, out RemoteClientVersion);
ByteUnpacker.ReadValueBitPacked(reader, out TickRate);
reader.ReadValueSafe(out EnableSceneManagement);
}
}
Expand Down
Loading