Fixed a few bugs in TasStateManager.cs

This commit is contained in:
Suuper 2016-02-20 12:00:05 -06:00
parent 1c4c5fb4a3
commit 8b5440d963
1 changed files with 8 additions and 4 deletions

View File

@ -527,7 +527,11 @@ namespace BizHawk.Client.Common
do
{
index++;
if (index >= States.Count)
break;
} while (_movie.Markers.IsMarker(States.ElementAt(index).Key + 1));
if (index >= States.Count) break;
ret.Add(index);
if (States.ElementAt(index).Value.IsOnDisk)
saveUsed -= _expectedStateSize;
@ -540,7 +544,8 @@ namespace BizHawk.Client.Common
while (saveUsed > (ulong)Settings.DiskSaveCapacitymb * 1024 * 1024)
{
index++;
ret.Add(index);
if (!ret.Contains(index))
ret.Add(index);
if (States.ElementAt(index).Value.IsOnDisk)
saveUsed -= _expectedStateSize;
else
@ -565,7 +570,7 @@ namespace BizHawk.Client.Common
bw.Write(kvp.Key);
bw.Write(kvp.Value.Length);
bw.Write(kvp.Value.State);
_movie.ReportProgress((double)100d / States.Count * i);
_movie.ReportProgress(100d / States.Count * i);
}
}
@ -776,7 +781,7 @@ namespace BizHawk.Client.Common
BranchStates[kvp.Key] = stateList;
}
stateList.Add(branchHash, kvp.Value);
Used += (ulong)stateList[branchHash].Length;
// We aren't creating any new states, just adding a reference to an already-existing one; so Used doesn't need to be updated.
}
}
@ -848,7 +853,6 @@ namespace BizHawk.Client.Common
BranchStates[kvp.Key] = stateList;
}
stateList.Add(branchHash, kvp.Value);
Used += (ulong)stateList[branchHash].Length;
}
}