only apply gap filling at the start of the start of an interval. This addresses the "odd" behavior that if you have a gap of 10 in current, and navigate from frame 100 to 99, you get a state saved at 91

This commit is contained in:
adelikat 2020-08-23 20:40:36 -05:00
parent e6ceb1c323
commit 44d7603622
1 changed files with 13 additions and 1 deletions

View File

@ -219,7 +219,11 @@ namespace BizHawk.Client.Common
// reserved states can include future states in the case of branch states // reserved states can include future states in the case of branch states
if (frame <= LastRing) if (frame <= LastRing)
{ {
CaptureGap(frame, source); if (NeedsGap(frame))
{
CaptureGap(frame, source);
}
return; return;
} }
@ -288,6 +292,14 @@ namespace BizHawk.Client.Common
return false; return false;
} }
private bool NeedsGap(int frame)
{
// When starting to fill gaps we won't actually know the true frequency, so fall back to current
// Current may very well not be the same as gap, but it's a reasonable behavior to have a current sized gap before seeing filler sized gaps
var frequency = _gapFiller.Count == 0 ? _current.RewindFrequency : _gapFiller.RewindFrequency;
return !StateCache.Any(sc => sc < frame && sc > frame - frequency);
}
private void CaptureGap(int frame, IStatable source) private void CaptureGap(int frame, IStatable source)
{ {
_gapFiller.Capture( _gapFiller.Capture(