mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
Re-added, MODELDEF parser: actor classname can have spaces, so it can be quoted...
Added, GLDEFS parser: light name can have spaces too, so it also can be quoted... Removed some excessive quote stripping from most of the ZDoom-related text parsers. Some parsing error reporting improvements in MODELDEF and GLDEFS parsers. Added a special warning when a texture/flat is overridden by a cameratexture.
This commit is contained in:
parent
580f7d4461
commit
23e4a86a95
12 changed files with 188 additions and 166 deletions
|
@ -67,7 +67,12 @@ namespace CodeImp.DoomBuilder.Config
|
|||
{
|
||||
//mxd. Wad duplicates are checked by WadReader
|
||||
if(location.type != DataLocation.RESOURCE_WAD && textures.ContainsKey(image.LongName) && !image.HasPatchWithSameName)
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Texture \"" + image.Name + "\" is double defined in resource \"" + this.Location.GetDisplayName() + "\".");
|
||||
{
|
||||
if(image is CameraTextureImage)
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Texture \"" + image.Name + "\" is overridden by CameraTexture with the same name in resource \"" + this.Location.GetDisplayName() + "\".");
|
||||
else
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Texture \"" + image.Name + "\" is double defined in resource \"" + this.Location.GetDisplayName() + "\".");
|
||||
}
|
||||
textures[image.LongName] = image;
|
||||
}
|
||||
|
||||
|
@ -76,7 +81,13 @@ namespace CodeImp.DoomBuilder.Config
|
|||
{
|
||||
//mxd. Wad duplicates are checked by WadReader
|
||||
if(location.type != DataLocation.RESOURCE_WAD && flats.ContainsKey(image.LongName) && (!General.Map.Config.MixTexturesFlats || !image.HasPatchWithSameName))
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Flat \"" + image.Name + "\" is double defined in resource \"" + this.Location.GetDisplayName() + "\".");
|
||||
{
|
||||
if(image is CameraTextureImage)
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Flat \"" + image.Name + "\" is overridden by CameraTexture with the same name in resource \"" + this.Location.GetDisplayName() + "\".");
|
||||
else
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Flat \"" + image.Name + "\" is double defined in resource \"" + this.Location.GetDisplayName() + "\".");
|
||||
}
|
||||
|
||||
flats[image.LongName] = image;
|
||||
}
|
||||
|
||||
|
|
|
@ -2274,12 +2274,21 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
// Create Gldefs Entries dictionary
|
||||
foreach(KeyValuePair<string, string> e in parser.Objects) //<ClassName, Light name>
|
||||
{
|
||||
// If we have decorate actor and light definition for given ClassName...
|
||||
if(actorsbyclass.ContainsKey(e.Key) && parser.LightsByName.ContainsKey(e.Value))
|
||||
gldefsentries[actorsbyclass[e.Key]] = parser.LightsByName[e.Value];
|
||||
else if(!decorate.AllActorsByClass.ContainsKey(e.Key))
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "GLDEFS object \"" + e.Key + "\" doesn't match any DECORATE actor class");
|
||||
{
|
||||
// Check if we have decorate actor and light definition for given ClassName
|
||||
//INFO: objects without corresponding actors are already reported by the parser
|
||||
if(actorsbyclass.ContainsKey(e.Key))
|
||||
{
|
||||
if(parser.LightsByName.ContainsKey(e.Value))
|
||||
{
|
||||
gldefsentries[actorsbyclass[e.Key]] = parser.LightsByName[e.Value];
|
||||
}
|
||||
else
|
||||
{
|
||||
//INFO: Lights CAN be defiend after Objects, so we can't perform any object->light matching checks while parsing
|
||||
General.ErrorLogger.Add(ErrorType.Error, "GLDEFS object \"" + e.Key + "\" references undefined light \"" + e.Value + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Grab them glowy flats!
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
// Continue until at the end of the stream
|
||||
while(SkipWhitespace(true))
|
||||
{
|
||||
string token = ReadToken();
|
||||
string token = ReadToken().ToLowerInvariant();
|
||||
if(string.IsNullOrEmpty(token)) continue;
|
||||
|
||||
// Ignore inner scope stuff
|
||||
|
@ -123,7 +123,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
if(token == "}") { bracelevel--; continue; }
|
||||
if(bracelevel > 0) continue;
|
||||
|
||||
switch(token.ToLowerInvariant())
|
||||
switch(token)
|
||||
{
|
||||
case "script":
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
if(token.IndexOf('"') != -1)
|
||||
{
|
||||
startpos += 1;
|
||||
string scriptname = StripTokenQuotes(token);
|
||||
string scriptname = StripQuotes(token);
|
||||
|
||||
// Try to parse argument names
|
||||
List<KeyValuePair<string, string>> args = ParseArgs();
|
||||
|
@ -231,7 +231,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
return IgnoreErrors;
|
||||
}
|
||||
|
||||
libname = StripTokenQuotes(libname);
|
||||
libname = StripQuotes(libname);
|
||||
|
||||
if(string.IsNullOrEmpty(libname))
|
||||
{
|
||||
|
@ -265,7 +265,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
return IgnoreErrors;
|
||||
}
|
||||
|
||||
includelump = StripTokenQuotes(includelump);
|
||||
includelump = StripQuotes(includelump);
|
||||
|
||||
if(string.IsNullOrEmpty(includelump))
|
||||
{
|
||||
|
|
|
@ -109,8 +109,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
// Continue until at the end of the stream
|
||||
while(SkipWhitespace(true))
|
||||
{
|
||||
string token = StripTokenQuotes(ReadToken()).ToLowerInvariant(); // Quotes can be anywhere! ANYWHERE!!! And GZDoom will still parse data correctly
|
||||
if(string.IsNullOrEmpty(token)) break;
|
||||
string token = ReadToken().ToLowerInvariant();
|
||||
if(string.IsNullOrEmpty(token)) continue;
|
||||
|
||||
switch(token)
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
// Find classname
|
||||
SkipWhitespace(true);
|
||||
string lightname = StripTokenQuotes(ReadToken());
|
||||
string lightname = StripQuotes(ReadToken());
|
||||
|
||||
if(string.IsNullOrEmpty(lightname))
|
||||
{
|
||||
|
@ -187,7 +187,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
case "color":
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
if(!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out light.Color.Red))
|
||||
{
|
||||
// Not numeric!
|
||||
|
@ -196,7 +196,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
}
|
||||
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
if(!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out light.Color.Green))
|
||||
{
|
||||
// Not numeric!
|
||||
|
@ -205,7 +205,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
}
|
||||
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
if(!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out light.Color.Blue))
|
||||
{
|
||||
// Not numeric!
|
||||
|
@ -219,7 +219,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
SkipWhitespace(true);
|
||||
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out light.PrimaryRadius))
|
||||
{
|
||||
// Not numeric!
|
||||
|
@ -238,7 +238,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
case "offset":
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
if(!ReadSignedFloat(token, ref light.Offset.X))
|
||||
{
|
||||
// Not numeric!
|
||||
|
@ -247,7 +247,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
}
|
||||
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
if(!ReadSignedFloat(token, ref light.Offset.Z))
|
||||
{
|
||||
// Not numeric!
|
||||
|
@ -256,7 +256,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
}
|
||||
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
if(!ReadSignedFloat(token, ref light.Offset.Y))
|
||||
{
|
||||
// Not numeric!
|
||||
|
@ -269,7 +269,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
SkipWhitespace(true);
|
||||
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
int i;
|
||||
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out i))
|
||||
{
|
||||
|
@ -286,7 +286,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
SkipWhitespace(true);
|
||||
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
int i;
|
||||
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out i))
|
||||
{
|
||||
|
@ -304,7 +304,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
SkipWhitespace(true);
|
||||
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
float interval;
|
||||
if(!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out interval))
|
||||
{
|
||||
|
@ -337,7 +337,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
SkipWhitespace(true);
|
||||
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out light.SecondaryRadius))
|
||||
{
|
||||
// Not numeric!
|
||||
|
@ -359,7 +359,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
SkipWhitespace(true);
|
||||
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
float chance;
|
||||
if(!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out chance))
|
||||
{
|
||||
|
@ -383,7 +383,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
SkipWhitespace(true);
|
||||
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
float scale;
|
||||
if(!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out scale))
|
||||
{
|
||||
|
@ -454,7 +454,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
SkipWhitespace(true);
|
||||
|
||||
// Read object class
|
||||
string objectclass = StripTokenQuotes(ReadToken());
|
||||
string objectclass = StripQuotes(ReadToken());
|
||||
|
||||
if(string.IsNullOrEmpty(objectclass))
|
||||
{
|
||||
|
@ -462,6 +462,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
return false;
|
||||
}
|
||||
|
||||
// Check if actor exists
|
||||
if(!General.Map.Data.Decorate.ActorsByClass.ContainsKey(objectclass))
|
||||
{
|
||||
ReportError("DECORATE class \"" + objectclass + "\" does not exist");
|
||||
|
||||
// We aren't done yet
|
||||
LogError();
|
||||
ClearError();
|
||||
}
|
||||
|
||||
// Now find opening brace
|
||||
if(!NextTokenIs("{", false))
|
||||
{
|
||||
|
@ -476,10 +486,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
// Read frames structure
|
||||
while(SkipWhitespace(true))
|
||||
{
|
||||
string token = ReadToken();
|
||||
string token = ReadToken().ToLowerInvariant();
|
||||
if(string.IsNullOrEmpty(token)) continue;
|
||||
|
||||
token = StripTokenQuotes(token).ToLowerInvariant();
|
||||
if(!foundlight && !foundframe && token == "frame")
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
|
@ -491,19 +500,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
else if(!foundlight && foundframe && token == "light") // Just use first light and be done with it
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
token = ReadToken(); // Should be light name
|
||||
token = StripQuotes(ReadToken()); // Should be light name
|
||||
|
||||
if(!string.IsNullOrEmpty(token))
|
||||
{
|
||||
if(lightsbyname.ContainsKey(token))
|
||||
{
|
||||
objects[objectclass] = token;
|
||||
foundlight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWarning("Light declaration not found for light \"" + token + "\"");
|
||||
}
|
||||
objects[objectclass] = token;
|
||||
foundlight = true;
|
||||
}
|
||||
}
|
||||
else if(token == "{") // Continue in this loop until object structure ends
|
||||
|
@ -594,7 +596,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
int color;
|
||||
int glowheight = DEFAULT_GLOW_HEIGHT;
|
||||
bool subtractivetexture = (token == "subtexture");
|
||||
string texturename = StripTokenQuotes(ReadToken(false));
|
||||
string texturename = StripQuotes(ReadToken(false));
|
||||
|
||||
if(string.IsNullOrEmpty(texturename))
|
||||
{
|
||||
|
@ -707,7 +709,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
private bool ParseSkybox()
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
string name = StripTokenQuotes(ReadToken());
|
||||
string name = StripQuotes(ReadToken());
|
||||
|
||||
if(string.IsNullOrEmpty(name))
|
||||
{
|
||||
|
@ -763,7 +765,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
//include paths are relative to the first parsed entry, not the current one
|
||||
//also include paths may or may not be quoted
|
||||
SkipWhitespace(true);
|
||||
string includelump = StripTokenQuotes(ReadToken(false)); // Don't skip newline
|
||||
string includelump = StripQuotes(ReadToken(false)); // Don't skip newline
|
||||
|
||||
// Sanity checks
|
||||
if(string.IsNullOrEmpty(includelump))
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
}
|
||||
else
|
||||
{
|
||||
mapinfo.Title = StripTokenQuotes(token);
|
||||
mapinfo.Title = StripQuotes(token);
|
||||
}
|
||||
|
||||
// Parse properties
|
||||
|
@ -201,7 +201,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
private bool ParseInclude(bool clearerrors)
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
string includelump = StripTokenQuotes(ReadToken(false)); // Don't skip newline
|
||||
string includelump = StripQuotes(ReadToken(false)); // Don't skip newline
|
||||
|
||||
//INFO: ZDoom MAPINFO include paths can't be relative ("../mapstuff.txt")
|
||||
//or absolute ("d:/project/mapstuff.txt")
|
||||
|
@ -283,7 +283,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
if(!NextTokenIs("=")) return false; // Finished with this file
|
||||
SkipWhitespace(true);
|
||||
string skyflatname = StripTokenQuotes(ReadToken());
|
||||
string skyflatname = StripQuotes(ReadToken());
|
||||
if(string.IsNullOrEmpty(skyflatname))
|
||||
{
|
||||
ReportError("Expected SkyFlatName value");
|
||||
|
@ -327,7 +327,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
// Then actor class
|
||||
SkipWhitespace(false);
|
||||
string classname = StripTokenQuotes(ReadToken());
|
||||
string classname = StripQuotes(ReadToken());
|
||||
if(string.IsNullOrEmpty(classname))
|
||||
{
|
||||
ReportError("Expected DoomEdNums class definition");
|
||||
|
@ -380,7 +380,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
// Then actor class
|
||||
SkipWhitespace(false);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = StripQuotes(ReadToken());
|
||||
if(string.IsNullOrEmpty(token))
|
||||
{
|
||||
ReportError("Unable to get SpawnNums entry class definition");
|
||||
|
@ -490,7 +490,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
private bool ParseSky(string skytype)
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
string token = StripTokenQuotes(ReadToken());
|
||||
string token = StripQuotes(ReadToken());
|
||||
|
||||
// New format
|
||||
if(token == "=")
|
||||
|
@ -498,7 +498,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
SkipWhitespace(true);
|
||||
|
||||
// Should be sky texture name
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = StripQuotes(ReadToken());
|
||||
bool gotcomma = (token.IndexOf(",", StringComparison.Ordinal) != -1);
|
||||
if(gotcomma) token = token.Replace(",", "");
|
||||
string skytexture = token.ToUpperInvariant();
|
||||
|
@ -516,13 +516,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
// Check if we have scrollspeed
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
|
||||
if(!gotcomma && token == ",")
|
||||
{
|
||||
gotcomma = true;
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
}
|
||||
|
||||
if(gotcomma)
|
||||
|
@ -562,7 +562,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
// Try to read scroll speed
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
|
||||
float scrollspeed = 0;
|
||||
if(!ReadSignedFloat(token, ref scrollspeed))
|
||||
|
@ -585,17 +585,17 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
private bool ParseFade(string fadetype)
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
string token = StripTokenQuotes(ReadToken());
|
||||
string token = ReadToken();
|
||||
|
||||
// New format?
|
||||
if(token == "=")
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
}
|
||||
|
||||
// Get the color value
|
||||
string colorval = StripTokenQuotes(token).ToLowerInvariant().Replace(" ", "");
|
||||
string colorval = StripQuotes(token).ToLowerInvariant().Replace(" ", "");
|
||||
|
||||
if(string.IsNullOrEmpty(colorval))
|
||||
{
|
||||
|
@ -625,13 +625,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
private bool ParseWallShade(string shadetype)
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
string token = StripTokenQuotes(ReadToken());
|
||||
string token = ReadToken();
|
||||
|
||||
// New format
|
||||
if(token == "=")
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
}
|
||||
|
||||
int val = 0;
|
||||
|
@ -654,13 +654,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
private bool ParseFogDensity(string densitytype)
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
string token = StripTokenQuotes(ReadToken());
|
||||
string token = ReadToken();
|
||||
|
||||
// New format
|
||||
if(token == "=")
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
}
|
||||
|
||||
int val;
|
||||
|
|
|
@ -58,19 +58,27 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
while(SkipWhitespace(true))
|
||||
{
|
||||
string token = ReadToken();
|
||||
if(string.IsNullOrEmpty(token)) continue;
|
||||
|
||||
token = StripTokenQuotes(token).ToLowerInvariant();
|
||||
if(token != "model") continue;
|
||||
if(string.IsNullOrEmpty(token) || token.ToLowerInvariant() != "model") continue;
|
||||
|
||||
// Find classname
|
||||
SkipWhitespace(true);
|
||||
string classname = ReadToken(ActorStructure.ACTOR_CLASS_SPECIAL_TOKENS);
|
||||
string classname = StripQuotes(ReadToken(ActorStructure.ACTOR_CLASS_SPECIAL_TOKENS));
|
||||
if(string.IsNullOrEmpty(classname))
|
||||
{
|
||||
ReportError("Expected actor class");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if actor exists
|
||||
bool haveplaceableactor = actorsbyclass.ContainsKey(classname);
|
||||
if(!haveplaceableactor && !General.Map.Data.Decorate.ActorsByClass.ContainsKey(classname))
|
||||
{
|
||||
ReportError("DECORATE class \"" + classname + "\" does not exist");
|
||||
|
||||
// We aren't done yet
|
||||
LogError();
|
||||
ClearError();
|
||||
}
|
||||
|
||||
// Now find opening brace
|
||||
if(!NextTokenIs("{")) return false;
|
||||
|
@ -80,7 +88,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
if(mds.Parse(this))
|
||||
{
|
||||
// Fetch Actor info
|
||||
if(actorsbyclass.ContainsKey(classname))
|
||||
if(haveplaceableactor)
|
||||
{
|
||||
ThingTypeInfo info = General.Map.Data.GetThingInfoEx(actorsbyclass[classname]);
|
||||
|
||||
|
|
|
@ -84,10 +84,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
bool parsingfinished = false;
|
||||
while(!parsingfinished && parser.SkipWhitespace(true))
|
||||
{
|
||||
string token = parser.ReadToken();
|
||||
string token = parser.ReadToken().ToLowerInvariant();
|
||||
if(string.IsNullOrEmpty(token)) continue;
|
||||
|
||||
switch(token.ToLowerInvariant())
|
||||
switch(token)
|
||||
{
|
||||
case "path":
|
||||
parser.SkipWhitespace(true);
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
|
||||
// Texture name
|
||||
SkipWhitespace(true);
|
||||
string texturename = StripTokenQuotes(ReadToken(false));
|
||||
string texturename = StripQuotes(ReadToken(false));
|
||||
if(string.IsNullOrEmpty(texturename))
|
||||
{
|
||||
ReportError("Expected camera texture name");
|
||||
|
|
|
@ -196,7 +196,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
//include paths are relative to the first parsed entry, not the current one
|
||||
//also include paths may or may not be quoted
|
||||
SkipWhitespace(true);
|
||||
string filename = StripTokenQuotes(ReadToken(false)); //mxd. Don't skip newline
|
||||
string filename = StripQuotes(ReadToken(false)); //mxd. Don't skip newline
|
||||
|
||||
//mxd. Sanity checks
|
||||
if(string.IsNullOrEmpty(filename))
|
||||
|
@ -258,7 +258,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
case "damagetype": //mxd
|
||||
// Get DamageType name
|
||||
SkipWhitespace(true);
|
||||
string damagetype = StripTokenQuotes(ReadToken(false));
|
||||
string damagetype = StripQuotes(ReadToken(false));
|
||||
if(string.IsNullOrEmpty(damagetype))
|
||||
{
|
||||
ReportError("Expected DamageType name");
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
else
|
||||
{
|
||||
//this should be reverb name and args
|
||||
string name = StripTokenQuotes(token);
|
||||
string name = StripQuotes(token);
|
||||
|
||||
if(string.IsNullOrEmpty(name))
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
|
||||
// Read first part of the ID
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
int arg1;
|
||||
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out arg1))
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
|
||||
// Read second part of the ID
|
||||
SkipWhitespace(true);
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
token = ReadToken();
|
||||
int arg2;
|
||||
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out arg2))
|
||||
{
|
||||
|
|
|
@ -40,104 +40,96 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
// Continue until at the end of the stream
|
||||
while(SkipWhitespace(true))
|
||||
{
|
||||
string token = ReadToken();
|
||||
string token = ReadToken().ToLowerInvariant();
|
||||
if(string.IsNullOrEmpty(token)) continue;
|
||||
|
||||
if(!string.IsNullOrEmpty(token))
|
||||
{
|
||||
token = StripTokenQuotes(token).ToLowerInvariant();
|
||||
if(token == ",") //previous token was a sprite name
|
||||
{
|
||||
if(!string.IsNullOrEmpty(prevToken) && !spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
|
||||
prevToken = StripQuotes(token).ToUpperInvariant();
|
||||
}
|
||||
else if(token == "=") //next token should be a voxel model name
|
||||
{
|
||||
if(!string.IsNullOrEmpty(prevToken) && !spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
|
||||
|
||||
if(token == ",") //previous token was a sprite name
|
||||
{
|
||||
if(!string.IsNullOrEmpty(prevToken) && !spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
|
||||
prevToken = token.ToUpperInvariant();
|
||||
}
|
||||
else if(token == "=") //next token should be a voxel model name
|
||||
{
|
||||
if(!string.IsNullOrEmpty(prevToken) && !spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
|
||||
SkipWhitespace(true);
|
||||
token = ReadToken();
|
||||
|
||||
SkipWhitespace(true);
|
||||
token = ReadToken();
|
||||
|
||||
if(string.IsNullOrEmpty(token))
|
||||
{
|
||||
ReportError("Expected voxel name");
|
||||
return false;
|
||||
}
|
||||
|
||||
modelName = StripTokenQuotes(token).ToLowerInvariant();
|
||||
}
|
||||
else if(token == "{") //read the settings
|
||||
if(string.IsNullOrEmpty(token))
|
||||
{
|
||||
ModelData mde = new ModelData { IsVoxel = true };
|
||||
float scale = 1.0f;
|
||||
float angleoffset = 0;
|
||||
ReportError("Expected voxel name");
|
||||
return false;
|
||||
}
|
||||
|
||||
while(SkipWhitespace(true))
|
||||
{
|
||||
token = ReadToken();
|
||||
modelName = StripQuotes(token).ToLowerInvariant();
|
||||
}
|
||||
else if(token == "{") //read the settings
|
||||
{
|
||||
ModelData mde = new ModelData { IsVoxel = true };
|
||||
float scale = 1.0f;
|
||||
float angleoffset = 0;
|
||||
|
||||
if(!string.IsNullOrEmpty(token))
|
||||
while(SkipWhitespace(true))
|
||||
{
|
||||
token = ReadToken().ToLowerInvariant();
|
||||
if(string.IsNullOrEmpty(token)) continue;
|
||||
|
||||
if(token == "}") //store data
|
||||
{
|
||||
if(!string.IsNullOrEmpty(modelName) && spriteNames.Count > 0)
|
||||
{
|
||||
token = StripTokenQuotes(token).ToLowerInvariant();
|
||||
mde.ModelNames.Add(modelName);
|
||||
mde.SetTransform(Matrix.RotationZ(Angle2D.DegToRad(angleoffset)), Matrix.Identity, new Vector3(scale));
|
||||
|
||||
if(token == "}") //store data
|
||||
{
|
||||
if(!string.IsNullOrEmpty(modelName) && spriteNames.Count > 0)
|
||||
{
|
||||
mde.ModelNames.Add(modelName);
|
||||
mde.SetTransform(Matrix.RotationZ(Angle2D.DegToRad(angleoffset)), Matrix.Identity, new Vector3(scale));
|
||||
|
||||
foreach(string s in spriteNames)
|
||||
{
|
||||
//TODO: is this the proper behaviour?
|
||||
entries[s] = mde;
|
||||
}
|
||||
|
||||
//reset local data
|
||||
modelName = string.Empty;
|
||||
prevToken = string.Empty;
|
||||
spriteNames.Clear();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else if(token == "overridepalette")
|
||||
foreach(string s in spriteNames)
|
||||
{
|
||||
mde.OverridePalette = true;
|
||||
}
|
||||
else if(token == "angleoffset")
|
||||
{
|
||||
if(!NextTokenIs("=")) return false;
|
||||
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
if(!ReadSignedFloat(token, ref angleoffset))
|
||||
{
|
||||
// Not numeric!
|
||||
ReportError("Expected AngleOffset value, but got \"" + token + "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(token == "scale")
|
||||
{
|
||||
if(!NextTokenIs("=")) return false;
|
||||
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
if(!ReadSignedFloat(token, ref scale))
|
||||
{
|
||||
// Not numeric!
|
||||
ReportError("Expected Scale value, but got \"" + token + "\"");
|
||||
return false;
|
||||
}
|
||||
//TODO: is this the proper behaviour?
|
||||
entries[s] = mde;
|
||||
}
|
||||
|
||||
prevToken = token.ToUpperInvariant();
|
||||
//reset local data
|
||||
modelName = string.Empty;
|
||||
prevToken = string.Empty;
|
||||
spriteNames.Clear();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else if(token == "overridepalette")
|
||||
{
|
||||
mde.OverridePalette = true;
|
||||
}
|
||||
else if(token == "angleoffset")
|
||||
{
|
||||
if(!NextTokenIs("=")) return false;
|
||||
|
||||
token = ReadToken();
|
||||
if(!ReadSignedFloat(token, ref angleoffset))
|
||||
{
|
||||
// Not numeric!
|
||||
ReportError("Expected AngleOffset value, but got \"" + token + "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(token == "scale")
|
||||
{
|
||||
if(!NextTokenIs("=")) return false;
|
||||
|
||||
token = ReadToken();
|
||||
if(!ReadSignedFloat(token, ref scale))
|
||||
{
|
||||
// Not numeric!
|
||||
ReportError("Expected Scale value, but got \"" + token + "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prevToken = token.ToUpperInvariant();
|
||||
|
||||
prevToken = StripQuotes(token).ToUpperInvariant();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prevToken = StripQuotes(token).ToUpperInvariant();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -528,14 +528,14 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
}
|
||||
|
||||
//mxd
|
||||
protected internal bool ReadSignedFloat(ref float value) { return ReadSignedFloat(StripTokenQuotes(ReadToken(false)), ref value); }
|
||||
protected internal bool ReadSignedFloat(ref float value) { return ReadSignedFloat(ReadToken(false), ref value); }
|
||||
protected internal bool ReadSignedFloat(string token, ref float value)
|
||||
{
|
||||
int sign = 1;
|
||||
if(token == "-")
|
||||
{
|
||||
sign = -1;
|
||||
token = StripTokenQuotes(ReadToken(false));
|
||||
token = ReadToken(false);
|
||||
}
|
||||
|
||||
float val;
|
||||
|
@ -545,14 +545,14 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
}
|
||||
|
||||
//mxd
|
||||
protected internal bool ReadSignedInt(ref int value) { return ReadSignedInt(StripTokenQuotes(ReadToken(false)), ref value); }
|
||||
protected internal bool ReadSignedInt(ref int value) { return ReadSignedInt(ReadToken(false), ref value); }
|
||||
protected internal bool ReadSignedInt(string token, ref int value)
|
||||
{
|
||||
int sign = 1;
|
||||
if(token == "-")
|
||||
{
|
||||
sign = -1;
|
||||
token = StripTokenQuotes(ReadToken(false));
|
||||
token = ReadToken(false);
|
||||
}
|
||||
|
||||
int val;
|
||||
|
@ -562,7 +562,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
}
|
||||
|
||||
//mxd
|
||||
protected internal bool ReadByte(ref byte value) { return ReadByte(StripTokenQuotes(ReadToken(false)), ref value); }
|
||||
protected internal bool ReadByte(ref byte value) { return ReadByte(ReadToken(false), ref value); }
|
||||
protected internal bool ReadByte(string token, ref byte value)
|
||||
{
|
||||
if(token == "-") return false;
|
||||
|
@ -667,7 +667,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
}
|
||||
else
|
||||
{
|
||||
shorterrorsource = Path.Combine(datalocation.GetDisplayName(), sourcename);
|
||||
shorterrorsource = Path.Combine(datalocation.GetDisplayName(), sourcename).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
||||
errorsource = Path.Combine(datalocation.location, sourcename);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue