From 1bedd816660440025a5bc7b4fcfcae958f133d08 Mon Sep 17 00:00:00 2001 From: brandman211 Date: Wed, 25 Jul 2012 08:01:02 +0000 Subject: [PATCH] That optimization for movie length calculation in the PlayMovie dialog now accounts for files with new line characters of all sizes. --- BizHawk.MultiClient/movie/Movie.cs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/BizHawk.MultiClient/movie/Movie.cs b/BizHawk.MultiClient/movie/Movie.cs index 6cd6e16219..e6e90f42cc 100644 --- a/BizHawk.MultiClient/movie/Movie.cs +++ b/BizHawk.MultiClient/movie/Movie.cs @@ -381,27 +381,22 @@ namespace BizHawk.MultiClient using (StreamReader sr = file.OpenText()) { string str = ""; - int length = 0; while ((str = sr.ReadLine()) != null) { - length += str.Length + 1; - if (str == "") - { + if (str == "" || Header.AddHeaderFromLine(str)) continue; - } - else if (Header.AddHeaderFromLine(str)) - continue; - if (str.StartsWith("subtitle") || str.StartsWith("sub")) - { Subtitles.AddSubtitle(str); - } else if (str[0] == '|') { - int line = str.Length + 1; - length -= line; - int lines = (int)file.Length - length; - this.Frames = lines / line; + string frames = sr.ReadToEnd(); + int length = str.Length; + // Account for line breaks of either size. + if (frames.IndexOf("\r\n") != -1) + length++; + length++; + // Count the remaining frames and the current one. + this.Frames = (frames.Length / length) + 1; break; } else