Skip to content

Commit 72d3d49

Browse files
refactor
removing the timeout code to reduce confusion on the changes to NetworkVariableTests.
1 parent 82d243f commit 72d3d49

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableTests.cs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,6 @@ public static void ClientNetworkVariableTestSpawned(NetworkVariableTest networkV
8383
s_ClientNetworkVariableTestInstances.Add(networkVariableTest);
8484
}
8585

86-
private const float k_TimeOutWaitPeriod = 2.0f;
87-
private static float s_TimeOutPeriod;
88-
89-
/// <summary>
90-
/// This will simply advance the timeout period
91-
/// </summary>
92-
private static void AdvanceTimeOutPeriod()
93-
{
94-
s_TimeOutPeriod = Time.realtimeSinceStartup + k_TimeOutWaitPeriod;
95-
}
96-
97-
/// <summary>
98-
/// Checks if the timeout period has elapsed
99-
/// </summary>
100-
private static bool HasTimedOut()
101-
{
102-
return s_TimeOutPeriod <= Time.realtimeSinceStartup;
103-
}
104-
10586
// Player1 component on the server
10687
private NetworkVariableTest m_Player1OnServer;
10788

@@ -180,12 +161,13 @@ private IEnumerator InitializeServerAndClients(bool useHost)
180161
var allClientNetworkVariableTestInstancesSpawned = false;
181162
var waitPeriod = 1.0f / m_ServerNetworkManager.NetworkConfig.TickRate;
182163
var timedOut = false;
183-
AdvanceTimeOutPeriod();
184-
while (!allClientNetworkVariableTestInstancesSpawned && !HasTimedOut())
164+
var timeOutPeriod = Time.realtimeSinceStartup + 2.0f;
165+
166+
while (!allClientNetworkVariableTestInstancesSpawned && !timedOut)
185167
{
186168
allClientNetworkVariableTestInstancesSpawned = s_ClientNetworkVariableTestInstances.Count >= NbClients;
187-
timedOut = HasTimedOut();
188169
yield return new WaitForSeconds(waitPeriod);
170+
timedOut = timeOutPeriod < Time.realtimeSinceStartup;
189171
}
190172

191173
Assert.False(timedOut, "Timed out waiting for all client NetworkVariableTest instances to register they have spawned!");

0 commit comments

Comments
 (0)