Skip to content
Snippets Groups Projects
Commit 52871962 authored by MaxED's avatar MaxED
Browse files

Fixed, ACC compiler: in some cases compilation errors contained map file path...

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.
parent bc4f65e4
No related branches found
No related tags found
No related merge requests found
...@@ -85,12 +85,13 @@ namespace CodeImp.DoomBuilder.Compilers ...@@ -85,12 +85,13 @@ namespace CodeImp.DoomBuilder.Compilers
// Preprocess the file // Preprocess the file
parser = new AcsParserSE parser = new AcsParserSE
{ {
IsMapScriptsLump = SourceIsMapScriptsLump,
OnInclude = delegate(AcsParserSE se, string includefile, AcsParserSE.IncludeType includetype) OnInclude = delegate(AcsParserSE se, string includefile, AcsParserSE.IncludeType includetype)
{ {
TextResourceData data = General.Map.Data.GetTextResourceData(includefile); TextResourceData data = General.Map.Data.GetTextResourceData(includefile);
if(data == null) if(data == null)
{ {
se.ReportError("Unable to find include file \"" + includefile + "\""); se.ReportError("Unable to find include file \"" + includefile + "\".");
return false; // Fial return false; // Fial
} }
...@@ -105,7 +106,8 @@ namespace CodeImp.DoomBuilder.Compilers ...@@ -105,7 +106,8 @@ namespace CodeImp.DoomBuilder.Compilers
if(SourceIsMapScriptsLump && stream.Length == 0) return false; if(SourceIsMapScriptsLump && stream.Length == 0) return false;
DataLocation dl = new DataLocation(DataLocation.RESOURCE_DIRECTORY, Path.GetDirectoryName(inputfilepath), false, false, 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)) if(!parser.Parse(data, info.Files, true, AcsParserSE.IncludeType.NONE, false))
{ {
// Check for errors // Check for errors
...@@ -117,14 +119,7 @@ namespace CodeImp.DoomBuilder.Compilers ...@@ -117,14 +119,7 @@ namespace CodeImp.DoomBuilder.Compilers
//mxd. External lumps should be libraries //mxd. External lumps should be libraries
if(!SourceIsMapScriptsLump && !parser.IsLibrary) if(!SourceIsMapScriptsLump && !parser.IsLibrary)
{ {
ReportError(new CompilerError("External ACS files can only be compiled as libraries!", sourcefile)); 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));
return true; return true;
} }
...@@ -215,6 +210,7 @@ namespace CodeImp.DoomBuilder.Compilers ...@@ -215,6 +210,7 @@ namespace CodeImp.DoomBuilder.Compilers
// Read all lines // Read all lines
bool erroradded = false; //mxd bool erroradded = false; //mxd
string[] errlines = File.ReadAllLines(errfile); string[] errlines = File.ReadAllLines(errfile);
string temppath = this.tempdir.FullName + Path.DirectorySeparatorChar.ToString(); //mxd. Need trailing slash..
while(line < errlines.Length) while(line < errlines.Length)
{ {
// Check line // Check line
...@@ -235,7 +231,7 @@ namespace CodeImp.DoomBuilder.Compilers ...@@ -235,7 +231,7 @@ namespace CodeImp.DoomBuilder.Compilers
err.filename = linestr.Substring(0, match.Index).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); err.filename = linestr.Substring(0, match.Index).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
//mxd. Get rid of temp directory path //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)) if(!Path.IsPathRooted(err.filename))
{ {
......
...@@ -217,7 +217,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting ...@@ -217,7 +217,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
case "#library": case "#library":
if(IsMapScriptsLump) 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; return IgnoreErrors;
} }
...@@ -226,7 +226,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting ...@@ -226,7 +226,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
if(!libname.StartsWith("\"") || !libname.EndsWith("\"")) if(!libname.StartsWith("\"") || !libname.EndsWith("\""))
{ {
if(!IgnoreErrors) ReportError("#library name should be quoted"); if(!IgnoreErrors) ReportError("#library name should be quoted.");
return IgnoreErrors; return IgnoreErrors;
} }
...@@ -234,7 +234,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting ...@@ -234,7 +234,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
if(string.IsNullOrEmpty(libname)) if(string.IsNullOrEmpty(libname))
{ {
if(!IgnoreErrors) ReportError("Expected library name"); if(!IgnoreErrors) ReportError("Expected library name.");
return IgnoreErrors; return IgnoreErrors;
} }
...@@ -260,7 +260,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting ...@@ -260,7 +260,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
if(!includelump.StartsWith("\"") || !includelump.EndsWith("\"")) if(!includelump.StartsWith("\"") || !includelump.EndsWith("\""))
{ {
if(!IgnoreErrors) ReportError(token + " filename should be quoted"); if(!IgnoreErrors) ReportError(token + " filename should be quoted.");
return IgnoreErrors; return IgnoreErrors;
} }
...@@ -268,7 +268,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting ...@@ -268,7 +268,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
if(string.IsNullOrEmpty(includelump)) if(string.IsNullOrEmpty(includelump))
{ {
if(!IgnoreErrors) ReportError("Expected file name to " + token); if(!IgnoreErrors) ReportError("Expected file name to " + token + ".");
return IgnoreErrors; return IgnoreErrors;
} }
...@@ -280,7 +280,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting ...@@ -280,7 +280,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
// These can also be included several times... // These can also be included several times...
if(includes[includecategory].Contains(includelump)) 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; return IgnoreErrors;
} }
...@@ -299,7 +299,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting ...@@ -299,7 +299,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
// Already parsed? // Already parsed?
if(includes[includecategory].Contains(includelumppath)) 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; return IgnoreErrors;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment