When loading UDMF maps and fields that have NaN (not a number) as a value are encountered those fields will now be dropped permanently. A warning that this happens will be displayed in the Errors and Warnings dialog.

This commit is contained in:
biwa 2020-10-11 00:31:55 +02:00
parent 6659a8ccbd
commit c0984c8b67
2 changed files with 15 additions and 2 deletions

View file

@ -60,6 +60,9 @@ namespace CodeImp.DoomBuilder.IO
private int cpErrorResult;
private string cpErrorDescription = "";
private int cpErrorLine;
// Warnings
private List<string> warnings = new List<string>();
// Configuration root
private UniversalCollection root;
@ -82,6 +85,8 @@ namespace CodeImp.DoomBuilder.IO
public int ErrorLine { get { return cpErrorLine; } }
public UniversalCollection Root { get { return root; } }
public bool StrictChecking { get { return strictchecking; } set { strictchecking = value; } }
public bool HasWarnings { get { return warnings.Count != 0; } }
public List<string> Warnings { get { return warnings; } }
#endregion
@ -623,8 +628,10 @@ namespace CodeImp.DoomBuilder.IO
case "nan":
// Add float value
UniversalEntry nan = new UniversalEntry(key.ToString().Trim().ToLowerInvariant(), float.NaN);
cs.Add(nan);
UniversalEntry nan = new UniversalEntry(key.ToString().Trim().ToLowerInvariant(), double.NaN);
// Do not add NaN, just drop it with a warning
// cs.Add(nan);
warnings.Add("UDMF map data line " + (line+1) + ": value of field " + key.ToString().Trim().ToLowerInvariant() + " has a value of NaN (not a number). Field is being dropped permanentely.");
if (!matches.ContainsKey(data[line])) matches.Add(data[line], nan);
break;

View file

@ -152,6 +152,12 @@ namespace CodeImp.DoomBuilder.IO
throw new Exception("Error on line " + textmap.ErrorLine + " while parsing UDMF map data:\n" + textmap.ErrorDescription);
}
if(textmap.HasWarnings)
{
foreach (string warning in textmap.Warnings)
General.ErrorLogger.Add(ErrorType.Warning, warning);
}
// Read the map
Dictionary<int, Vertex> vertexlink = ReadVertices(map, textmap);
Dictionary<int, Sector> sectorlink = ReadSectors(map, textmap);