From 528719622b1c541ba87a0210efc3e7353fef82e4 Mon Sep 17 00:00:00 2001 From: MaxED <j.maxed@gmail.com> Date: Tue, 31 May 2016 23:57:41 +0000 Subject: [PATCH] Fixed, ACC compiler: in some cases compilation errors contained map file path as error source instead of lump name when compiling SCRIPTS lump. Fixed, ACC compiler: in some cases includes were processed incorrectly when compiling external acs files. --- Source/Core/Compilers/AccCompiler.cs | 18 +++++++----------- Source/Core/ZDoom/Scripting/AcsParserSE.cs | 14 +++++++------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Source/Core/Compilers/AccCompiler.cs b/Source/Core/Compilers/AccCompiler.cs index 57a84e120..fd6ac0ede 100644 --- a/Source/Core/Compilers/AccCompiler.cs +++ b/Source/Core/Compilers/AccCompiler.cs @@ -85,12 +85,13 @@ namespace CodeImp.DoomBuilder.Compilers // Preprocess the file parser = new AcsParserSE { + IsMapScriptsLump = SourceIsMapScriptsLump, OnInclude = delegate(AcsParserSE se, string includefile, AcsParserSE.IncludeType includetype) { TextResourceData data = General.Map.Data.GetTextResourceData(includefile); if(data == null) { - se.ReportError("Unable to find include file \"" + includefile + "\""); + se.ReportError("Unable to find include file \"" + includefile + "\"."); return false; // Fial } @@ -105,7 +106,8 @@ namespace CodeImp.DoomBuilder.Compilers if(SourceIsMapScriptsLump && stream.Length == 0) return false; DataLocation dl = new DataLocation(DataLocation.RESOURCE_DIRECTORY, Path.GetDirectoryName(inputfilepath), false, false, false); - TextResourceData data = new TextResourceData(stream, dl, inputfile, false); + //mxd. TextResourceData must point to temp path when compiling WAD lumps for lump to be recognized as map lump when reporting errors... + TextResourceData data = new TextResourceData(stream, dl, (SourceIsMapScriptsLump ? inputfile : sourcefile), false); if(!parser.Parse(data, info.Files, true, AcsParserSE.IncludeType.NONE, false)) { // Check for errors @@ -117,14 +119,7 @@ namespace CodeImp.DoomBuilder.Compilers //mxd. External lumps should be libraries if(!SourceIsMapScriptsLump && !parser.IsLibrary) { - ReportError(new CompilerError("External ACS files can only be compiled as libraries!", sourcefile)); - return true; - } - - //mxd. SCRIPTS lump can't be library - if(SourceIsMapScriptsLump && parser.IsLibrary) - { - ReportError(new CompilerError("SCRIPTS lump can't be compiled as library!", sourcefile)); + ReportError(new CompilerError("External ACS files can only be compiled as libraries.", sourcefile)); return true; } @@ -215,6 +210,7 @@ namespace CodeImp.DoomBuilder.Compilers // Read all lines bool erroradded = false; //mxd string[] errlines = File.ReadAllLines(errfile); + string temppath = this.tempdir.FullName + Path.DirectorySeparatorChar.ToString(); //mxd. Need trailing slash.. while(line < errlines.Length) { // Check line @@ -235,7 +231,7 @@ namespace CodeImp.DoomBuilder.Compilers err.filename = linestr.Substring(0, match.Index).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); //mxd. Get rid of temp directory path - if(err.filename.StartsWith(this.tempdir.Name)) err.filename = err.filename.Replace(this.tempdir.Name, string.Empty); + if(err.filename.StartsWith(temppath)) err.filename = err.filename.Replace(temppath, string.Empty); if(!Path.IsPathRooted(err.filename)) { diff --git a/Source/Core/ZDoom/Scripting/AcsParserSE.cs b/Source/Core/ZDoom/Scripting/AcsParserSE.cs index 8a807f0ed..1ee8ae5b1 100644 --- a/Source/Core/ZDoom/Scripting/AcsParserSE.cs +++ b/Source/Core/ZDoom/Scripting/AcsParserSE.cs @@ -217,7 +217,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting case "#library": if(IsMapScriptsLump) { - if(!IgnoreErrors) ReportError("SCRIPTS lump can not be compiled as a library"); + if(!IgnoreErrors) ReportError("SCRIPTS lump can't be compiled as library."); return IgnoreErrors; } @@ -226,7 +226,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting if(!libname.StartsWith("\"") || !libname.EndsWith("\"")) { - if(!IgnoreErrors) ReportError("#library name should be quoted"); + if(!IgnoreErrors) ReportError("#library name should be quoted."); return IgnoreErrors; } @@ -234,7 +234,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting if(string.IsNullOrEmpty(libname)) { - if(!IgnoreErrors) ReportError("Expected library name"); + if(!IgnoreErrors) ReportError("Expected library name."); return IgnoreErrors; } @@ -260,7 +260,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting if(!includelump.StartsWith("\"") || !includelump.EndsWith("\"")) { - if(!IgnoreErrors) ReportError(token + " filename should be quoted"); + if(!IgnoreErrors) ReportError(token + " filename should be quoted."); return IgnoreErrors; } @@ -268,7 +268,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting if(string.IsNullOrEmpty(includelump)) { - if(!IgnoreErrors) ReportError("Expected file name to " + token); + if(!IgnoreErrors) ReportError("Expected file name to " + token + "."); return IgnoreErrors; } @@ -280,7 +280,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting // These can also be included several times... if(includes[includecategory].Contains(includelump)) { - if(!IgnoreErrors) ReportError("Already parsed \"" + includelump + "\". Check your " + token + " directives"); + if(!IgnoreErrors) ReportError("Already parsed \"" + includelump + "\". Check your " + token + " directives."); return IgnoreErrors; } @@ -299,7 +299,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting // Already parsed? if(includes[includecategory].Contains(includelumppath)) { - if(!IgnoreErrors) ReportError("Already parsed \"" + includelump + "\". Check your " + token + " directives"); + if(!IgnoreErrors) ReportError("Already parsed \"" + includelump + "\". Check your " + token + " directives."); return IgnoreErrors; } -- GitLab