Fixed, GLDEFS parser: in some cases the parser was unable to detect the end of "Glow" block, which resulted in skipping the rest of the file.

This commit is contained in:
MaxED 2015-12-27 00:13:31 +00:00
parent dc3d4064a1
commit f86bc370d9
3 changed files with 593 additions and 568 deletions

View file

@ -92,33 +92,38 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
while(SkipWhitespace(true))
{
string token = StripTokenQuotes(ReadToken()).ToLowerInvariant(); //Quotes can be anywhere! ANYWHERE!!! And GZDoom will still parse data correctly
if(!string.IsNullOrEmpty(token))
{
if(string.IsNullOrEmpty(token)) break;
//got light structure
if(token == GldefsLightType.POINT || token == GldefsLightType.PULSE || token == GldefsLightType.FLICKER
|| token == GldefsLightType.FLICKER2 || token == GldefsLightType.SECTOR)
{
string lightType = token;
DynamicLightData light = new DynamicLightData();
light.Type = GldefsLightType.GLDEFS_TO_GZDOOM_LIGHT_TYPE[lightType];
DynamicLightData light = new DynamicLightData { Type = GldefsLightType.GLDEFS_TO_GZDOOM_LIGHT_TYPE[lightType] };
//find classname
SkipWhitespace(true);
string lightName = StripTokenQuotes(ReadToken()).ToLowerInvariant();
if(!string.IsNullOrEmpty(lightName))
if(string.IsNullOrEmpty(lightName))
{
ReportError("Expected " + token + " name");
return false;
}
//now find opening brace
if(!NextTokenIs("{")) continue;
if(!NextTokenIs("{", false))
{
ReportError("Expected opening brace");
return false;
}
//read gldefs light structure
while(SkipWhitespace(true))
{
token = ReadToken();
token = ReadToken().ToLowerInvariant();
if(!string.IsNullOrEmpty(token))
{
token = token.ToLowerInvariant();
//color
if(token == "color")
{
@ -393,7 +398,6 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
}
}
}
}
else if(token == "object")
{
SkipWhitespace(true);
@ -401,10 +405,18 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
//read object class
string objectClass = StripTokenQuotes(ReadToken()).ToLowerInvariant();
if(!string.IsNullOrEmpty(objectClass))
if(string.IsNullOrEmpty(objectClass))
{
ReportError("Expected object class");
return false;
}
//now find opening brace
if(!NextTokenIs("{")) continue;
if(!NextTokenIs("{", false))
{
ReportError("Expected opening brace");
return false;
}
int bracesCount = 1;
bool foundLight = false;
@ -454,21 +466,33 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
}
}
}
}
//Glowing flats block start
else if(token == "glow")
{
// Next sould be opening brace
if(!NextTokenIs("{")) continue;
if(!NextTokenIs("{", false))
{
ReportError("Expected opening brace");
return false;
}
// Parse inner blocks
while(SkipWhitespace(true))
{
token = ReadToken().ToLowerInvariant();
if(token == "flats" || token == "walls")
if(token == "}")
{
// End of Glow structure
break;
}
else if(token == "flats" || token == "walls")
{
// Next sould be opening brace
if(!NextTokenIs("{")) break;
if(!NextTokenIs("{", false))
{
ReportError("Expected opening brace");
return false;
}
// Read flat names
while(SkipWhitespace(true))
@ -489,7 +513,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
else if(token == "subflats" || token == "subwalls")
{
// Next sould be opening brace
if(!NextTokenIs("{")) break;
if(!NextTokenIs("{", false))
{
ReportError("Expected opening brace");
return false;
}
// Read flat names
while(SkipWhitespace(true))
@ -521,7 +549,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
}
// Now we should find a comma
if(!NextTokenIs(",")) break;
if(!NextTokenIs(",", false))
{
ReportError("Expected a comma");
return false;
}
// Next is color
SkipWhitespace(true);
@ -610,19 +642,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
};
}
}
// Now find closing brace
while(SkipWhitespace(true))
{
token = ReadToken();
if(string.IsNullOrEmpty(token) || token == "}") break;
}
}
else if(token == "#include")
{
//INFO: ZDoom GLDEFS include paths can't be relative ("../glstuff.txt")
//or absolute ("d:/project/glstuff.txt")
//or have backward slases ("info\glstuff.txt")
//or have backward slashes ("info\glstuff.txt")
//include paths are relative to the first parsed entry, not the current one
//also include paths may or may not be quoted
SkipWhitespace(true);
@ -650,10 +675,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
return false;
}
// Backward slases are not supported
if(includelump.Contains(Path.DirectorySeparatorChar.ToString()))
// Backward slashes are not supported
if(includelump.Contains(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture)))
{
ReportError("Only forward slases are supported by ZDoom");
ReportError("Only forward slashes are supported by ZDoom");
return false;
}
@ -705,9 +730,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
while(scopelevel > 0);
}
}
}
return objects.Count > 0;
return !this.HasError;
}
#endregion

View file

@ -137,7 +137,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
//should be sky texture name
token = StripTokenQuotes(ReadToken());
bool gotComma = (token.IndexOf(",") != -1);
bool gotComma = (token.IndexOf(",", StringComparison.Ordinal) != -1);
if(gotComma) token = token.Replace(",", "");
string skyTexture = StripTokenQuotes(token).ToLowerInvariant();
@ -359,7 +359,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
//INFO: ZDoom MAPINFO include paths can't be relative ("../mapstuff.txt")
//or absolute ("d:/project/mapstuff.txt")
//or have backward slases ("info\mapstuff.txt")
//or have backward slashes ("info\mapstuff.txt")
//include paths are relative to the first parsed entry, not the current one
//also include paths may or may not be quoted
if(!string.IsNullOrEmpty(includelump))
@ -379,10 +379,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
return false;
}
// Backward slases are not supported
if(includelump.Contains(Path.DirectorySeparatorChar.ToString()))
// Backward slashes are not supported
if(includelump.Contains(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture)))
{
ReportError("Only forward slases are supported by ZDoom");
ReportError("Only forward slashes are supported by ZDoom");
return false;
}

View file

@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
#endregion
@ -154,7 +155,7 @@ namespace CodeImp.DoomBuilder.ZDoom
{
//INFO: ZDoom DECORATE include paths can't be relative ("../actor.txt")
//or absolute ("d:/project/actor.txt")
//or have backward slases ("info\actor.txt")
//or have backward slashes ("info\actor.txt")
//include paths are relative to the first parsed entry, not the current one
//also include paths may or may not be quoted
SkipWhitespace(true);
@ -182,10 +183,10 @@ namespace CodeImp.DoomBuilder.ZDoom
return false;
}
//mxd. Backward slases are not supported
if(filename.Contains(Path.DirectorySeparatorChar.ToString()))
//mxd. Backward slashes are not supported
if(filename.Contains(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture)))
{
ReportError("Only forward slases are supported by ZDoom");
ReportError("Only forward slashes are supported by ZDoom");
return false;
}