-Fix: Loading a TasProj caued it to be saved immediately after. (Some old TasProj files are now broken.)
(Saving process for movies still needs some cleaning.) -Fixed setting input log by reference when loading a branch -Fix: TasStateManager wouldn't decrease Used when deleting a RAM state from a branch. -Removed a useless call to Movie.Save() -Fixed a bug with creating a savestate anchored tasproj.
This commit is contained in:
parent
19a1f6cbef
commit
f76c49ce1b
|
@ -464,6 +464,7 @@ namespace BizHawk.Client.Common
|
||||||
if (!record) // The semantics of record is that we are starting a new movie, and even wiping a pre-existing movie with the same path, but non-record means we are loading an existing movie into playback mode
|
if (!record) // The semantics of record is that we are starting a new movie, and even wiping a pre-existing movie with the same path, but non-record means we are loading an existing movie into playback mode
|
||||||
{
|
{
|
||||||
movie.Load(false);
|
movie.Load(false);
|
||||||
|
|
||||||
if (movie.SystemID != emulator.SystemId)
|
if (movie.SystemID != emulator.SystemId)
|
||||||
{
|
{
|
||||||
throw new MoviePlatformMismatchException(
|
throw new MoviePlatformMismatchException(
|
||||||
|
@ -475,11 +476,11 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Delete this, this save is utterly useless.
|
// TODO: Delete this, this save is utterly useless.
|
||||||
//If a movie is already loaded, save it before starting a new movie
|
// Movie was saved immediately before calling QueeuNewMovie. (StartNewMovie)
|
||||||
if (Movie.IsActive && !string.IsNullOrEmpty(Movie.Filename))
|
//if (Movie.IsActive && !string.IsNullOrEmpty(Movie.Filename))
|
||||||
{
|
//{
|
||||||
Movie.Save();
|
// Movie.Save();
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Note: this populates MovieControllerAdapter's Type with the approparite controller
|
// Note: this populates MovieControllerAdapter's Type with the approparite controller
|
||||||
// Don't set it to a movie instance of the adapter or you will lose the definition!
|
// Don't set it to a movie instance of the adapter or you will lose the definition!
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
||||||
}
|
}
|
||||||
|
|
||||||
bk2.HeaderEntries.Clear();
|
bk2.HeaderEntries.Clear();
|
||||||
foreach(var kvp in old.HeaderEntries)
|
foreach (var kvp in old.HeaderEntries)
|
||||||
{
|
{
|
||||||
bk2.HeaderEntries[kvp.Key] = kvp.Value;
|
bk2.HeaderEntries[kvp.Key] = kvp.Value;
|
||||||
}
|
}
|
||||||
|
@ -100,13 +100,13 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
||||||
bk2.SyncSettingsJson = old.SyncSettingsJson;
|
bk2.SyncSettingsJson = old.SyncSettingsJson;
|
||||||
|
|
||||||
bk2.Comments.Clear();
|
bk2.Comments.Clear();
|
||||||
foreach(var comment in old.Comments)
|
foreach (var comment in old.Comments)
|
||||||
{
|
{
|
||||||
bk2.Comments.Add(comment);
|
bk2.Comments.Add(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
bk2.Subtitles.Clear();
|
bk2.Subtitles.Clear();
|
||||||
foreach(var sub in old.Subtitles)
|
foreach (var sub in old.Subtitles)
|
||||||
{
|
{
|
||||||
bk2.Subtitles.Add(sub);
|
bk2.Subtitles.Add(sub);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,6 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
||||||
|
|
||||||
TasMovie tas = new TasMovie(newFilename, true);
|
TasMovie tas = new TasMovie(newFilename, true);
|
||||||
tas.BinarySavestate = savestate;
|
tas.BinarySavestate = savestate;
|
||||||
tas.TasStateManager.Clear();
|
|
||||||
tas.ClearLagLog();
|
tas.ClearLagLog();
|
||||||
|
|
||||||
List<string> entries = old.GetLogEntries();
|
List<string> entries = old.GetLogEntries();
|
||||||
|
@ -154,7 +153,9 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
||||||
|
|
||||||
// States can't be easily moved over, because they contain the frame number.
|
// States can't be easily moved over, because they contain the frame number.
|
||||||
// TODO? I'm not sure how this would be done.
|
// TODO? I'm not sure how this would be done.
|
||||||
|
tas.TasStateManager.MountWriteAccess();
|
||||||
|
old.TasStateManager.Clear();
|
||||||
|
|
||||||
// Lag Log
|
// Lag Log
|
||||||
tas.TasLagLog.FromLagLog(old.TasLagLog);
|
tas.TasLagLog.FromLagLog(old.TasLagLog);
|
||||||
tas.TasLagLog.StartFromFrame(frame);
|
tas.TasLagLog.StartFromFrame(frame);
|
||||||
|
@ -180,7 +181,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
||||||
tas.Subtitles.Add(sub);
|
tas.Subtitles.Add(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(TasMovieMarker marker in old.Markers)
|
foreach (TasMovieMarker marker in old.Markers)
|
||||||
{
|
{
|
||||||
if (marker.Frame > frame)
|
if (marker.Frame > frame)
|
||||||
tas.Markers.Add(new TasMovieMarker(marker.Frame - frame, marker.Message));
|
tas.Markers.Add(new TasMovieMarker(marker.Frame - frame, marker.Message));
|
||||||
|
@ -304,7 +305,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
||||||
movie.HeaderEntries.Add(key, firmware.Hash);
|
movie.HeaderEntries.Add(key, firmware.Hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Global.Emulator is Gameboy && (Global.Emulator as Gameboy).IsCGBMode())
|
if (Global.Emulator is Gameboy && (Global.Emulator as Gameboy).IsCGBMode())
|
||||||
|
|
|
@ -472,14 +472,10 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
int? divergentPoint = DivergantPoint(_log, branch.InputLog);
|
int? divergentPoint = DivergantPoint(_log, branch.InputLog);
|
||||||
|
|
||||||
_log = branch.InputLog;
|
_log = branch.InputLog.ToList();
|
||||||
_changes = true;
|
_changes = true;
|
||||||
LagLog.FromLagLog(branch.LagLog);
|
LagLog.FromLagLog(branch.LagLog);
|
||||||
|
|
||||||
//if (divergentPoint.HasValue)
|
|
||||||
// StateManager.Invalidate(divergentPoint.Value);
|
|
||||||
//else
|
|
||||||
// StateManager.Invalidate(branch.InputLog.Count);
|
|
||||||
StateManager.LoadBranch(Branches.IndexOf(branch));
|
StateManager.LoadBranch(Branches.IndexOf(branch));
|
||||||
|
|
||||||
StateManager.SetState(branch.Frame, branch.CoreData);
|
StateManager.SetState(branch.Frame, branch.CoreData);
|
||||||
|
|
|
@ -270,6 +270,7 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<tsmState> lowPriorityStates = new List<tsmState>();
|
||||||
private void MaybeRemoveState()
|
private void MaybeRemoveState()
|
||||||
{
|
{
|
||||||
int shouldRemove = -1;
|
int shouldRemove = -1;
|
||||||
|
@ -297,15 +298,8 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
shouldRemove++;
|
shouldRemove++;
|
||||||
|
|
||||||
//// No need to have two savestates with only lag frames between them:
|
if (lowPriorityStates.Count != 0)
|
||||||
//for (int i = shouldRemove + 1; i < States.Count; i++)
|
shouldRemove = States.IndexOfKey(lowPriorityStates[0].Frame);
|
||||||
//{
|
|
||||||
// if (AllLag(States.Keys[i - 1], States.Keys[i]))
|
|
||||||
// {
|
|
||||||
// shouldRemove = i - 1;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//// Find states with the fewest frames between them
|
//// Find states with the fewest frames between them
|
||||||
//for (int i = shouldRemove + 1; i < States.Count; i++)
|
//for (int i = shouldRemove + 1; i < States.Count; i++)
|
||||||
|
@ -321,7 +315,7 @@ namespace BizHawk.Client.Common
|
||||||
markerSkips--;
|
markerSkips--;
|
||||||
if (markerSkips < 0)
|
if (markerSkips < 0)
|
||||||
shouldRemove = _movie.StartsFromSavestate ? 0 : 1;
|
shouldRemove = _movie.StartsFromSavestate ? 0 : 1;
|
||||||
} while (_movie.Markers.IsMarker(States.ElementAt(shouldRemove).Key + 1) && markerSkips > -1);
|
} while (_movie.Markers.IsMarker(States.Keys[shouldRemove] + 1) && markerSkips > -1);
|
||||||
|
|
||||||
return shouldRemove;
|
return shouldRemove;
|
||||||
}
|
}
|
||||||
|
@ -370,6 +364,12 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
StateAccessed(frame);
|
StateAccessed(frame);
|
||||||
|
|
||||||
|
int i = States.IndexOfKey(frame);
|
||||||
|
if (i > 0 && AllLag(States.Keys[i - 1], States.Keys[i]))
|
||||||
|
{
|
||||||
|
lowPriorityStates.Add(States[frame]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void RemoveState(int frame, int branch = -1)
|
private void RemoveState(int frame, int branch = -1)
|
||||||
{
|
{
|
||||||
|
@ -378,8 +378,10 @@ namespace BizHawk.Client.Common
|
||||||
else
|
else
|
||||||
accessed.Remove(BranchStates[frame][branch]);
|
accessed.Remove(BranchStates[frame][branch]);
|
||||||
|
|
||||||
|
tsmState state;
|
||||||
if (branch == -1)
|
if (branch == -1)
|
||||||
{
|
{
|
||||||
|
state = States[frame];
|
||||||
if (States[frame].IsOnDisk)
|
if (States[frame].IsOnDisk)
|
||||||
States[frame].Dispose();
|
States[frame].Dispose();
|
||||||
else
|
else
|
||||||
|
@ -388,8 +390,11 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
state = BranchStates[frame][branch];
|
||||||
if (BranchStates[frame][branch].IsOnDisk)
|
if (BranchStates[frame][branch].IsOnDisk)
|
||||||
BranchStates[frame][branch].Dispose();
|
BranchStates[frame][branch].Dispose();
|
||||||
|
else
|
||||||
|
Used -= (ulong)BranchStates[frame][branch].Length;
|
||||||
BranchStates[frame].RemoveAt(BranchStates[frame].IndexOfKey(branch));
|
BranchStates[frame].RemoveAt(BranchStates[frame].IndexOfKey(branch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -445,15 +450,6 @@ namespace BizHawk.Client.Common
|
||||||
foreach (KeyValuePair<int, tsmState> state in statesToRemove)
|
foreach (KeyValuePair<int, tsmState> state in statesToRemove)
|
||||||
RemoveState(state.Key);
|
RemoveState(state.Key);
|
||||||
|
|
||||||
// Why did I put this here? The branches aren't being edited/invalidated.
|
|
||||||
//var bStateLists = BranchStates.Where(x => x.Key >= frame).ToList();
|
|
||||||
//anyInvalidated = anyInvalidated | bStateLists.Any();
|
|
||||||
//foreach (KeyValuePair<int, SortedList<int, tsmState>> stateList in bStateLists)
|
|
||||||
//{
|
|
||||||
// for (int i = 0; i < stateList.Value.Count; i++)
|
|
||||||
// RemoveState(stateList.Key, stateList.Value.Keys[i]);
|
|
||||||
//}
|
|
||||||
|
|
||||||
CallInvalidateCallback(frame);
|
CallInvalidateCallback(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -398,28 +398,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentTasMovie == null)
|
TasMovie newMovie = new TasMovie(false, _saveBackgroundWorker);
|
||||||
{
|
newMovie.TasStateManager.InvalidateCallback = GreenzoneInvalidated;
|
||||||
Global.MovieSession.Movie = new TasMovie(false, _saveBackgroundWorker);
|
newMovie.Filename = file.FullName;
|
||||||
(Global.MovieSession.Movie as TasMovie).TasStateManager.InvalidateCallback = GreenzoneInvalidated;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurrentTasMovie.Filename = file.FullName;
|
Settings.RecentTas.Add(newMovie.Filename);
|
||||||
try
|
|
||||||
{
|
|
||||||
CurrentTasMovie.Load(false);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
MessageBox.Show(
|
|
||||||
"Tastudio could not open the file. Due to the loading process, the emulator/Tastudio may be in a unspecified state depending on the error.",
|
|
||||||
"Tastudio",
|
|
||||||
MessageBoxButtons.OK);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Settings.RecentTas.Add(CurrentTasMovie.Filename);
|
|
||||||
|
|
||||||
if (!HandleMovieLoadStuff())
|
if (!HandleMovieLoadStuff(newMovie))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BookMarkControl.UpdateValues();
|
BookMarkControl.UpdateValues();
|
||||||
|
@ -450,11 +435,16 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private bool HandleMovieLoadStuff(TasMovie movie = null)
|
private bool HandleMovieLoadStuff(TasMovie movie = null)
|
||||||
{
|
{
|
||||||
if (movie == null)
|
|
||||||
movie = CurrentTasMovie;
|
|
||||||
|
|
||||||
WantsToControlStopMovie = false;
|
WantsToControlStopMovie = false;
|
||||||
bool result = StartNewMovieWrapper(movie.InputLogLength == 0, movie);
|
bool result;
|
||||||
|
if (movie == null)
|
||||||
|
{
|
||||||
|
movie = CurrentTasMovie;
|
||||||
|
result = StartNewMovieWrapper(movie.InputLogLength == 0, movie);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result = StartNewMovieWrapper(false, movie);
|
||||||
if (!result)
|
if (!result)
|
||||||
return false;
|
return false;
|
||||||
WantsToControlStopMovie = true;
|
WantsToControlStopMovie = true;
|
||||||
|
|
Loading…
Reference in New Issue