mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-17 09:32:34 +00:00
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:
parent
dc3d4064a1
commit
f86bc370d9
3 changed files with 593 additions and 568 deletions
|
@ -92,33 +92,38 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
{
|
{
|
||||||
string token = StripTokenQuotes(ReadToken()).ToLowerInvariant(); //Quotes can be anywhere! ANYWHERE!!! And GZDoom will still parse data correctly
|
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
|
//got light structure
|
||||||
if(token == GldefsLightType.POINT || token == GldefsLightType.PULSE || token == GldefsLightType.FLICKER
|
if(token == GldefsLightType.POINT || token == GldefsLightType.PULSE || token == GldefsLightType.FLICKER
|
||||||
|| token == GldefsLightType.FLICKER2 || token == GldefsLightType.SECTOR)
|
|| token == GldefsLightType.FLICKER2 || token == GldefsLightType.SECTOR)
|
||||||
{
|
{
|
||||||
string lightType = token;
|
string lightType = token;
|
||||||
|
DynamicLightData light = new DynamicLightData { Type = GldefsLightType.GLDEFS_TO_GZDOOM_LIGHT_TYPE[lightType] };
|
||||||
DynamicLightData light = new DynamicLightData();
|
|
||||||
light.Type = GldefsLightType.GLDEFS_TO_GZDOOM_LIGHT_TYPE[lightType];
|
|
||||||
|
|
||||||
//find classname
|
//find classname
|
||||||
SkipWhitespace(true);
|
SkipWhitespace(true);
|
||||||
string lightName = StripTokenQuotes(ReadToken()).ToLowerInvariant();
|
string lightName = StripTokenQuotes(ReadToken()).ToLowerInvariant();
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(lightName))
|
if(string.IsNullOrEmpty(lightName))
|
||||||
{
|
{
|
||||||
|
ReportError("Expected " + token + " name");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//now find opening brace
|
//now find opening brace
|
||||||
if(!NextTokenIs("{")) continue;
|
if(!NextTokenIs("{", false))
|
||||||
|
{
|
||||||
|
ReportError("Expected opening brace");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//read gldefs light structure
|
//read gldefs light structure
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
{
|
{
|
||||||
token = ReadToken();
|
token = ReadToken().ToLowerInvariant();
|
||||||
if(!string.IsNullOrEmpty(token))
|
if(!string.IsNullOrEmpty(token))
|
||||||
{
|
{
|
||||||
token = token.ToLowerInvariant();
|
|
||||||
//color
|
//color
|
||||||
if(token == "color")
|
if(token == "color")
|
||||||
{
|
{
|
||||||
|
@ -393,7 +398,6 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if(token == "object")
|
else if(token == "object")
|
||||||
{
|
{
|
||||||
SkipWhitespace(true);
|
SkipWhitespace(true);
|
||||||
|
@ -401,10 +405,18 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
//read object class
|
//read object class
|
||||||
string objectClass = StripTokenQuotes(ReadToken()).ToLowerInvariant();
|
string objectClass = StripTokenQuotes(ReadToken()).ToLowerInvariant();
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(objectClass))
|
if(string.IsNullOrEmpty(objectClass))
|
||||||
{
|
{
|
||||||
|
ReportError("Expected object class");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//now find opening brace
|
//now find opening brace
|
||||||
if(!NextTokenIs("{")) continue;
|
if(!NextTokenIs("{", false))
|
||||||
|
{
|
||||||
|
ReportError("Expected opening brace");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int bracesCount = 1;
|
int bracesCount = 1;
|
||||||
bool foundLight = false;
|
bool foundLight = false;
|
||||||
|
@ -454,21 +466,33 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//Glowing flats block start
|
//Glowing flats block start
|
||||||
else if(token == "glow")
|
else if(token == "glow")
|
||||||
{
|
{
|
||||||
// Next sould be opening brace
|
// Next sould be opening brace
|
||||||
if(!NextTokenIs("{")) continue;
|
if(!NextTokenIs("{", false))
|
||||||
|
{
|
||||||
|
ReportError("Expected opening brace");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Parse inner blocks
|
// Parse inner blocks
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
{
|
{
|
||||||
token = ReadToken().ToLowerInvariant();
|
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
|
// Next sould be opening brace
|
||||||
if(!NextTokenIs("{")) break;
|
if(!NextTokenIs("{", false))
|
||||||
|
{
|
||||||
|
ReportError("Expected opening brace");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Read flat names
|
// Read flat names
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
|
@ -489,7 +513,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
else if(token == "subflats" || token == "subwalls")
|
else if(token == "subflats" || token == "subwalls")
|
||||||
{
|
{
|
||||||
// Next sould be opening brace
|
// Next sould be opening brace
|
||||||
if(!NextTokenIs("{")) break;
|
if(!NextTokenIs("{", false))
|
||||||
|
{
|
||||||
|
ReportError("Expected opening brace");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Read flat names
|
// Read flat names
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
|
@ -521,7 +549,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we should find a comma
|
// Now we should find a comma
|
||||||
if(!NextTokenIs(",")) break;
|
if(!NextTokenIs(",", false))
|
||||||
|
{
|
||||||
|
ReportError("Expected a comma");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Next is color
|
// Next is color
|
||||||
SkipWhitespace(true);
|
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")
|
else if(token == "#include")
|
||||||
{
|
{
|
||||||
//INFO: ZDoom GLDEFS include paths can't be relative ("../glstuff.txt")
|
//INFO: ZDoom GLDEFS include paths can't be relative ("../glstuff.txt")
|
||||||
//or absolute ("d:/project/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
|
//include paths are relative to the first parsed entry, not the current one
|
||||||
//also include paths may or may not be quoted
|
//also include paths may or may not be quoted
|
||||||
SkipWhitespace(true);
|
SkipWhitespace(true);
|
||||||
|
@ -650,10 +675,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backward slases are not supported
|
// Backward slashes are not supported
|
||||||
if(includelump.Contains(Path.DirectorySeparatorChar.ToString()))
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,9 +730,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
while(scopelevel > 0);
|
while(scopelevel > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return objects.Count > 0;
|
return !this.HasError;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -137,7 +137,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
|
|
||||||
//should be sky texture name
|
//should be sky texture name
|
||||||
token = StripTokenQuotes(ReadToken());
|
token = StripTokenQuotes(ReadToken());
|
||||||
bool gotComma = (token.IndexOf(",") != -1);
|
bool gotComma = (token.IndexOf(",", StringComparison.Ordinal) != -1);
|
||||||
if(gotComma) token = token.Replace(",", "");
|
if(gotComma) token = token.Replace(",", "");
|
||||||
string skyTexture = StripTokenQuotes(token).ToLowerInvariant();
|
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")
|
//INFO: ZDoom MAPINFO include paths can't be relative ("../mapstuff.txt")
|
||||||
//or absolute ("d:/project/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
|
//include paths are relative to the first parsed entry, not the current one
|
||||||
//also include paths may or may not be quoted
|
//also include paths may or may not be quoted
|
||||||
if(!string.IsNullOrEmpty(includelump))
|
if(!string.IsNullOrEmpty(includelump))
|
||||||
|
@ -379,10 +379,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backward slases are not supported
|
// Backward slashes are not supported
|
||||||
if(includelump.Contains(Path.DirectorySeparatorChar.ToString()))
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -154,7 +155,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
{
|
{
|
||||||
//INFO: ZDoom DECORATE include paths can't be relative ("../actor.txt")
|
//INFO: ZDoom DECORATE include paths can't be relative ("../actor.txt")
|
||||||
//or absolute ("d:/project/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
|
//include paths are relative to the first parsed entry, not the current one
|
||||||
//also include paths may or may not be quoted
|
//also include paths may or may not be quoted
|
||||||
SkipWhitespace(true);
|
SkipWhitespace(true);
|
||||||
|
@ -182,10 +183,10 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd. Backward slases are not supported
|
//mxd. Backward slashes are not supported
|
||||||
if(filename.Contains(Path.DirectorySeparatorChar.ToString()))
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue