Fix bug with delta state rewinder (#2871)
This commit is contained in:
parent
56594840ad
commit
7cc73ca9b0
|
@ -106,7 +106,7 @@ namespace BizHawk.Client.Common
|
||||||
_count++;
|
_count++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!_buffer.WillCapture(_masterFrame))
|
if (!_buffer.WouldCapture(frame - _masterFrame))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -189,7 +189,7 @@ namespace BizHawk.Client.Common
|
||||||
_masterLength = (int)sss.Position;
|
_masterLength = (int)sss.Position;
|
||||||
_masterFrame = frame;
|
_masterFrame = frame;
|
||||||
_count++;
|
_count++;
|
||||||
});
|
}, force: true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,31 +148,35 @@ namespace BizHawk.Client.Common
|
||||||
_backingStoreType == settings.BackingStore;
|
_backingStoreType == settings.BackingStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ShouldCapture(int frame)
|
private bool ShouldCaptureForFrameDiff(int frameDiff)
|
||||||
{
|
{
|
||||||
if (Count == 0)
|
if (Count == 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var frameDiff = frame - _states[HeadStateIndex].Frame;
|
|
||||||
if (frameDiff < 1)
|
if (frameDiff < 1)
|
||||||
|
{
|
||||||
// non-linear time is from a combination of other state changing mechanisms and the rewinder
|
// non-linear time is from a combination of other state changing mechanisms and the rewinder
|
||||||
// not much we can say here, so just take a state
|
// not much we can say here, so just take a state
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return frameDiff >= ComputeIdealRewindInterval();
|
||||||
|
}
|
||||||
|
|
||||||
return frameDiff >= ComputeIdealRewindInterval();
|
private bool ShouldCapture(int frame)
|
||||||
|
{
|
||||||
|
var frameDiff = frame - _states[HeadStateIndex].Frame;
|
||||||
|
return ShouldCaptureForFrameDiff(frameDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Predict whether Capture() will capture a state. Useful if expensive work needs to happen before
|
/// Predict whether Capture() would capture a state, assuming a particular frame delta.
|
||||||
/// Capture() is called.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="frame">The same frame number to be passed to capture</param>
|
/// <param name="frameDelta">The assumed frame delta. Normally this will be equal to `nextStateFrame - GetState(Count - 1).Frame`.</param>
|
||||||
/// <returns>Whether capture will happen, assuming Capture() is passed the same frame and force = false</returns>
|
/// <returns>Whether Capture(nextStateFrame) would actually capture, assuming the frameDelta matched.</returns>
|
||||||
public bool WillCapture(int frame)
|
public bool WouldCapture(int frameDelta)
|
||||||
{
|
{
|
||||||
return ShouldCapture(frame);
|
return ShouldCaptureForFrameDiff(frameDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue