UltimateZoneBuilder/Source/Core/GZBuilder/GZDoom/ModeldefParserSE.cs
MaxED dbcc57b7a6 Fixed, Script Editor: file was marked as changed when changing script configurations.
Fixed, Script Editor: in some cases clicking on an error in the errors list didn't navigate to the error location.
Fixed, Script Editor: in some cases incorrect error line number was shown.
Fixed, Text lump parsers: fixed a crash when trying to get a filename from a quoted string with missing closing quote.
Fixed, Text lump parsers: in several cases parsing errors were ignored by overlaying data structures.
Fixed: in some cases Thing Filter thing flags were cleared when switching game configurations in the "Game Configurations" window.
Changed, PK3 reader: loading of files with invalid path chars is now skipped instead of skipping loading of the whole resource. Also more helpful warning message is now displayed.
Updated SharpCompress library to v.0.11.2.0.
2015-12-17 10:07:28 +00:00

64 lines
1.6 KiB
C#

#region ================== Namespaces
using System.Collections.Generic;
using System.IO;
using CodeImp.DoomBuilder.GZBuilder.Data;
using CodeImp.DoomBuilder.ZDoom;
#endregion
//mxd. Modeldef parser used to create ScriptItems for use in script editor's navigator
//Should be parse model definitions even from invalid MODELDEF and should never fail parsing
namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
{
internal sealed class ModeldefParserSE : ZDTextParser
{
private readonly List<ScriptItem> models;
internal List<ScriptItem> Models { get { return models; } }
public ModeldefParserSE()
{
models = new List<ScriptItem>();
}
public override bool Parse(Stream stream, string sourcefilename)
{
base.Parse(stream, sourcefilename);
// Continue until at the end of the stream
while(SkipWhitespace(true))
{
string token = ReadToken();
if(string.IsNullOrEmpty(token) || token.ToUpperInvariant() != "MODEL") continue;
SkipWhitespace(true);
int startpos = (int)stream.Position;
string modelname = ReadToken();
SkipWhitespace(true);
token = ReadToken(); //this should be "{"
if(token == "{")
{
ScriptItem i = new ScriptItem(modelname, startpos, false);
models.Add(i);
}
while(SkipWhitespace(true))
{
token = ReadToken();
if(string.IsNullOrEmpty(token) || token == "}") break;
}
}
// Sort nodes
models.Sort(ScriptItem.SortByName);
return true;
}
protected override string GetLanguageType()
{
return "MODELDEF";
}
}
}