tastudio: last preparation before new tasproject entry.

old branch states won't load anymore, as they were part of common greenzone and were cut off. current states should still be compatible.
This commit is contained in:
feos 2015-10-24 17:17:33 +03:00
parent fd2e6848f1
commit 855561ac19
2 changed files with 33 additions and 34 deletions

View File

@ -82,8 +82,8 @@ namespace BizHawk.Client.Common
{
bs.PutLump(BinaryStateLump.MovieSaveRam, (BinaryWriter bw) => bw.Write(SaveRam));
}
ReportProgress(PROGRESS_STEP);
if (ClientSettingsForSave != null)
{
var clientSettingsJson = ClientSettingsForSave();
@ -99,9 +99,11 @@ namespace BizHawk.Client.Common
if (Branches.Any())
{
Branches.Save(bs);
bs.PutLump(BinaryStateLump.BranchStateHistory, (BinaryWriter bw) => StateManager.SaveBranchStates(bw));
if (StateManager.Settings.BranchStatesInTasproj)
{
bs.PutLump(BinaryStateLump.BranchStateHistory, (BinaryWriter bw) => StateManager.SaveBranchStates(bw));
}
}
ReportProgress(PROGRESS_STEP);
}
@ -289,10 +291,13 @@ namespace BizHawk.Client.Common
}
Branches.Load(bl, this);
bl.GetLump(BinaryStateLump.BranchStateHistory, false, delegate(BinaryReader br, long length)
if (StateManager.Settings.BranchStatesInTasproj)
{
StateManager.LoadBranchStates(br);
});
bl.GetLump(BinaryStateLump.BranchStateHistory, false, delegate(BinaryReader br, long length)
{
StateManager.LoadBranchStates(br);
});
}
}
Changes = false;

View File

@ -586,48 +586,42 @@ namespace BizHawk.Client.Common
public void SaveBranchStates(BinaryWriter bw)
{
if (Settings.BranchStatesInTasproj)
bw.Write(BranchStates.Count);
foreach (var s in BranchStates)
{
bw.Write(BranchStates.Count);
foreach (var s in BranchStates)
bw.Write(s.Key);
bw.Write(s.Value.Count);
foreach (var t in s.Value)
{
bw.Write(s.Key);
bw.Write(s.Value.Count);
foreach (var t in s.Value)
{
bw.Write(t.Key);
t.Value.Write(bw);
}
bw.Write(t.Key);
t.Value.Write(bw);
}
}
}
public void LoadBranchStates(BinaryReader br)
{
if (Settings.BranchStatesInTasproj)
try
{
try
int c = br.ReadInt32();
BranchStates = new SortedList<int, SortedList<int, StateManagerState>>(c);
while (c > 0)
{
int c = br.ReadInt32();
BranchStates = new SortedList<int, SortedList<int, StateManagerState>>(c);
while (c > 0)
int key = br.ReadInt32();
int c2 = br.ReadInt32();
var list = new SortedList<int, StateManagerState>(c2);
while (c2 > 0)
{
int key = br.ReadInt32();
int c2 = br.ReadInt32();
var list = new SortedList<int, StateManagerState>(c2);
while (c2 > 0)
{
int key2 = br.ReadInt32();
var state = StateManagerState.Read(br, this);
list.Add(key2, state);
c2--;
}
BranchStates.Add(key, list);
c--;
int key2 = br.ReadInt32();
var state = StateManagerState.Read(br, this);
list.Add(key2, state);
c2--;
}
BranchStates.Add(key, list);
c--;
}
catch (EndOfStreamException) { }
}
catch (EndOfStreamException) { }
}