rip out IStateManager.MountForWriteAccess() and simplify
This commit is contained in:
parent
c87c1d8328
commit
eaef336492
|
@ -37,7 +37,6 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
|||
}
|
||||
|
||||
var tas = new TasMovie(newFilename, old.StartsFromSavestate);
|
||||
tas.TasStateManager.MountWriteAccess();
|
||||
|
||||
for (var i = 0; i < old.InputLogLength; i++)
|
||||
{
|
||||
|
@ -167,7 +166,6 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
|||
|
||||
// States can't be easily moved over, because they contain the frame number.
|
||||
// TODO? I'm not sure how this would be done.
|
||||
tas.TasStateManager.MountWriteAccess();
|
||||
old.TasStateManager.Clear();
|
||||
|
||||
// Lag Log
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
public interface IStateManager
|
||||
{
|
||||
// byte[] this[int frame] { get; } // TODO: I had it refactored to this back in the day
|
||||
|
@ -45,8 +42,5 @@ namespace BizHawk.Client.Common
|
|||
int GetStateFrameByIndex(int index);
|
||||
|
||||
bool Remove(int frame);
|
||||
|
||||
// ********* Delete these **********
|
||||
void MountWriteAccess();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,15 +18,11 @@ namespace BizHawk.Client.Common
|
|||
// TODO: pass this in, and find a solution to a stale reference (this is instantiated BEFORE a new core instance is made, making this one stale if it is simply set in the constructor
|
||||
private IStatable Core => Global.Emulator.AsStatable();
|
||||
private readonly StateManagerDecay _decay;
|
||||
|
||||
public Action<int> InvalidateCallback { get; set; }
|
||||
|
||||
private SortedList<int, StateManagerState> _states = new SortedList<int, StateManagerState>();
|
||||
|
||||
private bool _isMountedForWrite;
|
||||
private readonly TasMovie _movie;
|
||||
|
||||
private ulong _expectedStateSize;
|
||||
private readonly SortedList<int, StateManagerState> _states;
|
||||
private readonly ulong _expectedStateSize;
|
||||
|
||||
private int _stateFrequency;
|
||||
private readonly int _minFrequency = 1;
|
||||
private readonly int _maxFrequency = 16;
|
||||
|
@ -45,8 +41,20 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
_decay = new StateManagerDecay(_movie, this);
|
||||
|
||||
_expectedStateSize = (ulong)Core.SaveStateBinary().Length;
|
||||
if (_expectedStateSize == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Savestate size can not be zero!");
|
||||
}
|
||||
|
||||
_states = new SortedList<int, StateManagerState>(MaxStates);
|
||||
|
||||
UpdateStateFrequency();
|
||||
}
|
||||
|
||||
public Action<int> InvalidateCallback { get; set; }
|
||||
|
||||
public void UpdateStateFrequency()
|
||||
{
|
||||
_stateFrequency = ((int)_expectedStateSize / Settings.MemStateGapDivider / 1024)
|
||||
|
@ -56,34 +64,6 @@ namespace BizHawk.Client.Common
|
|||
LimitStateCount();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mounts this instance for write access. Prior to that it's read-only
|
||||
/// </summary>
|
||||
public void MountWriteAccess()
|
||||
{
|
||||
if (_isMountedForWrite)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int limit = 0;
|
||||
_isMountedForWrite = true;
|
||||
_expectedStateSize = (ulong)Core.SaveStateBinary().Length;
|
||||
UpdateStateFrequency();
|
||||
|
||||
if (_expectedStateSize > 0)
|
||||
{
|
||||
limit = MaxStates;
|
||||
}
|
||||
|
||||
_states = new SortedList<int, StateManagerState>(limit);
|
||||
|
||||
if (_expectedStateSize > int.MaxValue)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public TasStateManagerSettings Settings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -5,10 +5,6 @@ using System.Windows.Forms;
|
|||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
|
||||
using BizHawk.Emulation.Cores.Nintendo.NES;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES9X;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -30,9 +26,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
try
|
||||
{
|
||||
var tasmovie = (movie as TasMovie);
|
||||
if (tasmovie != null)
|
||||
tasmovie.TasStateManager.MountWriteAccess();
|
||||
Global.MovieSession.QueueNewMovie(movie, record, Emulator);
|
||||
}
|
||||
catch (MoviePlatformMismatchException ex)
|
||||
|
|
|
@ -642,7 +642,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
Global.MovieSession.Movie = new TasMovie(false, _seekBackgroundWorker);
|
||||
var stateManager = ((TasMovie)Global.MovieSession.Movie).TasStateManager;
|
||||
|
||||
stateManager.MountWriteAccess();
|
||||
stateManager.InvalidateCallback = GreenzoneInvalidated;
|
||||
|
||||
BookMarkControl.LoadedCallback = BranchLoaded;
|
||||
|
|
Loading…
Reference in New Issue