mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 12:50:52 +00:00
Enabled parsing of NaN in UDMF so that the existing buggy maps load; made it throw exceptions when a NaN vertex is added to the map
This commit is contained in:
parent
efd2ded0b3
commit
995e23f290
3 changed files with 27 additions and 4 deletions
|
@ -620,8 +620,15 @@ namespace CodeImp.DoomBuilder.IO
|
||||||
cs.Add(f);
|
cs.Add(f);
|
||||||
if(!matches.ContainsKey(data[line])) matches.Add(data[line], f);
|
if(!matches.ContainsKey(data[line])) matches.Add(data[line], f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case "nan":
|
||||||
|
// Add float value
|
||||||
|
UniversalEntry nan = new UniversalEntry(key.ToString().Trim().ToLowerInvariant(), float.NaN);
|
||||||
|
cs.Add(nan);
|
||||||
|
if (!matches.ContainsKey(data[line])) matches.Add(data[line], nan);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
// Unknown keyword
|
// Unknown keyword
|
||||||
RaiseError(line, ERROR_KEYWORDUNKNOWN + "\n\nUnrecognized token: \"" + val.ToString().Trim() + "\"");
|
RaiseError(line, ERROR_KEYWORDUNKNOWN + "\n\nUnrecognized token: \"" + val.ToString().Trim() + "\"");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -459,6 +459,14 @@ namespace CodeImp.DoomBuilder.IO
|
||||||
float x = GetCollectionEntry(c, "x", true, 0.0f, where);
|
float x = GetCollectionEntry(c, "x", true, 0.0f, where);
|
||||||
float y = GetCollectionEntry(c, "y", true, 0.0f, where);
|
float y = GetCollectionEntry(c, "y", true, 0.0f, where);
|
||||||
|
|
||||||
|
// [ZZ] Correct location if it's NaN. Note that there cannot be any meaningful value here, so I just reset it to 0,0 to avoid triggering the NaN exception
|
||||||
|
// TODO: remove once the cause of NaN is reported
|
||||||
|
if (float.IsNaN(x) || float.IsNaN(y))
|
||||||
|
{
|
||||||
|
x = y = 0f;
|
||||||
|
General.ErrorLogger.Add(ErrorType.Warning, string.Format("Vertex {0} has NaN coordinates, resetting to 0,0", i));
|
||||||
|
}
|
||||||
|
|
||||||
// Create new item
|
// Create new item
|
||||||
Vertex v = map.CreateVertex(new Vector2D(x, y));
|
Vertex v = map.CreateVertex(new Vector2D(x, y));
|
||||||
if(v != null)
|
if(v != null)
|
||||||
|
|
|
@ -93,8 +93,16 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
// Constructor
|
// Constructor
|
||||||
internal Vertex(MapSet map, int listindex, Vector2D pos)
|
internal Vertex(MapSet map, int listindex, Vector2D pos)
|
||||||
{
|
{
|
||||||
// Initialize
|
// [ZZ] Check coordinates
|
||||||
this.elementtype = MapElementType.VERTEX; //mxd
|
// Something in GZDB creates vertices with NaN coordinates. This needs to be found.
|
||||||
|
if (float.IsNaN(pos.x) ||
|
||||||
|
float.IsNaN(pos.y))
|
||||||
|
{
|
||||||
|
throw new Exception("Tried to create a vertex at coordinates NaN,NaN");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
this.elementtype = MapElementType.VERTEX; //mxd
|
||||||
this.map = map;
|
this.map = map;
|
||||||
this.linedefs = new LinkedList<Linedef>();
|
this.linedefs = new LinkedList<Linedef>();
|
||||||
this.listindex = listindex;
|
this.listindex = listindex;
|
||||||
|
|
Loading…
Reference in a new issue