diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs index b95d87e81a..30ae36affc 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs @@ -68,8 +68,8 @@ namespace BizHawk.Client.Common if (!IsOnDisk) return; - var key = ID.ToString(); - var ret = _manager.ndbdatabase.FetchAll(key); + string key = ID.ToString(); + _state = _manager.ndbdatabase.FetchAll(key); _manager.ndbdatabase.Release(key); } public void Dispose() @@ -144,7 +144,7 @@ namespace BizHawk.Client.Common return -2; } - public string statePath + private string statePath { get { @@ -313,6 +313,9 @@ namespace BizHawk.Client.Common if (Used > Settings.Cap) { + if (DiskUsed > (ulong)Settings.DiskCapacitymb * 1024uL * 1024uL) + MaybeRemoveState(); + int lastMemState = -1; do { lastMemState++; } while (States[accessed[lastMemState]] == null); MoveStateToDisk(accessed[lastMemState]); @@ -528,6 +531,16 @@ namespace BizHawk.Client.Common ndbdatabase.Clear(); } + /// + /// Deletes/moves states to follow the state storage size limits. + /// Used after changing the settings. + /// + public void LimitStateCount() + { + while (Used + DiskUsed > Settings.CapTotal) + MaybeRemoveState(); + } + // TODO: save/load BranchStates public void Save(BinaryWriter bw) { diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs index 2bccac30a1..6d4572f7f3 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs @@ -48,7 +48,9 @@ namespace BizHawk.Client.EmuHawk private int MaxStatesInCapacity { - get { return (int)Math.Floor((MemCapacityNumeric.Value + DiskCapacityNumeric.Value) / _stateSizeMb); } + get { return (int)Math.Floor(MemCapacityNumeric.Value / _stateSizeMb) + + (int)Math.Floor(DiskCapacityNumeric.Value / _stateSizeMb); + } } private void OkBtn_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index cc9ef02677..8b3525b2fe 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -748,6 +748,7 @@ namespace BizHawk.Client.EmuHawk Location = this.ChildPointToScreen(TasView), Statable = this.StatableEmulator }.Show(); + CurrentTasMovie.TasStateManager. UpdateChangesIndicator(); }