From 855561ac193700956e288c9180e9e20e10525cc0 Mon Sep 17 00:00:00 2001 From: feos Date: Sat, 24 Oct 2015 17:17:33 +0300 Subject: [PATCH] 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. --- .../movie/tasproj/TasMovie.IO.cs | 17 ++++--- .../movie/tasproj/TasStateManager.cs | 50 ++++++++----------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs index c0d7e7eb60..411c6c3325 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs @@ -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; diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs index a8798ced03..7e9118efe0 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs @@ -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>(c); + while (c > 0) { - int c = br.ReadInt32(); - BranchStates = new SortedList>(c); - while (c > 0) + int key = br.ReadInt32(); + int c2 = br.ReadInt32(); + var list = new SortedList(c2); + while (c2 > 0) { - int key = br.ReadInt32(); - int c2 = br.ReadInt32(); - var list = new SortedList(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) { } }