diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index b581150df8..7105a6e705 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -21,6 +21,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed +- Fixed issue where clients were not rebuilding the `NetworkConfig` hash value for each unique connection request. (#2226) - Fixed the issue where player objects were not taking the `DontDestroyWithOwner` property into consideration when a client disconnected. (#2225) - Fixed issue #1924 where `UnityTransport` would fail to restart after a first failure (even if what caused the initial failure was addressed). (#2220) - Fixed issue where `NetworkTransform.SetStateServerRpc` and `NetworkTransform.SetStateClientRpc` were not honoring local vs world space settings when applying the position and rotation. (#2203) diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs index 37fbf69e46..b7a0903375 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs @@ -1609,7 +1609,9 @@ private void SendConnectionRequest() { var message = new ConnectionRequestMessage { - ConfigHash = NetworkConfig.GetConfig(), + // Since only a remote client will send a connection request, + // we should always force the rebuilding of the NetworkConfig hash value + ConfigHash = NetworkConfig.GetConfig(false), ShouldSendConnectionData = NetworkConfig.ConnectionApproval, ConnectionData = NetworkConfig.ConnectionData }; diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/ConnectionApproval.cs b/com.unity.netcode.gameobjects/Tests/Runtime/ConnectionApproval.cs index 8c8f6e594a..4e7ec9581d 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/ConnectionApproval.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/ConnectionApproval.cs @@ -62,11 +62,27 @@ private void NetworkManagerObject_ConnectionApprovalCallback(NetworkManager.Conn response.PlayerPrefabHash = null; } + + [Test] + public void VerifyUniqueNetworkConfigPerRequest() + { + var networkConfig = new NetworkConfig(); + networkConfig.EnableSceneManagement = true; + networkConfig.TickRate = 30; + var currentHash = networkConfig.GetConfig(); + networkConfig.EnableSceneManagement = false; + networkConfig.TickRate = 60; + var newHash = networkConfig.GetConfig(false); + + Assert.True(currentHash != newHash, $"Hashed {nameof(NetworkConfig)} values {currentHash} and {newHash} should not be the same!"); + } + [TearDown] public void TearDown() { // Stop, shutdown, and destroy NetworkManagerHelper.ShutdownNetworkManager(); } + } }