From 5cb40a23c2954e5ad8c6c5e54521f076663860af Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Sat, 9 Apr 2022 17:00:49 +0200 Subject: [PATCH] ZScript: fixed an issue where #include files were not parsed when the parent file had a //$GZDB_Skip comment. Fixes #716 --- Source/Core/ZDoom/ZScriptParser.cs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Source/Core/ZDoom/ZScriptParser.cs b/Source/Core/ZDoom/ZScriptParser.cs index 213ca5f2..a9b47923 100755 --- a/Source/Core/ZDoom/ZScriptParser.cs +++ b/Source/Core/ZDoom/ZScriptParser.cs @@ -846,16 +846,7 @@ namespace CodeImp.DoomBuilder.ZDoom ZScriptTokenType.Preprocessor); if (token == null) // EOF reached - { - // Now parse all included files - foreach(string include in includes) - { - if (!ParseInclude(include)) - return false; - } - break; - } if (!token.IsValid) { @@ -863,6 +854,10 @@ namespace CodeImp.DoomBuilder.ZDoom return false; } + // If $GZDB_SKIP is encountered we stop parsing. Not that we can't "return" here yet, because the includes still have to be parsed + if (token.Type == ZScriptTokenType.LineComment && token.Value.Trim().ToLowerInvariant() == "$gzdb_skip") + break; + // toplevel tokens allowed are only Preprocessor and Identifier. switch (token.Type) { @@ -876,9 +871,6 @@ namespace CodeImp.DoomBuilder.ZDoom string cmtval = token.Value.TrimStart(); if (cmtval.Length <= 0 || cmtval[0] != '$') break; - // check for $GZDB_SKIP - if (cmtval.Trim().ToLowerInvariant() == "$gzdb_skip") - return true; // if we are in a region, read property using function from ZScriptActorStructure if (regions.Count > 0) ZScriptActorStructure.ParseGZDBComment(regions.Last().Properties, cmtval); @@ -1014,6 +1006,13 @@ namespace CodeImp.DoomBuilder.ZDoom } } + // Now parse all included files + foreach (string include in includes) + { + if (!ParseInclude(include)) + return false; + } + return true; }