Refactor last commit and some other code so that reset happens in a singular place when loading a state from the state manager
This commit is contained in:
parent
59494767f5
commit
e3b6d29956
|
@ -5,13 +5,13 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class TasMovieRecord
|
||||
{
|
||||
public byte[] State { get; set; }
|
||||
public KeyValuePair<int, byte[]> State { get; set; }
|
||||
public bool? Lagged { get; set; }
|
||||
public string LogEntry { get; set; }
|
||||
|
||||
public bool HasState
|
||||
{
|
||||
get { return State.Any(); }
|
||||
get { return State.Value.Any(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,21 +68,21 @@ namespace BizHawk.Client.Common
|
|||
/// If this frame does not have a state currently, will return an empty array
|
||||
/// </summary>
|
||||
/// <returns>A savestate for the given frame or an empty array if there isn't one</returns>
|
||||
public byte[] this[int frame]
|
||||
public KeyValuePair<int, byte[]> this[int frame]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (frame == 0 && _movie.StartsFromSavestate)
|
||||
{
|
||||
return _movie.BinarySavestate;
|
||||
return new KeyValuePair<int,byte[]>(0, _movie.BinarySavestate);
|
||||
}
|
||||
|
||||
if (States.ContainsKey(frame))
|
||||
{
|
||||
return States[frame];
|
||||
return new KeyValuePair<int,byte[]>(frame, States[frame]);
|
||||
}
|
||||
|
||||
return new byte[0];
|
||||
return new KeyValuePair<int,byte[]>(-1, new byte[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -509,7 +509,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
var state = (byte[])Global.Emulator.SaveStateBinary().Clone();
|
||||
var greenzone = CurrentTasMovie.TasStateManager[frame];
|
||||
|
||||
if (!state.SequenceEqual(greenzone))
|
||||
if (!state.SequenceEqual(greenzone.Value))
|
||||
{
|
||||
MessageBox.Show("bad data at frame: " + frame);
|
||||
return;
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (CurrentTasMovie[goToFrame].HasState) // Go back 1 frame and emulate to get the display (we don't store that)
|
||||
{
|
||||
CurrentTasMovie.SwitchToPlay();
|
||||
LoadState(CurrentTasMovie[goToFrame].State.ToArray());
|
||||
LoadState(CurrentTasMovie[goToFrame].State);
|
||||
|
||||
if (frame > 0) // We can't emulate up to frame 0!
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (CurrentTasMovie[goToFrame].HasState) // Can we go directly there?
|
||||
{
|
||||
CurrentTasMovie.SwitchToPlay();
|
||||
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(CurrentTasMovie[goToFrame].State.ToArray())));
|
||||
LoadState(CurrentTasMovie[goToFrame].State);
|
||||
Global.Emulator.FrameAdvance(true);
|
||||
GlobalWin.DisplayManager.NeedsToPaint = true;
|
||||
|
||||
|
@ -100,7 +100,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (CurrentTasMovie.TasStateManager.LastEmulatedFrame > 0 && shouldLoadstate)
|
||||
{
|
||||
LoadState(CurrentTasMovie[CurrentTasMovie.TasStateManager.LastEmulatedFrame].State.ToArray());
|
||||
LoadState(CurrentTasMovie[CurrentTasMovie.TasStateManager.LastEmulatedFrame].State);
|
||||
}
|
||||
|
||||
if (frame != Global.Emulator.Frame) // If we aren't already at our destination, seek
|
||||
|
|
|
@ -303,21 +303,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
KeyValuePair<int, byte[]> closestState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame);
|
||||
if (closestState.Value != null)
|
||||
{
|
||||
LoadState(closestState.Value.ToArray());
|
||||
|
||||
if (closestState.Key == 0 && CurrentTasMovie.StartsFromSavestate)
|
||||
{
|
||||
Global.Emulator.ResetCounters();
|
||||
}
|
||||
LoadState(closestState);
|
||||
}
|
||||
|
||||
GlobalWin.MainForm.PauseOnFrame = frame;
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
}
|
||||
|
||||
private void LoadState(byte[] state)
|
||||
private void LoadState(KeyValuePair<int, byte[]> state)
|
||||
{
|
||||
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(state)));
|
||||
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(state.Value.ToArray())));
|
||||
|
||||
if (state.Key == 0 && CurrentTasMovie.StartsFromSavestate)
|
||||
{
|
||||
Global.Emulator.ResetCounters();
|
||||
}
|
||||
|
||||
_hackyDontUpdate = true;
|
||||
GlobalWin.Tools.UpdateBefore();
|
||||
|
|
Loading…
Reference in New Issue