don't load entire inputlog into a string when parking it in a savestate
This commit is contained in:
parent
e1ddb51826
commit
a355f78631
|
@ -219,7 +219,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
if (Movie.IsActive)
|
if (Movie.IsActive)
|
||||||
{
|
{
|
||||||
writer.Write(Movie.GetInputLog());
|
Movie.WriteInputLog(writer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ namespace BizHawk.Client.Common
|
||||||
bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));
|
bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));
|
||||||
bs.PutLump(BinaryStateLump.SyncSettings, tw => tw.WriteLine(_syncSettingsJson));
|
bs.PutLump(BinaryStateLump.SyncSettings, tw => tw.WriteLine(_syncSettingsJson));
|
||||||
|
|
||||||
bs.PutLump(BinaryStateLump.Input, tw => tw.WriteLine(RawInputLog()));
|
bs.PutLump(BinaryStateLump.Input, tw => WriteInputLog(tw));
|
||||||
|
|
||||||
if (StartsFromSavestate)
|
if (StartsFromSavestate)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,14 +14,19 @@ namespace BizHawk.Client.Common
|
||||||
public string GetInputLog()
|
public string GetInputLog()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
var writer = new StringWriter(sb);
|
||||||
sb.AppendLine("[Input]");
|
WriteInputLog(writer);
|
||||||
sb.Append(RawInputLog());
|
writer.Flush();
|
||||||
sb.AppendLine("[/Input]");
|
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void WriteInputLog(TextWriter writer)
|
||||||
|
{
|
||||||
|
writer.WriteLine("[Input]");
|
||||||
|
WriteRawInputLog(writer);
|
||||||
|
writer.WriteLine("[/Input]");
|
||||||
|
}
|
||||||
|
|
||||||
public string GetInputLogEntry(int frame)
|
public string GetInputLogEntry(int frame)
|
||||||
{
|
{
|
||||||
if (frame < FrameCount && frame >= 0)
|
if (frame < FrameCount && frame >= 0)
|
||||||
|
@ -294,20 +299,17 @@ namespace BizHawk.Client.Common
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StringBuilder RawInputLog()
|
protected void WriteRawInputLog(TextWriter writer)
|
||||||
{
|
{
|
||||||
var lg = new Bk2LogEntryGenerator(LogKey);
|
var lg = new Bk2LogEntryGenerator(LogKey);
|
||||||
lg.SetSource(Global.MovieOutputHardpoint);
|
lg.SetSource(Global.MovieOutputHardpoint);
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
writer.WriteLine(lg.GenerateLogKey());
|
||||||
sb.AppendLine(lg.GenerateLogKey());
|
|
||||||
sb.EnsureCapacity(sb.Capacity + _log.Count);
|
|
||||||
foreach (var record in _log)
|
foreach (var record in _log)
|
||||||
{
|
{
|
||||||
sb.AppendLine(record);
|
writer.WriteLine(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -13,17 +13,22 @@ namespace BizHawk.Client.Common
|
||||||
public string GetInputLog()
|
public string GetInputLog()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
var writer = new StringWriter(sb);
|
||||||
|
WriteInputLog(writer);
|
||||||
|
writer.Flush();
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
sb.AppendLine("[Input]");
|
public void WriteInputLog(TextWriter writer)
|
||||||
|
{
|
||||||
|
writer.WriteLine("[Input]");
|
||||||
|
|
||||||
foreach (var record in _log)
|
foreach (var record in _log)
|
||||||
{
|
{
|
||||||
sb.AppendLine(record);
|
writer.WriteLine(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.AppendLine("[/Input]");
|
writer.WriteLine("[/Input]");
|
||||||
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetInputLogEntry(int frame)
|
public string GetInputLogEntry(int frame)
|
||||||
|
|
|
@ -114,6 +114,11 @@ namespace BizHawk.Client.Common
|
||||||
/// <returns>returns a string represntation of the input log in its current state</returns>
|
/// <returns>returns a string represntation of the input log in its current state</returns>
|
||||||
string GetInputLog();
|
string GetInputLog();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the input log directly to the stream, bypassing the need to load it all into ram as a string
|
||||||
|
/// </summary>
|
||||||
|
void WriteInputLog(TextWriter writer);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets one frame from the input log.
|
/// Gets one frame from the input log.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace BizHawk.Client.Common
|
||||||
bs.PutLump(BinaryStateLump.Comments, tw => tw.WriteLine(CommentsString()));
|
bs.PutLump(BinaryStateLump.Comments, tw => tw.WriteLine(CommentsString()));
|
||||||
bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));
|
bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));
|
||||||
bs.PutLump(BinaryStateLump.SyncSettings, tw => tw.WriteLine(SyncSettingsJson));
|
bs.PutLump(BinaryStateLump.SyncSettings, tw => tw.WriteLine(SyncSettingsJson));
|
||||||
bs.PutLump(BinaryStateLump.Input, tw => tw.WriteLine(RawInputLog()));
|
bs.PutLump(BinaryStateLump.Input, tw => WriteInputLog(tw));
|
||||||
|
|
||||||
// TasProj extras
|
// TasProj extras
|
||||||
bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(StateManager.Settings.ToString()));
|
bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(StateManager.Settings.ToString()));
|
||||||
|
|
Loading…
Reference in New Issue