Skip to content
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 @@ -62,7 +62,7 @@ public IEnumerator PlayerLoopTimeTest_WithDifferentTimeScale([Values(0.0f, 0.1f,
public IEnumerator CorrectAmountTicksTest()
{
NetworkTickSystem tickSystem = NetworkManager.Singleton.NetworkTickSystem;
float delta = tickSystem.LocalTime.FixedDeltaTime;
double delta = tickSystem.LocalTime.FixedDeltaTimeAsDouble;
int previous_localTickCalculated = 0;
int previous_serverTickCalculated = 0;

Expand All @@ -79,7 +79,6 @@ public IEnumerator CorrectAmountTicksTest()
previous_localTickCalculated++;
}


tickCalculated = NetworkManager.Singleton.ServerTime.Time / delta;
previous_serverTickCalculated = (int)tickCalculated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public IEnumerator TestClientTimeInitializationOnConnect([Values(0, 1f)] float s
yield return new WaitUntil(() => server.NetworkTickSystem.ServerTime.Tick > 2);

var serverTimePassed = server.NetworkTickSystem.ServerTime.Time;
var expectedServerTickCount = Mathf.FloorToInt((float)(serverTimePassed * 30));

// Use FixedDeltaTimeAsDouble and divide the tick frequency into the time passed to get the accurate tick count
var expectedServerTickCount = (int)System.Math.Floor(serverTimePassed / server.ServerTime.FixedDeltaTimeAsDouble);
var ticksPassed = server.NetworkTickSystem.ServerTime.Tick - serverTick;
Assert.AreEqual(expectedServerTickCount, ticksPassed);
Assert.AreEqual(expectedServerTickCount, ticksPassed, $"Calculated tick failed: Tick ({expectedServerTickCount}) TicksPassed ({ticksPassed}) Server Tick ({server.NetworkTickSystem.ServerTime.Tick}) Prev-Server Tick ({serverTick})");

yield return new WaitForSeconds(clientStartDelay);

Expand Down