From 21ae27dd9486653982f911715d1dd01a146eb861 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 8 Dec 2014 19:02:22 +0000 Subject: [PATCH] Bk2/TasProj movies - don't crash if syncsettings, comments, or subtitles are missing --- .../movie/bk2/Bk2Movie.IO.cs | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs index 1739ed838d..632ad4c498 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs @@ -66,41 +66,50 @@ namespace BizHawk.Client.Common } }); - bl.GetLump(BinaryStateLump.Comments, true, delegate(TextReader tr) + if (bl.HasLump(BinaryStateLump.Comments)) { - string line; - while ((line = tr.ReadLine()) != null) + bl.GetLump(BinaryStateLump.Comments, true, delegate(TextReader tr) { - if (!string.IsNullOrWhiteSpace(line)) + string line; + while ((line = tr.ReadLine()) != null) { - Comments.Add(line); + if (!string.IsNullOrWhiteSpace(line)) + { + Comments.Add(line); + } } - } - }); + }); + } - bl.GetLump(BinaryStateLump.Subtitles, true, delegate(TextReader tr) + if (bl.HasLump(BinaryStateLump.Subtitles)) { - string line; - while ((line = tr.ReadLine()) != null) + bl.GetLump(BinaryStateLump.Subtitles, true, delegate(TextReader tr) { - if (!string.IsNullOrWhiteSpace(line)) + string line; + while ((line = tr.ReadLine()) != null) { - Subtitles.AddFromString(line); + if (!string.IsNullOrWhiteSpace(line)) + { + Subtitles.AddFromString(line); + } } - } - }); + }); + } - bl.GetLump(BinaryStateLump.SyncSettings, true, delegate(TextReader tr) + if (bl.HasLump(BinaryStateLump.SyncSettings)) { - string line; - while ((line = tr.ReadLine()) != null) + bl.GetLump(BinaryStateLump.SyncSettings, true, delegate(TextReader tr) { - if (!string.IsNullOrWhiteSpace(line)) + string line; + while ((line = tr.ReadLine()) != null) { - _syncSettingsJson = line; + if (!string.IsNullOrWhiteSpace(line)) + { + _syncSettingsJson = line; + } } - } - }); + }); + } bl.GetLump(BinaryStateLump.Input, true, delegate(TextReader tr) {