bk2 and tasproj movies - respect the preload flag, only loads header and inputlog. This speeds up the play movie dialog by 50-100%, a lot more if there is a large sizeable .tasproj files in the folder

This commit is contained in:
adelikat 2020-07-11 17:06:40 -05:00
parent a19791a212
commit 9d054d19f6
2 changed files with 24 additions and 19 deletions

View File

@ -148,10 +148,10 @@ namespace BizHawk.Client.Common
protected virtual void LoadFields(ZipStateLoader bl, bool preload)
{
LoadBk2Fields(bl);
LoadBk2Fields(bl, preload);
}
protected void LoadBk2Fields(ZipStateLoader bl)
protected void LoadBk2Fields(ZipStateLoader bl, bool preload)
{
bl.GetLump(BinaryStateLump.Movieheader, true, delegate(TextReader tr)
{
@ -173,6 +173,18 @@ namespace BizHawk.Client.Common
}
});
bl.GetLump(BinaryStateLump.Input, true, delegate(TextReader tr)
{
IsCountingRerecords = false;
ExtractInputLog(tr, out _);
IsCountingRerecords = true;
});
if (preload)
{
return;
}
bl.GetLump(BinaryStateLump.Comments, false, delegate(TextReader tr)
{
string line;
@ -211,13 +223,6 @@ namespace BizHawk.Client.Common
}
});
bl.GetLump(BinaryStateLump.Input, true, delegate(TextReader tr)
{
IsCountingRerecords = false;
ExtractInputLog(tr, out _);
IsCountingRerecords = true;
});
if (StartsFromSavestate)
{
bl.GetCoreState(

View File

@ -63,11 +63,14 @@ namespace BizHawk.Client.Common
protected override void LoadFields(ZipStateLoader bl, bool preload)
{
LoadBk2Fields(bl);
LoadTasprojExtras(bl, preload);
LoadBk2Fields(bl, preload);
if (!preload)
{
LoadTasprojExtras(bl);
}
}
private void LoadTasprojExtras(ZipStateLoader bl, bool preload)
private void LoadTasprojExtras(ZipStateLoader bl)
{
bl.GetLump(BinaryStateLump.LagLog, false, delegate(TextReader tr)
{
@ -153,15 +156,12 @@ namespace BizHawk.Client.Common
}
});
if (!preload)
if (TasStateManager.Settings.SaveStateHistory)
{
if (TasStateManager.Settings.SaveStateHistory)
bl.GetLump(BinaryStateLump.StateHistory, false, delegate(BinaryReader br, long length)
{
bl.GetLump(BinaryStateLump.StateHistory, false, delegate(BinaryReader br, long length)
{
TasStateManager.Load(br);
});
}
TasStateManager.Load(br);
});
}
}
}