Rip out the saving, checking, and dealing with Guids for movie files, it is an outdated notion.
This commit is contained in:
parent
bc860a4bcf
commit
ec030ae05e
|
@ -13,7 +13,6 @@ namespace BizHawk.Client.Common
|
|||
public const string GAMENAME = "GameName";
|
||||
public const string AUTHOR = "Author";
|
||||
public const string RERECORDS = "rerecordCount";
|
||||
public const string GUID = "GUID";
|
||||
public const string STARTSFROMSAVESTATE = "StartsFromSavestate";
|
||||
public const string FOURSCORE = "FourScore";
|
||||
public const string SHA1 = "SHA1";
|
||||
|
@ -35,11 +34,6 @@ namespace BizHawk.Client.Common
|
|||
// Board properties
|
||||
public const string BOARDPROPERTIES = "BoardProperty";
|
||||
|
||||
public static string NewGuid
|
||||
{
|
||||
get { return Guid.NewGuid().ToString(); }
|
||||
}
|
||||
|
||||
public static bool Contains(string val)
|
||||
{
|
||||
var keys = typeof(HeaderKeys).GetFields()
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
#region Dubious, should reconsider
|
||||
|
||||
LoadStateResult CheckTimeLines(TextReader reader, bool onlyGuid, bool ignoreGuidMismatch, out string errorMessage); // No need to return a status, no reason to have hacky flags, no need to pass a textreader
|
||||
LoadStateResult CheckTimeLines(TextReader reader, out string errorMessage); // No need to return a status, no reason to have hacky flags, no need to pass a textreader
|
||||
|
||||
void ExtractInputLog(TextReader reader); //Is passing a textreader the only reasonable way to do this?
|
||||
|
||||
|
@ -124,4 +124,4 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
// TODO: delete this and refactor code that uses it!
|
||||
public enum LoadStateResult { Pass, GuidMismatch, TimeLineError, FutureEventError, NotInRecording, EmptyLog, MissingFrameNumber }
|
||||
public enum LoadStateResult { Pass, TimeLineError, FutureEventError, NotInRecording, EmptyLog, MissingFrameNumber }
|
|
@ -393,9 +393,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb
|
||||
.AppendLine("[Input]")
|
||||
.AppendLine(HeaderKeys.GUID + " " + Header[HeaderKeys.GUID]);
|
||||
sb.AppendLine("[Input]");
|
||||
|
||||
foreach (var record in _log)
|
||||
{
|
||||
|
@ -558,7 +556,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public LoadStateResult CheckTimeLines(TextReader reader, bool onlyGuid, bool ignoreGuidMismatch, out string errorMessage)
|
||||
public LoadStateResult CheckTimeLines(TextReader reader, out string errorMessage)
|
||||
{
|
||||
// This function will compare the movie data to the savestate movie data to see if they match
|
||||
errorMessage = String.Empty;
|
||||
|
@ -575,17 +573,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
continue;
|
||||
}
|
||||
else if (line.Contains("GUID"))
|
||||
{
|
||||
var guid = line.Split(new[] { ' ' }, 2)[1];
|
||||
if (Header[HeaderKeys.GUID] != guid)
|
||||
{
|
||||
if (!ignoreGuidMismatch)
|
||||
{
|
||||
return LoadStateResult.GuidMismatch;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (line.Contains("Frame 0x")) // NES stores frame count in hex, yay
|
||||
{
|
||||
var strs = line.Split('x');
|
||||
|
@ -626,11 +613,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
if (onlyGuid)
|
||||
{
|
||||
return LoadStateResult.Pass;
|
||||
}
|
||||
|
||||
if (stateFrame == 0)
|
||||
{
|
||||
stateFrame = log.Length; // In case the frame count failed to parse, revert to using the entire state input log
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace BizHawk.Client.Common
|
|||
this[HeaderKeys.GAMENAME] = String.Empty;
|
||||
this[HeaderKeys.AUTHOR] = String.Empty;
|
||||
this[HeaderKeys.RERECORDS] = "0";
|
||||
this[HeaderKeys.GUID] = HeaderKeys.NewGuid;
|
||||
}
|
||||
|
||||
public new string this[string key]
|
||||
|
|
|
@ -383,7 +383,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else if (line.ToLower().StartsWith("guid"))
|
||||
{
|
||||
m.Header[HeaderKeys.GUID] = ParseHeader(line, "guid");
|
||||
continue; //We no longer care to keep this info
|
||||
}
|
||||
else if (line.ToLower().StartsWith("startsfromsavestate"))
|
||||
{
|
||||
|
@ -1730,7 +1730,7 @@ namespace BizHawk.Client.Common
|
|||
recording time in Unix epoch format
|
||||
*/
|
||||
uint uid = r.ReadUInt32();
|
||||
m.Header[HeaderKeys.GUID] = String.Format("{0:X8}", uid) + "-0000-0000-0000-000000000000";
|
||||
|
||||
// 00C 4-byte little-endian unsigned int: rerecord count
|
||||
m.Header.Rerecords = r.ReadUInt32();
|
||||
// 010 4-byte little-endian unsigned int: number of frames
|
||||
|
@ -1989,7 +1989,7 @@ namespace BizHawk.Client.Common
|
|||
recording time in Unix epoch format
|
||||
*/
|
||||
uint uid = r.ReadUInt32();
|
||||
m.Header[HeaderKeys.GUID] = String.Format("{0:X8}", uid) + "-0000-0000-0000-000000000000";
|
||||
|
||||
// 00C 4-byte little-endian unsigned int: number of frames
|
||||
uint frameCount = r.ReadUInt32();
|
||||
// 010 4-byte little-endian unsigned int: rerecord count
|
||||
|
|
|
@ -33,24 +33,17 @@ namespace BizHawk.Client.Common
|
|||
public MovieRecordList()
|
||||
: base()
|
||||
{
|
||||
Guid = new Guid();
|
||||
}
|
||||
|
||||
public Guid Guid { get; private set; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb
|
||||
.AppendLine("[Input]")
|
||||
|
||||
|
||||
.Append("Frame ")
|
||||
.Append(Global.Emulator.Frame)
|
||||
.AppendLine()
|
||||
|
||||
.Append(HeaderKeys.GUID)
|
||||
.Append(' ')
|
||||
.Append(Guid)
|
||||
.AppendLine();
|
||||
|
||||
foreach (var record in this)
|
||||
|
|
|
@ -210,7 +210,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (ReadOnly)
|
||||
{
|
||||
var result = Movie.CheckTimeLines(reader, onlyGuid: false, ignoreGuidMismatch: false, errorMessage: out ErrorMSG);
|
||||
var result = Movie.CheckTimeLines(reader, out ErrorMSG);
|
||||
if (result == LoadStateResult.Pass)
|
||||
{
|
||||
Movie.Save();
|
||||
|
@ -220,38 +220,13 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
if (result == LoadStateResult.GuidMismatch)
|
||||
{
|
||||
if (HandleGuidError())
|
||||
{
|
||||
var newresult = Movie.CheckTimeLines(reader, onlyGuid: false, ignoreGuidMismatch: true, errorMessage: out ErrorMSG);
|
||||
if (newresult == LoadStateResult.Pass)
|
||||
{
|
||||
Movie.Save();
|
||||
Movie.SwitchToPlay();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = Movie.CheckTimeLines(reader, onlyGuid: true, ignoreGuidMismatch: false, errorMessage: out ErrorMSG);
|
||||
var result = Movie.CheckTimeLines(reader, out ErrorMSG);
|
||||
if (result == LoadStateResult.Pass)
|
||||
{
|
||||
reader.BaseStream.Position = 0;
|
||||
|
@ -260,34 +235,8 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
if (result == LoadStateResult.GuidMismatch)
|
||||
{
|
||||
if (HandleGuidError())
|
||||
{
|
||||
var newresult = Movie.CheckTimeLines(reader, onlyGuid: false, ignoreGuidMismatch: true, errorMessage: out ErrorMSG);
|
||||
if (newresult == LoadStateResult.Pass)
|
||||
{
|
||||
reader.BaseStream.Position = 0;
|
||||
reader.DiscardBufferedData();
|
||||
Movie.ExtractInputLog(reader);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +245,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (ReadOnly)
|
||||
{
|
||||
var result = Movie.CheckTimeLines(reader, onlyGuid: !ReadOnly, ignoreGuidMismatch: false, errorMessage: out ErrorMSG);
|
||||
var result = Movie.CheckTimeLines(reader, out ErrorMSG);
|
||||
if (result == LoadStateResult.Pass)
|
||||
{
|
||||
//Frame loop automatically handles the rewinding effect based on Global.Emulator.Frame so nothing else is needed here
|
||||
|
@ -304,36 +253,12 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
if (result == LoadStateResult.GuidMismatch)
|
||||
{
|
||||
if (HandleGuidError())
|
||||
{
|
||||
var newresult = Movie.CheckTimeLines(reader, onlyGuid: !ReadOnly, ignoreGuidMismatch: true, errorMessage: out ErrorMSG);
|
||||
if (newresult == LoadStateResult.Pass)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
Output(ErrorMSG);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = Movie.CheckTimeLines(reader, onlyGuid: !ReadOnly, ignoreGuidMismatch: false, errorMessage: out ErrorMSG);
|
||||
var result = Movie.CheckTimeLines(reader, out ErrorMSG);
|
||||
if (result == LoadStateResult.Pass)
|
||||
{
|
||||
Movie.SwitchToRecord();
|
||||
|
@ -344,35 +269,8 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
if (result == LoadStateResult.GuidMismatch)
|
||||
{
|
||||
if (HandleGuidError())
|
||||
{
|
||||
var newresult = Movie.CheckTimeLines(reader, onlyGuid: !ReadOnly, ignoreGuidMismatch: true, errorMessage: out ErrorMSG);
|
||||
if (newresult == LoadStateResult.Pass)
|
||||
{
|
||||
Movie.SwitchToRecord();
|
||||
reader.BaseStream.Position = 0;
|
||||
reader.DiscardBufferedData();
|
||||
Movie.ExtractInputLog(reader);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -380,35 +278,11 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (ReadOnly)
|
||||
{
|
||||
var result = Movie.CheckTimeLines(reader, onlyGuid: false, ignoreGuidMismatch: false, errorMessage: out ErrorMSG);
|
||||
var result = Movie.CheckTimeLines(reader, errorMessage: out ErrorMSG);
|
||||
if (result != LoadStateResult.Pass)
|
||||
{
|
||||
if (result == LoadStateResult.GuidMismatch)
|
||||
{
|
||||
if (HandleGuidError())
|
||||
{
|
||||
var newresult = Movie.CheckTimeLines(reader, onlyGuid: true, ignoreGuidMismatch: true, errorMessage: out ErrorMSG);
|
||||
if (newresult == LoadStateResult.Pass)
|
||||
{
|
||||
Movie.SwitchToPlay();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
else if (Movie.IsFinished) //TimeLine check can change a movie to finished, hence the check here (not a good design)
|
||||
{
|
||||
|
@ -421,7 +295,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
var result = Movie.CheckTimeLines(reader, onlyGuid: !ReadOnly, ignoreGuidMismatch: false, errorMessage: out ErrorMSG);
|
||||
var result = Movie.CheckTimeLines(reader, out ErrorMSG);
|
||||
if (result == LoadStateResult.Pass)
|
||||
{
|
||||
Global.Emulator.ClearSaveRam();
|
||||
|
@ -433,36 +307,8 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
if (result == LoadStateResult.GuidMismatch)
|
||||
{
|
||||
if (HandleGuidError())
|
||||
{
|
||||
var newresult = Movie.CheckTimeLines(reader, onlyGuid: !ReadOnly, ignoreGuidMismatch: true, errorMessage: out ErrorMSG);
|
||||
if (newresult == LoadStateResult.Pass)
|
||||
{
|
||||
Global.Emulator.ClearSaveRam();
|
||||
Movie.StartNewRecording();
|
||||
reader.BaseStream.Position = 0;
|
||||
reader.DiscardBufferedData();
|
||||
Movie.ExtractInputLog(reader);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
Output(ErrorMSG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ namespace BizHawk.Client.Common
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public LoadStateResult CheckTimeLines(System.IO.TextReader reader, bool onlyGuid, bool ignoreGuidMismatch, out string errorMessage)
|
||||
public LoadStateResult CheckTimeLines(System.IO.TextReader reader, out string errorMessage)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -97,7 +97,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
_movieToRecord.Header[HeaderKeys.AUTHOR] = AuthorBox.Text;
|
||||
_movieToRecord.Header[HeaderKeys.EMULATIONVERSION] = VersionInfo.GetEmuVersion();
|
||||
_movieToRecord.Header[HeaderKeys.MOVIEVERSION] = HeaderKeys.MovieVersion;
|
||||
_movieToRecord.Header[HeaderKeys.GUID] = HeaderKeys.NewGuid;
|
||||
_movieToRecord.Header[HeaderKeys.PLATFORM] = Global.Game.System;
|
||||
if (Global.Game != null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue