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