Configuration file parser: floating point numbers without the "f" suffix are now parsed as double precision floating point numbers

This commit is contained in:
biwa 2020-10-24 23:27:04 +02:00
parent 0fc2296ce9
commit 8330c70a41

View file

@ -706,7 +706,7 @@ namespace CodeImp.DoomBuilder.IO
// is also the end of the assignment
pos--;
// Floating point?
// Floating point of single precision?
if(val.IndexOf("f", StringComparison.Ordinal) > -1)
{
float fval;
@ -721,6 +721,19 @@ namespace CodeImp.DoomBuilder.IO
}
return fval;
}
else if(val.IndexOf(".", StringComparison.Ordinal) > -1) // Floating point of double precision?
{
double dval;
try { dval = Convert.ToDouble(val.Trim(), CultureInfo.InvariantCulture); }
catch(FormatException)
{
// ERROR: Invalid value in assignment
RaiseError(file, line, ERROR_VALUEINVALID);
return null;
}
return dval;
}
else
{
// Convert to int