Movie Loadstate - GUID checking in read-only mode + fix a crash bug

This commit is contained in:
andres.delikat 2011-07-31 17:35:02 +00:00
parent 3481943b74
commit 64e38e83c8
3 changed files with 21 additions and 9 deletions

View File

@ -121,7 +121,7 @@ namespace BizHawk.MultiClient
if (ReadOnly) if (ReadOnly)
{ {
if (!UserMovie.CheckTimeLines(reader)) if (!UserMovie.CheckTimeLines(reader, false))
return false; //Timeline/GUID error return false; //Timeline/GUID error
else else
{ {
@ -132,7 +132,8 @@ namespace BizHawk.MultiClient
} }
else else
{ {
//TODO: GUID check if (!UserMovie.CheckTimeLines(reader, true))
return false; //GUID Error
UserMovie.LoadLogFromSavestateText(reader); UserMovie.LoadLogFromSavestateText(reader);
} }
} }
@ -140,14 +141,14 @@ namespace BizHawk.MultiClient
{ {
if (ReadOnly) if (ReadOnly)
{ {
if (!UserMovie.CheckTimeLines(reader)) if (!UserMovie.CheckTimeLines(reader, false))
return false; //Timeline/GUID error return false; //Timeline/GUID error
//Frame loop automatically handles the rewinding effect based on Global.Emulator.Frame so nothing else is needed here //Frame loop automatically handles the rewinding effect based on Global.Emulator.Frame so nothing else is needed here
} }
else else
{ {
//TODO: GUID check if (!UserMovie.CheckTimeLines(reader, true))
//QUESTIONABLE - control whether the movie gets truncated here? return false; //GUID Error
UserMovie.StartNewRecording(!Global.MovieSession.MultiTrack.IsActive); UserMovie.StartNewRecording(!Global.MovieSession.MultiTrack.IsActive);
SetMainformMovieInfo(); SetMainformMovieInfo();
UserMovie.LoadLogFromSavestateText(reader); UserMovie.LoadLogFromSavestateText(reader);
@ -165,7 +166,7 @@ namespace BizHawk.MultiClient
} }
else else
{ {
if (!UserMovie.CheckTimeLines(reader)) if (!UserMovie.CheckTimeLines(reader, false))
return false; //Timeline/GUID error return false; //Timeline/GUID error
UserMovie.StartPlayback(); UserMovie.StartPlayback();
SetMainformMovieInfo(); SetMainformMovieInfo();
@ -181,7 +182,8 @@ namespace BizHawk.MultiClient
} }
else else
{ {
//TODO: GUID check if (!UserMovie.CheckTimeLines(reader, true))
return false; //GUID Error
UserMovie.StartNewRecording(); UserMovie.StartNewRecording();
SetMainformMovieInfo(); SetMainformMovieInfo();
UserMovie.LoadLogFromSavestateText(reader); UserMovie.LoadLogFromSavestateText(reader);

View File

@ -1597,14 +1597,17 @@ namespace BizHawk.MultiClient
private void LoadStateFile(string path, string name) private void LoadStateFile(string path, string name)
{ {
var reader = new StreamReader(path); var reader = new StreamReader(path);
if (HandleMovieLoadState(reader)) if (HandleMovieLoadState(reader))
{ {
reader.BaseStream.Position = 0; //Reset position after movie code has had its way with it
Global.Emulator.LoadStateText(reader); Global.Emulator.LoadStateText(reader);
UpdateTools(); UpdateTools();
reader.Close(); reader.Close();
Global.RenderPanel.AddMessage("Loaded state: " + name); Global.RenderPanel.AddMessage("Loaded state: " + name);
} }
else
Global.RenderPanel.AddMessage("Loadstate error!");
} }
private void LoadState(string name) private void LoadState(string name)

View File

@ -478,7 +478,7 @@ namespace BizHawk.MultiClient
} }
} }
public bool CheckTimeLines(StreamReader reader) public bool CheckTimeLines(StreamReader reader, bool OnlyGUID)
{ {
//This function will compare the movie data to the savestate movie data to see if they match //This function will compare the movie data to the savestate movie data to see if they match
@ -503,6 +503,11 @@ namespace BizHawk.MultiClient
if (result == DialogResult.No) if (result == DialogResult.No)
return false; return false;
} }
else if (OnlyGUID)
{
reader.BaseStream.Position = 0;
return true;
}
} }
else if (line == "[Input]") continue; else if (line == "[Input]") continue;
else if (line == "[/Input]") break; else if (line == "[/Input]") break;
@ -513,6 +518,8 @@ namespace BizHawk.MultiClient
reader.BaseStream.Position = 0; //Reset position because this stream may be read again by other code reader.BaseStream.Position = 0; //Reset position because this stream may be read again by other code
if (OnlyGUID) return true;
if (Log.Length() < l.Length()) if (Log.Length() < l.Length())
{ {
//Future event error //Future event error