Handle the null control code case

This commit is contained in:
jeffman 2015-03-25 15:07:04 -04:00
parent 800ae858a5
commit 43431f3d1a
1 changed files with 88 additions and 63 deletions

View File

@ -341,7 +341,32 @@ namespace ScriptTool
i = str.IndexOf(']', i + 1) + 1; i = str.IndexOf(']', i + 1) + 1;
if (code == null)
{
// Not matched to anything -- check if it's a valid character sequence
foreach (var codeString in codeStrings)
{
if (!IsHexByte(codeString))
{
sb.Append("[INVALID]");
}
else
{
byte b = Convert.ToByte(codeString, 16);
if (!charLookup.ContainsKey(b))
{
sb.Append("[INVALID]");
}
else
{
sb.Append(charLookup[b]);
currentWidth += virtualWidths[b - 0x50];
}
}
}
}
else
{
switch (code.Identifier) switch (code.Identifier)
{ {
case 0xC: case 0xC:
@ -406,7 +431,7 @@ namespace ScriptTool
currentWidth += 10; currentWidth += 10;
break; break;
} }
}
} }
else if (str[i] == ']') else if (str[i] == ']')
{ {