DECORATE and MAPINFO parsers: added editor number range check.

This commit is contained in:
MaxED 2016-02-28 21:21:50 +00:00
parent e70c436882
commit 95e28518cb
5 changed files with 29 additions and 9 deletions

View file

@ -382,6 +382,15 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
return false; return false;
} }
// Range check
if((id < General.Map.FormatInterface.MinThingType) || (id > General.Map.FormatInterface.MaxThingType))
{
// Out of bounds!
ReportError("\"" + token + "\" actor's spawn number must be between "
+ General.Map.FormatInterface.MinThingType + " and " + General.Map.FormatInterface.MaxThingType);
return false; // Finished with this file
}
// Add to collection // Add to collection
spawnnums[id] = token.ToLowerInvariant(); spawnnums[id] = token.ToLowerInvariant();
} }

View file

@ -76,8 +76,8 @@ namespace CodeImp.DoomBuilder.IO
public override int MinEffect { get { return ushort.MinValue; } } public override int MinEffect { get { return ushort.MinValue; } }
public override int MaxBrightness { get { return short.MaxValue; } } public override int MaxBrightness { get { return short.MaxValue; } }
public override int MinBrightness { get { return short.MinValue; } } public override int MinBrightness { get { return short.MinValue; } }
public override int MaxThingType { get { return ushort.MaxValue; } } public override int MaxThingType { get { return short.MaxValue; } } //mxd. Editor numbers must be in [1 .. 32767] range
public override int MinThingType { get { return ushort.MinValue; } } public override int MinThingType { get { return 1; } } //mxd
public override float MaxCoordinate { get { return short.MaxValue; } } public override float MaxCoordinate { get { return short.MaxValue; } }
public override float MinCoordinate { get { return short.MinValue; } } public override float MinCoordinate { get { return short.MinValue; } }
public override int MaxThingAngle { get { return short.MaxValue; } } public override int MaxThingAngle { get { return short.MaxValue; } }

View file

@ -74,8 +74,8 @@ namespace CodeImp.DoomBuilder.IO
public override int MinEffect { get { return ushort.MinValue; } } public override int MinEffect { get { return ushort.MinValue; } }
public override int MaxBrightness { get { return short.MaxValue; } } public override int MaxBrightness { get { return short.MaxValue; } }
public override int MinBrightness { get { return short.MinValue; } } public override int MinBrightness { get { return short.MinValue; } }
public override int MaxThingType { get { return ushort.MaxValue; } } public override int MaxThingType { get { return short.MaxValue; } } //mxd. Editor numbers must be in [1 .. 32767] range
public override int MinThingType { get { return ushort.MinValue; } } public override int MinThingType { get { return 1; } } //mxd
public override float MaxCoordinate { get { return short.MaxValue; } } public override float MaxCoordinate { get { return short.MaxValue; } }
public override float MinCoordinate { get { return short.MinValue; } } public override float MinCoordinate { get { return short.MinValue; } }
public override int MaxThingAngle { get { return short.MaxValue; } } public override int MaxThingAngle { get { return short.MaxValue; } }

View file

@ -126,8 +126,8 @@ namespace CodeImp.DoomBuilder.IO
public override int MinEffect { get { return int.MinValue; } } public override int MinEffect { get { return int.MinValue; } }
public override int MaxBrightness { get { return int.MaxValue; } } public override int MaxBrightness { get { return int.MaxValue; } }
public override int MinBrightness { get { return int.MinValue; } } public override int MinBrightness { get { return int.MinValue; } }
public override int MaxThingType { get { return int.MaxValue; } } public override int MaxThingType { get { return short.MaxValue; } } //mxd. Editor numbers must be in [1 .. 32767] range
public override int MinThingType { get { return int.MinValue; } } public override int MinThingType { get { return 1; } } //mxd
public override float MaxCoordinate { get { return short.MaxValue; } } //mxd. UDMF maps are still bounded to -32768 .. 32767 range public override float MaxCoordinate { get { return short.MaxValue; } } //mxd. UDMF maps are still bounded to -32768 .. 32767 range
public override float MinCoordinate { get { return short.MinValue; } } //mxd public override float MinCoordinate { get { return short.MinValue; } } //mxd
public override int MaxThingAngle { get { return int.MaxValue; } } public override int MaxThingAngle { get { return int.MaxValue; } }

View file

@ -160,11 +160,22 @@ namespace CodeImp.DoomBuilder.ZDoom
{ {
// This is for editor-only properties such as $sprite and $category // This is for editor-only properties such as $sprite and $category
props[token] = new List<string> { (parser.SkipWhitespace(false) ? parser.ReadLine() : "") }; props[token] = new List<string> { (parser.SkipWhitespace(false) ? parser.ReadLine() : "") };
continue;
} }
else if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out doomednum)) // Check if numeric
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out doomednum)) // Check if numeric
{ {
// Not numeric! // Not numeric!
parser.ReportError("Expected editor thing number or start of actor scope while parsing \"" + classname + "\""); parser.ReportError("Expected editor number or start of actor scope while parsing \"" + classname + "\"");
return;
}
//mxd. Range check
if((doomednum < General.Map.FormatInterface.MinThingType) || (doomednum > General.Map.FormatInterface.MaxThingType))
{
// Out of bounds!
parser.ReportError("\"" + classname + "\" actor's editor number must be between "
+ General.Map.FormatInterface.MinThingType + " and " + General.Map.FormatInterface.MaxThingType);
return; return;
} }
break; break;