Fix the timestep jank threshold.
This commit is contained in:
committed by
Matthias Mailänder
parent
d5edbc2bc7
commit
7e9793fa90
@@ -74,9 +74,8 @@ namespace OpenRA
|
||||
public static int NetFrameNumber { get { return orderManager.NetFrameNumber; } }
|
||||
public static int LocalTick { get { return orderManager.LocalFrameNumber; } }
|
||||
public const int NetTickScale = 3; // 120 ms net tick for 40 ms local tick
|
||||
public const int MinTick = 1;
|
||||
public const int MaxTick = 10;
|
||||
public const int Timestep = 40;
|
||||
public const int TimestepJankThreshold = 250; // Don't catch up for delays larger than 250ms
|
||||
|
||||
public static event Action<OrderManager> ConnectionStateChanged = _ => { };
|
||||
static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
|
||||
@@ -181,9 +180,13 @@ namespace OpenRA
|
||||
if (worldTimestep != 0 && worldTickDelta >= worldTimestep)
|
||||
using (new PerfSample("tick_time"))
|
||||
{
|
||||
var relativeTickDelta = (worldTickDelta / worldTimestep) * worldTimestep;
|
||||
var tickIntervall = relativeTickDelta > MinTick && relativeTickDelta < MaxTick ? MinTick : relativeTickDelta;
|
||||
orderManager.LastTickTime += tickIntervall;
|
||||
// Tick the world to advance the world time to match real time:
|
||||
// If dt < TickJankThreshold then we should try and catch up by repeatedly ticking
|
||||
// If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate
|
||||
// dt is rounded down to an integer tick count in order to preserve fractional tick components.
|
||||
|
||||
var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep;
|
||||
orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep;
|
||||
|
||||
if (orderManager.GameStarted)
|
||||
++Viewport.TicksSinceLastMove;
|
||||
|
||||
Reference in New Issue
Block a user