Skip to content

Commit a7412d2

Browse files
NoelStephensUnitymichalChrobot
authored andcommitted
update
Replace the two places where Debug.Assert is used in UnityTransport to be DEBUG wrapped checks that log warnings as opposed to throwing asserts in order to avoid being considered a failed test run even if all tests have passed.
1 parent 123ff3d commit a7412d2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,13 @@ public override void DisconnectLocalClient()
11671167
/// <param name="clientId">The client to disconnect</param>
11681168
public override void DisconnectRemoteClient(ulong clientId)
11691169
{
1170-
Debug.Assert(m_State == State.Listening, "DisconnectRemoteClient should be called on a listening server");
1170+
#if DEBUG
1171+
if (m_State != State.Listening)
1172+
{
1173+
Debug.LogWarning("DisconnectRemoteClient should be called on a listening server!");
1174+
return;
1175+
}
1176+
#endif
11711177

11721178
if (m_State == State.Listening)
11731179
{
@@ -1239,7 +1245,13 @@ public NetworkEndpoint GetEndpoint(ulong clientId)
12391245
/// <param name="networkManager">The NetworkManager that initialized and owns the transport</param>
12401246
public override void Initialize(NetworkManager networkManager = null)
12411247
{
1242-
Debug.Assert(sizeof(ulong) == UnsafeUtility.SizeOf<NetworkConnection>(), "Netcode connection id size does not match UTP connection id size");
1248+
#if DEBUG
1249+
if (sizeof(ulong) != UnsafeUtility.SizeOf<NetworkConnection>())
1250+
{
1251+
Debug.LogWarning($"Netcode connection id size {sizeof(ulong)} does not match UTP connection id size {UnsafeUtility.SizeOf<NetworkConnection>()}!");
1252+
return;
1253+
}
1254+
#endif
12431255

12441256
NetworkManager = networkManager;
12451257

0 commit comments

Comments
 (0)