Fix NaN propagation in RewindConfig

This commit is contained in:
YoshiRulz 2023-02-05 20:48:48 +10:00
parent b1e8d93f5f
commit f473db56c3
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 17 additions and 15 deletions

View File

@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk
{
public partial class RewindConfig : Form
{
private double _avgStateSize;
private ulong _avgStateSize;
private readonly Config _config;
@ -34,15 +34,17 @@ namespace BizHawk.Client.EmuHawk
var rewinder = _getRewinder();
if (rewinder?.Active == true)
{
FullnessLabel.Text = $"{rewinder.FullnessRatio:P2}";
RewindFramesUsedLabel.Text = rewinder.Count.ToString();
_avgStateSize = rewinder.Size * rewinder.FullnessRatio / rewinder.Count;
var fullnessRatio = rewinder.FullnessRatio;
FullnessLabel.Text = $"{fullnessRatio:P2}";
var stateCount = rewinder.Count;
RewindFramesUsedLabel.Text = stateCount.ToString();
_avgStateSize = stateCount is 0 ? 0UL : (ulong) Math.Round(rewinder.Size * fullnessRatio / stateCount);
}
else
{
FullnessLabel.Text = "N/A";
RewindFramesUsedLabel.Text = "N/A";
_avgStateSize = _statableCore.CloneSavestate().Length;
_avgStateSize = (ulong) _statableCore.CloneSavestate().Length;
}
RewindEnabledBox.Checked = _config.Rewind.Enabled;
@ -77,7 +79,7 @@ namespace BizHawk.Client.EmuHawk
ScreenshotInStatesCheckbox.Checked;
}
private string FormatKB(double n)
private string FormatKB(ulong n)
{
double num = n / 1024.0;
@ -139,16 +141,16 @@ namespace BizHawk.Client.EmuHawk
private void CalculateEstimates()
{
var bufferSize = 1L << (int) BufferSizeUpDown.Value;
labelEx1.Text = bufferSize.ToString();
bufferSize *= 1024 * 1024;
var estFrames = bufferSize / _avgStateSize;
double estTotalFrames = estFrames;
double minutes = estTotalFrames / 60 / 60;
double estFrames = 0.0;
if (_avgStateSize is not 0UL)
{
var bufferSize = 1L << (int) BufferSizeUpDown.Value;
labelEx1.Text = bufferSize.ToString();
bufferSize *= 1024 * 1024;
estFrames = bufferSize / (double) _avgStateSize;
}
ApproxFramesLabel.Text = $"{estFrames:n0} frames";
EstTimeLabel.Text = $"{minutes:n} minutes";
EstTimeLabel.Text = $"{estFrames / 3600.0:n} minutes";
}
private void BufferSizeUpDown_ValueChanged(object sender, EventArgs e)