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);
|
||||
if(!matches.ContainsKey(data[line])) matches.Add(data[line], f);
|
||||
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
|
||||
RaiseError(line, ERROR_KEYWORDUNKNOWN + "\n\nUnrecognized token: \"" + val.ToString().Trim() + "\"");
|
||||
break;
|
||||
|
|
|
@ -459,6 +459,14 @@ namespace CodeImp.DoomBuilder.IO
|
|||
float x = GetCollectionEntry(c, "x", 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
|
||||
Vertex v = map.CreateVertex(new Vector2D(x, y));
|
||||
if(v != null)
|
||||
|
|
|
@ -93,8 +93,16 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Constructor
|
||||
internal Vertex(MapSet map, int listindex, Vector2D pos)
|
||||
{
|
||||
// Initialize
|
||||
this.elementtype = MapElementType.VERTEX; //mxd
|
||||
// [ZZ] Check coordinates
|
||||
// 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.linedefs = new LinkedList<Linedef>();
|
||||
this.listindex = listindex;
|
||||
|
|
Loading…
Reference in a new issue