diff --git a/UniTAS/Patcher/Implementations/FrameAdvancing/FrameAdvancing.cs b/UniTAS/Patcher/Implementations/FrameAdvancing/FrameAdvancing.cs index 273283df..3b484392 100644 --- a/UniTAS/Patcher/Implementations/FrameAdvancing/FrameAdvancing.cs +++ b/UniTAS/Patcher/Implementations/FrameAdvancing/FrameAdvancing.cs @@ -91,6 +91,7 @@ public void UpdateUnconditional() _fixedUpdateIndex = 0; } + // check if update offset is valid after the last fixed update if (_pendingUpdateOffsetFixState == PendingUpdateOffsetFixState.PendingCheckUpdateOffset) { var actualOffset = _pendingUpdateOffsetFixStateCheckingOffset + _timeEnv.FrameTime; @@ -102,9 +103,16 @@ public void UpdateUnconditional() $"invalid offset after FixedUpdate, expected {actualOffset}, current: {UpdateInvokeOffset.Offset}, fixing"); _syncFixedUpdate.OnSync(_updateOffsetSyncFix, actualOffset); // pause until offset is synced - // this also presents this broken Update + // this also prevents this broken Update _monoBehaviourController.PausedExecution = true; _pendingUpdateOffsetFixState = PendingUpdateOffsetFixState.PendingSync; + + // also _pendingPauseFrames needs to be decrease + if (_pendingPauseFrames > 0) + { + _pendingPauseFrames--; + } + return; } @@ -158,6 +166,9 @@ private void FrameAdvanceUpdate(bool update) CheckAndAddPendingFrameAdvances(); + // do we have new frame advance to do? don't bother pausing then + if (_pendingPauseFrames != 0) return; + _coroutine.Start(Pause(update)); } diff --git a/UniTAS/Patcher/Implementations/VirtualEnvironment/TimeEnv.cs b/UniTAS/Patcher/Implementations/VirtualEnvironment/TimeEnv.cs index bda215e7..4a5fe838 100644 --- a/UniTAS/Patcher/Implementations/VirtualEnvironment/TimeEnv.cs +++ b/UniTAS/Patcher/Implementations/VirtualEnvironment/TimeEnv.cs @@ -8,7 +8,6 @@ using UniTAS.Patcher.Services; using UniTAS.Patcher.Services.UnitySafeWrappers.Wrappers; using UniTAS.Patcher.Services.VirtualEnvironment; -using UniTAS.Patcher.Utils; using UnityEngine; namespace UniTAS.Patcher.Implementations.VirtualEnvironment; @@ -81,7 +80,6 @@ public void PreUpdateActual() public void OnLastUpdateActual() { - StaticLogger.Log.LogDebug($"Adding ft {FrameTime}"); RealtimeSinceStartup += FrameTime; UnscaledTime += FrameTime; // TODO test if this works accurately vs before