diff --git a/Source/Core/SRB2/LuaObjectParser.cs b/Source/Core/SRB2/LuaObjectParser.cs index 34fc4c1..3cb140e 100644 --- a/Source/Core/SRB2/LuaObjectParser.cs +++ b/Source/Core/SRB2/LuaObjectParser.cs @@ -135,7 +135,7 @@ namespace CodeImp.DoomBuilder.SRB2 break; } LogWarning("The sprite \"" + token + "\" assigned by the \"$sprite\" property does not exist"); - return false; + break; case "$Category": SkipWhitespace(true); token = ReadLine(); @@ -144,27 +144,18 @@ namespace CodeImp.DoomBuilder.SRB2 case "doomednum": if (!ReadParameter(out token, out finished)) return false; if (!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out mapThingNum)) - { - ReportError("Invalid map thing number"); - return false; - } + LogWarning("Could not parse map thing number"); break; case "radius": if (!ReadParameter(out token, out finished)) return false; if (!ParseWithArithmetic(token, out radius)) - { - ReportError("Invalid radius"); - return false; - } + LogWarning("Could not parse radius"); radius /= 65536; break; case "height": if (!ReadParameter(out token, out finished)) return false; if (!ParseWithArithmetic(token, out height)) - { - ReportError("Invalid height"); - return false; - } + LogWarning("Could not parse height"); height /= 65536; break; case "spawnstate": @@ -610,6 +601,20 @@ namespace CodeImp.DoomBuilder.SRB2 } private bool ParseWithArithmetic(string input, out int output) + { + output = 0; + string[] tokens = input.Split(new char[] { '+' }); + foreach (string t in tokens) + { + int val = 0; + if (!ParseMultiplication(t, out val)) + return false; + output += val; + } + return true; + } + + private bool ParseMultiplication(string input, out int output) { output = 1; string[] tokens = input.Split(new char[] { '*' }); @@ -619,10 +624,7 @@ namespace CodeImp.DoomBuilder.SRB2 int val = 1; if (trimmed == "FRACUNIT") val = 65536; else if (!int.TryParse(trimmed, NumberStyles.Integer, CultureInfo.InvariantCulture, out val)) - { - ReportError("Invalid radius"); return false; - } output *= val; } return true; diff --git a/Source/Core/SRB2/SOCObjectParser.cs b/Source/Core/SRB2/SOCObjectParser.cs index d6e2bfb..29a0ba9 100644 --- a/Source/Core/SRB2/SOCObjectParser.cs +++ b/Source/Core/SRB2/SOCObjectParser.cs @@ -161,6 +161,7 @@ namespace CodeImp.DoomBuilder.SRB2 continue; } LogWarning("The sprite \"" + spritename + "\" assigned by the \"$sprite\" property does not exist"); + continue; } if (line.StartsWith("#$Name ")) { @@ -186,25 +187,16 @@ namespace CodeImp.DoomBuilder.SRB2 { case "MAPTHINGNUM": if (!int.TryParse(tokens[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out mapThingNum)) - { - ReportError("Invalid map thing number"); - return false; - } + LogWarning("Could not parse map thing number"); break; case "RADIUS": if (!ParseWithArithmetic(tokens[1], out radius)) - { - ReportError("Invalid radius"); - return false; - } + LogWarning("Could not parse radius"); radius /= 65536; break; case "HEIGHT": if (!ParseWithArithmetic(tokens[1], out height)) - { - ReportError("Invalid height"); - return false; - } + LogWarning("Could not parse height"); height /= 65536; break; @@ -293,6 +285,20 @@ namespace CodeImp.DoomBuilder.SRB2 #region ================== Methods private bool ParseWithArithmetic(string input, out int output) + { + output = 0; + string[] tokens = input.Split(new char[] { '+' }); + foreach (string t in tokens) + { + int val = 0; + if (!ParseMultiplication(t, out val)) + return false; + output += val; + } + return true; + } + + private bool ParseMultiplication(string input, out int output) { output = 1; string[] tokens = input.Split(new char[] { '*' }); @@ -302,10 +308,7 @@ namespace CodeImp.DoomBuilder.SRB2 int val = 1; if (trimmed == "FRACUNIT") val = 65536; else if (!int.TryParse(trimmed, NumberStyles.Integer, CultureInfo.InvariantCulture, out val)) - { - ReportError("Invalid radius"); return false; - } output *= val; } return true;