private void LoadTasprojExtras(ZipStateLoader bl) { bl.GetLump(BinaryStateLump.LagLog, false, delegate(TextReader tr) { LagLog.Load(tr); }); bl.GetLump(BinaryStateLump.Markers, false, delegate(TextReader tr) { string line; while ((line = tr.ReadLine()) != null) { if (!string.IsNullOrWhiteSpace(line)) { Markers.Add(new TasMovieMarker(line)); } } }); if (GetClientSettingsOnLoad != null) { string clientSettings = ""; bl.GetLump(BinaryStateLump.ClientSettings, false, delegate(TextReader tr) { string line; while ((line = tr.ReadLine()) != null) { if (!string.IsNullOrWhiteSpace(line)) { clientSettings = line; } } }); if (!string.IsNullOrWhiteSpace(clientSettings)) { GetClientSettingsOnLoad(clientSettings); } } bl.GetLump(BinaryStateLump.VerificationLog, false, delegate(TextReader tr) { VerificationLog.Clear(); while (true) { var line = tr.ReadLine(); if (string.IsNullOrEmpty(line)) { break; } if (line.StartsWith("|")) { VerificationLog.Add(line); } } }); Branches.Load(bl, this); bl.GetLump(BinaryStateLump.Session, false, delegate(TextReader tr) { var json = tr.ReadToEnd(); try { TasSession = JsonConvert.DeserializeObject <TasSession>(json); } catch { // Do nothing, and use default settings instead } }); ZwinderStateManagerSettings settings = new ZwinderStateManagerSettings(); bl.GetLump(BinaryStateLump.StateHistorySettings, false, delegate(TextReader tr) { var json = tr.ReadToEnd(); try { settings = JsonConvert.DeserializeObject <ZwinderStateManagerSettings>(json); } catch { // Do nothing, and use default settings instead } }); bl.GetLump(BinaryStateLump.StateHistory, false, delegate(BinaryReader br, long length) { TasStateManager?.Dispose(); TasStateManager = ZwinderStateManager.Create(br, settings, IsReserved); }); }
private void LoadTasprojExtras(ZipStateLoader bl) { bl.GetLump(BinaryStateLump.LagLog, false, delegate(TextReader tr) { LagLog.Load(tr); }); bl.GetLump(BinaryStateLump.Markers, false, delegate(TextReader tr) { string line; while ((line = tr.ReadLine()) != null) { if (!string.IsNullOrWhiteSpace(line)) { Markers.Add(new TasMovieMarker(line)); } } }); if (GetClientSettingsOnLoad != null) { string clientSettings = ""; bl.GetLump(BinaryStateLump.ClientSettings, false, delegate(TextReader tr) { string line; while ((line = tr.ReadLine()) != null) { if (!string.IsNullOrWhiteSpace(line)) { clientSettings = line; } } }); if (!string.IsNullOrWhiteSpace(clientSettings)) { GetClientSettingsOnLoad(clientSettings); } } bl.GetLump(BinaryStateLump.VerificationLog, false, delegate(TextReader tr) { VerificationLog.Clear(); while (true) { var line = tr.ReadLine(); if (string.IsNullOrEmpty(line)) { break; } if (line.StartsWith("|")) { VerificationLog.Add(line); } } }); Branches.Load(bl, this); bl.GetLump(BinaryStateLump.Session, false, delegate(TextReader tr) { var json = tr.ReadToEnd(); try { TasSession = JsonConvert.DeserializeObject <TasSession>(json); } catch { // Do nothing, and use default settings instead } }); ZwinderStateManagerSettings settings = new ZwinderStateManagerSettings(); bl.GetLump(BinaryStateLump.StateHistorySettings, false, delegate(TextReader tr) { var json = tr.ReadToEnd(); try { settings = JsonConvert.DeserializeObject <ZwinderStateManagerSettings>(json); } catch { // Do nothing, and use default settings instead } }); bl.GetLump(BinaryStateLump.StateHistory, false, delegate(BinaryReader br, long length) { try { TasStateManager?.Dispose(); TasStateManager = ZwinderStateManager.Create(br, settings, IsReserved); } catch { // Continue with a fresh manager. If state history got corrupted, the file is still very much useable // and we would want the user to be able to load, and regenerate their state history // however, we still have an issue of how state history got corrupted TasStateManager = new ZwinderStateManager( Session.Settings.DefaultTasStateManagerSettings, IsReserved); Session.PopupMessage("State history was corrupted, clearing and working with a fresh history."); } }); }