UltimateZoneBuilder/Source/Core/GZBuilder/GZDoom/ModeldefParser.cs
MaxED cf3d416967 Renderer now works much faster in 2D modes.
Textures now load up to 2x faster when "mix textures and flats" flag is set in game configuration.
TEXTUREx/TEXTURES: texture will now be created if at least one of it's patches is loaded.
Visual mode: fixed a crash when "Slope floor to here" (9500) or "Slope ceiling to here" (9501) things were not inside sector.
Fixed: flats were not loaded form wads inside Directory and PK3/PK7 resources.
Sector Info Panel, Linedef Info Panel: texture size was shown for unknown textures.
2013-07-29 08:50:50 +00:00

82 lines
3.4 KiB
C#

using System.Collections.Generic;
using System.IO;
using CodeImp.DoomBuilder.ZDoom;
using CodeImp.DoomBuilder.GZBuilder.Data;
namespace CodeImp.DoomBuilder.GZBuilder.GZDoom {
internal class ModeldefParser : ZDTextParser {
private Dictionary<string, ModelData> modelDefEntries; //classname, entry
internal Dictionary<string, ModelData> ModelDefEntries { get { return modelDefEntries; } }
internal string Source { get { return sourcename; } }
internal ModeldefParser() {
modelDefEntries = new Dictionary<string, ModelData>();
}
//should be called after all decorate actors are parsed
public override bool Parse(Stream stream, string sourcefilename) {
base.Parse(stream, sourcefilename);
modelDefEntries = new Dictionary<string, ModelData>();
// Continue until at the end of the stream
while (SkipWhitespace(true)) {
string token = ReadToken();
if (token != null) {
token = StripTokenQuotes(token).ToLowerInvariant();
if (token == "model") { //model structure start
//find classname
SkipWhitespace(true);
string className = StripTokenQuotes(ReadToken()).ToLowerInvariant();
if (!string.IsNullOrEmpty(className)) {
if(modelDefEntries.ContainsKey(className)) continue; //already got this class; continue to next one
//now find opening brace
SkipWhitespace(true);
token = ReadToken();
if (token != "{") {
General.ErrorLogger.Add(ErrorType.Error, "Unexpected token found in "+sourcefilename+" at line "+GetCurrentLineNumber()+": expected '{', but got " + token);
continue; //something wrong with modeldef declaration, continue to next one
}
ModeldefStructure mds = new ModeldefStructure();
ModelData mde = mds.Parse(this);
if (mde != null) {
mde.ClassName = className;
modelDefEntries.Add(className, mde);
}
}
} else {
// Unknown structure!
string token2;
do {
if (!SkipWhitespace(true)) break;
token2 = ReadToken();
if (token2 == null) break;
}
while (token2 != "{");
int scopelevel = 1;
do {
if (!SkipWhitespace(true)) break;
token2 = ReadToken();
if (token2 == null) break;
if (token2 == "{") scopelevel++;
if (token2 == "}") scopelevel--;
}
while (scopelevel > 0);
}
}
}
if (modelDefEntries.Count > 0)
return true;
return false;
}
}
}