Fixed Issue 69 by properly chucking the invalid lines out of watch files instead of trying to get out of range substrings and parsing non-numbers as integers. Also, as the newly stored SystemID has yet to be accounted for in any way, I made the parser skip those lines. Not sure if there's something Ram Watch should do with this data as it seems like the SystemID is more accurately defined by the core currently running.

This commit is contained in:
brandman211 2012-06-07 18:41:39 +00:00
parent cb4c45eb70
commit 5a678f96d8
1 changed files with 23 additions and 5 deletions

View File

@ -66,9 +66,12 @@ namespace BizHawk.MultiClient
//Any properly formatted line couldn't possibly be this short anyway, this also takes care of any garbage lines that might be in a file
if (s.Length < 5) continue;
if (s.Substring(0, 6) == "Domain")
if (s.Length >= 6 && s.Substring(0, 6) == "Domain")
domain = s.Substring(7, s.Length - 7);
if (s.Length >= 8 && s.Substring(0, 8) == "SystemID")
continue;
z = HowMany(s, '\t');
if (z == 5)
{
@ -82,19 +85,34 @@ namespace BizHawk.MultiClient
Watch w = new Watch();
temp = s.Substring(0, s.IndexOf('\t'));
w.address = int.Parse(temp, NumberStyles.HexNumber);
try
{
w.address = int.Parse(temp, NumberStyles.HexNumber);
}
catch
{
continue;
}
y = s.IndexOf('\t') + 1;
s = s.Substring(y, s.Length - y); //Type
w.SetTypeByChar(s[0]);
if (!w.SetTypeByChar(s[0]))
continue;
y = s.IndexOf('\t') + 1;
s = s.Substring(y, s.Length - y); //Signed
w.SetSignedByChar(s[0]);
if (!w.SetSignedByChar(s[0]))
continue;
y = s.IndexOf('\t') + 1;
s = s.Substring(y, s.Length - y); //Endian
y = Int16.Parse(s[0].ToString());
try {
y = Int16.Parse(s[0].ToString());
}
catch
{
continue;
}
if (y == 0)
w.bigendian = false;
else