Fix `.tasproj` autoload loading mismatched savestates
This commit is contained in:
parent
a63efffa14
commit
84fd85c749
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common.PathExtensions;
|
||||
using BizHawk.Common.StringExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
|
@ -192,6 +194,8 @@ namespace BizHawk.Client.Common
|
|||
IMovie movie,
|
||||
bool record,
|
||||
string systemId,
|
||||
string loadedRomHash,
|
||||
PathEntryCollection pathEntries,
|
||||
IDictionary<string, string> preferredCores)
|
||||
{
|
||||
if (movie.IsActive() && movie.Changes)
|
||||
|
@ -208,6 +212,22 @@ namespace BizHawk.Client.Common
|
|||
throw new MoviePlatformMismatchException(
|
||||
$"Movie system Id ({movie.SystemID}) does not match the currently loaded platform ({systemId}), unable to load");
|
||||
}
|
||||
|
||||
if (!(string.IsNullOrEmpty(movie.Hash) || loadedRomHash.Equals(movie.Hash, StringComparison.Ordinal))
|
||||
&& movie is TasMovie tasproj)
|
||||
{
|
||||
var result = _dialogParent.ModalMessageBox2(
|
||||
caption: "Discard GreenZone?",
|
||||
text: $"The TAStudio project {movie.Filename.MakeRelativeTo(pathEntries.MovieAbsolutePath())} appears to be for a different game than the one that's loaded.\n"
|
||||
+ "Choose \"No\" to continue anyway, which may lead to an invalid savestate being loaded.\n"
|
||||
+ "Choose \"Yes\" to discard the GreenZone (savestate history). This is safer, and at worst you'll only need to watch through the whole movie.");
|
||||
//TODO add abort option
|
||||
if (result)
|
||||
{
|
||||
tasproj.TasSession.UpdateValues(frame: 0, currentBranch: tasproj.TasSession.CurrentBranch); // wtf is this API --yoshi
|
||||
tasproj.InvalidateEntireGreenzone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!record)
|
||||
|
|
|
@ -81,6 +81,8 @@ namespace BizHawk.Client.Common
|
|||
IMovie movie,
|
||||
bool record,
|
||||
string systemId,
|
||||
string loadedRomHash,
|
||||
PathEntryCollection pathEntries,
|
||||
IDictionary<string, string> preferredCores);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -149,6 +149,8 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public void InvalidateEntireGreenzone()
|
||||
=> InvalidateAfter(0);
|
||||
|
||||
private (int Frame, IMovieController Controller) _displayCache = (-1, new Bk2Controller("", NullController.Instance.Definition));
|
||||
|
||||
|
|
|
@ -27,7 +27,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
try
|
||||
{
|
||||
MovieSession.QueueNewMovie(movie, record, Emulator.SystemId, Config.PreferredCores);
|
||||
MovieSession.QueueNewMovie(
|
||||
movie,
|
||||
record: record,
|
||||
systemId: Emulator.SystemId,
|
||||
loadedRomHash: Game.Hash,
|
||||
Config.PathEntries,
|
||||
Config.PreferredCores);
|
||||
}
|
||||
catch (MoviePlatformMismatchException ex)
|
||||
{
|
||||
|
@ -54,6 +60,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
SetMainformMovieInfo();
|
||||
|
||||
// turns out this was too late for .tasproj autoloading and restoring playback position (loads savestate but wasn't checking game match)
|
||||
if (string.IsNullOrEmpty(MovieSession.Movie.Hash))
|
||||
{
|
||||
AddOnScreenMessage("Movie is missing hash, skipping hash check");
|
||||
|
|
Loading…
Reference in New Issue