That optimization for movie length calculation in the PlayMovie dialog now accounts for files with new line characters of all sizes.

This commit is contained in:
brandman211 2012-07-25 08:01:02 +00:00
parent bb05876f84
commit 1bedd81666
1 changed files with 9 additions and 14 deletions

View File

@ -381,27 +381,22 @@ namespace BizHawk.MultiClient
using (StreamReader sr = file.OpenText()) using (StreamReader sr = file.OpenText())
{ {
string str = ""; string str = "";
int length = 0;
while ((str = sr.ReadLine()) != null) while ((str = sr.ReadLine()) != null)
{ {
length += str.Length + 1; if (str == "" || Header.AddHeaderFromLine(str))
if (str == "")
{
continue; continue;
}
else if (Header.AddHeaderFromLine(str))
continue;
if (str.StartsWith("subtitle") || str.StartsWith("sub")) if (str.StartsWith("subtitle") || str.StartsWith("sub"))
{
Subtitles.AddSubtitle(str); Subtitles.AddSubtitle(str);
}
else if (str[0] == '|') else if (str[0] == '|')
{ {
int line = str.Length + 1; string frames = sr.ReadToEnd();
length -= line; int length = str.Length;
int lines = (int)file.Length - length; // Account for line breaks of either size.
this.Frames = lines / line; if (frames.IndexOf("\r\n") != -1)
length++;
length++;
// Count the remaining frames and the current one.
this.Frames = (frames.Length / length) + 1;
break; break;
} }
else else