diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..765b22f63c0b22f2efb3a6fd2be53e563f3388a2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,2 @@ +[*.cs] +indent_style = tab \ No newline at end of file diff --git a/Source/Core/BuilderMono.csproj b/Source/Core/BuilderMono.csproj index 52d17bccc0632f60e147f8560036eff85f977236..d94916685439e2e75bb5a02f6acacb32fcd7d4cc 100644 --- a/Source/Core/BuilderMono.csproj +++ b/Source/Core/BuilderMono.csproj @@ -138,6 +138,7 @@ --> <ItemGroup> <Compile Include="Compilers\AccCompiler.cs" /> + <Compile Include="Compilers\BccCompiler.cs" /> <Compile Include="Compilers\NodesCompiler.cs" /> <Compile Include="Config\ArgumentInfo.cs" /> <Compile Include="Config\ExternalCommandSettings.cs" /> diff --git a/Source/Core/Compilers/AccCompiler.cs b/Source/Core/Compilers/AccCompiler.cs index ac5b1b448151ef1879178a92b772950a96f71fb6..4230babf0cb559ad071d72fa4a8d4f387d8fe266 100755 --- a/Source/Core/Compilers/AccCompiler.cs +++ b/Source/Core/Compilers/AccCompiler.cs @@ -36,18 +36,18 @@ namespace CodeImp.DoomBuilder.Compilers protected class CompileContext { } - #endregion + #endregion + + #region ================== Constants - #region ================== Constants + private const string ACS_ERROR_FILE = "acs.err"; - private const string ACS_ERROR_FILE = "acs.err"; - #endregion - + #region ================== Variables private AcsParserSE parser; //mxd - + #endregion #region ================== Properties @@ -58,7 +58,7 @@ namespace CodeImp.DoomBuilder.Compilers #endregion #region ================== Constructor - + // Constructor public AccCompiler(CompilerInfo info) : base(info, false) { @@ -68,7 +68,7 @@ namespace CodeImp.DoomBuilder.Compilers public override void Dispose() { // Not already disposed? - if(!isdisposed) + if (!isdisposed) { // Clean up @@ -76,18 +76,18 @@ namespace CodeImp.DoomBuilder.Compilers base.Dispose(); } } - + #endregion - + #region ================== Methods protected virtual CompileContext OnBeforeProcessStart(ProcessStartInfo info) - { + { return new CompileContext(); } protected virtual void OnCheckError(HashSet<string> includes, ProcessStartInfo processinfo, Process process, CompileContext context) - { + { int line = 0; // Now find the error file @@ -171,7 +171,7 @@ namespace CodeImp.DoomBuilder.Compilers } } } - + // This runs the compiler public override bool Run() { @@ -182,10 +182,10 @@ namespace CodeImp.DoomBuilder.Compilers 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); - if(data == null) + if (data == null) { se.ReportError("Unable to find include file \"" + includefile + "\"."); return false; // Fial @@ -196,31 +196,31 @@ namespace CodeImp.DoomBuilder.Compilers }; string inputfilepath = Path.Combine(this.tempdir.FullName, inputfile); - using(FileStream stream = File.OpenRead(inputfilepath)) + using (FileStream stream = File.OpenRead(inputfilepath)) { // Map SCRIPTS lump is empty. Abort the process without generating any warnings or errors. - 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, null); //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)); - 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 - if(parser.HasError) ReportError(new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine)); + if (parser.HasError) ReportError(new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine)); return true; } } //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)); return true; } //mxd. Update script names if we are compiling the map SCRIPTS lump - if(SourceIsMapScriptsLump) + if (SourceIsMapScriptsLump) { General.Map.UpdateScriptNames(parser); } @@ -228,22 +228,22 @@ namespace CodeImp.DoomBuilder.Compilers //xabis // Copy includes from the resources into the compiler's folder, preserving relative pathing and naming HashSet<string> includes = parser.GetIncludes(); //mxd - foreach(string include in includes) + foreach (string include in includes) { // Grab the script text from the resources TextResourceData data = General.Map.Data.GetTextResourceData(include); - if(data != null && data.Stream != null) + if (data != null && data.Stream != null) { // Pull the pk3 or directory sub folder out if applicable FileInfo fi = new FileInfo(Path.Combine(this.tempdir.FullName, include)); // Do not allow files to be overwritten, either accidentally or maliciously - if(!fi.Exists) + if (!fi.Exists) { General.WriteLogLine("Copying script include: " + include); // Create the directory path as needed - if(!string.IsNullOrEmpty(fi.DirectoryName)) Directory.CreateDirectory(fi.DirectoryName); + if (!string.IsNullOrEmpty(fi.DirectoryName)) Directory.CreateDirectory(fi.DirectoryName); // Dump the script into the target file BinaryReader reader = new BinaryReader(data.Stream); @@ -260,7 +260,7 @@ namespace CodeImp.DoomBuilder.Compilers args = args.Replace("%PT", this.tempdir.FullName); args = args.Replace("%PS", sourcedir); args = args.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); //mxd. This fixes include path when the map is in a root directory - + // Setup process info ProcessStartInfo processinfo = new ProcessStartInfo(); processinfo.Arguments = args; @@ -272,24 +272,24 @@ namespace CodeImp.DoomBuilder.Compilers processinfo.WorkingDirectory = this.workingdir; CompileContext context = OnBeforeProcessStart(processinfo); - + // Output info General.WriteLogLine("Running compiler..."); General.WriteLogLine("Program: " + processinfo.FileName); General.WriteLogLine("Arguments: " + processinfo.Arguments); - + try { // Start the compiler process = Process.Start(processinfo); } - catch(Exception e) + catch (Exception e) { // Unable to start the compiler General.ShowErrorMessage("Unable to start the compiler (" + info.Name + "). " + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK); return false; } - + // Wait for compiler to complete process.WaitForExit(); TimeSpan deltatime = TimeSpan.FromTicks(process.ExitTime.Ticks - process.StartTime.Ticks); @@ -297,10 +297,10 @@ namespace CodeImp.DoomBuilder.Compilers General.WriteLogLine("Compile time: " + deltatime.TotalSeconds.ToString("########0.00") + " seconds"); OnCheckError(includes, processinfo, process, context); - + return true; } - + #endregion } } \ No newline at end of file diff --git a/Source/Core/Compilers/BccCompiler.cs b/Source/Core/Compilers/BccCompiler.cs index 7531070088cee5b92d78c5ec776d1f2d7628a331..3a5a2f70a04466d4e49d162e72cf4c4cf66b8de6 100644 --- a/Source/Core/Compilers/BccCompiler.cs +++ b/Source/Core/Compilers/BccCompiler.cs @@ -7,77 +7,77 @@ using System.IO; namespace CodeImp.DoomBuilder.Compilers { - internal class BccCompiler : AccCompiler - { - public BccCompiler(CompilerInfo info) : base(info) {} + internal class BccCompiler : AccCompiler + { + public BccCompiler(CompilerInfo info) : base(info) { } - protected override CompileContext OnBeforeProcessStart(ProcessStartInfo info) - { - info.UseShellExecute = false; - info.CreateNoWindow = true; - info.RedirectStandardError = true; - info.RedirectStandardOutput = true; - return new CompileContext(); - } + protected override CompileContext OnBeforeProcessStart(ProcessStartInfo info) + { + info.UseShellExecute = false; + info.CreateNoWindow = true; + info.RedirectStandardError = true; + info.RedirectStandardOutput = true; + return new CompileContext(); + } - protected override void OnCheckError(HashSet<string> includes, ProcessStartInfo processinfo, Process process, CompileContext context) - { - if (process.ExitCode != 0) - { - bool foundAnyErrors = false; - string[] errorLines = process.StandardOutput.ReadToEnd().Split('\n'); + protected override void OnCheckError(HashSet<string> includes, ProcessStartInfo processinfo, Process process, CompileContext context) + { + if (process.ExitCode != 0) + { + bool foundAnyErrors = false; + string[] errorLines = process.StandardOutput.ReadToEnd().Split('\n'); - foreach (string rawErrorLine in errorLines) - { - string[] rawError = rawErrorLine.Split(new char[] { ':' }, 4); - if (rawError.Length != 4) - continue; - string errorFile = rawError[0]; - int errorLine; - if (!int.TryParse(rawError[1], out errorLine)) - continue; - errorLine--; - // rawError[2] is ignored. in BCC, this contains the column at which the error happened. not supported in error viewer. - string errorContent = rawError[3].Trim(); + foreach (string rawErrorLine in errorLines) + { + string[] rawError = rawErrorLine.Split(new char[] { ':' }, 4); + if (rawError.Length != 4) + continue; + string errorFile = rawError[0]; + int errorLine; + if (!int.TryParse(rawError[1], out errorLine)) + continue; + errorLine--; + // rawError[2] is ignored. in BCC, this contains the column at which the error happened. not supported in error viewer. + string errorContent = rawError[3].Trim(); - // logic copied from AccCompiler - string temppath = this.tempdir.FullName + Path.DirectorySeparatorChar.ToString(); //mxd. Need trailing slash.. - if (errorFile.StartsWith(temppath)) errorFile = errorFile.Replace(temppath, string.Empty); + // logic copied from AccCompiler + string temppath = this.tempdir.FullName + Path.DirectorySeparatorChar.ToString(); //mxd. Need trailing slash.. + if (errorFile.StartsWith(temppath)) errorFile = errorFile.Replace(temppath, string.Empty); - if (!Path.IsPathRooted(errorFile)) - { - //mxd. If the error is in an include file, try to find it in loaded resources - if (includes.Contains(errorFile)) - { - foreach (DataReader dr in General.Map.Data.Containers) - { - if (dr is DirectoryReader && dr.FileExists(errorFile)) - { - errorFile = Path.Combine(dr.Location.location, errorFile); - break; - } - } - } - else - { - // Add working directory to filename, so it could be recognized as map namespace lump in MapManager.CompileLump() - errorFile = Path.Combine(processinfo.WorkingDirectory, errorFile); - } - } - // end logic copied from AccCompiler + if (!Path.IsPathRooted(errorFile)) + { + //mxd. If the error is in an include file, try to find it in loaded resources + if (includes.Contains(errorFile)) + { + foreach (DataReader dr in General.Map.Data.Containers) + { + if (dr is DirectoryReader && dr.FileExists(errorFile)) + { + errorFile = Path.Combine(dr.Location.location, errorFile); + break; + } + } + } + else + { + // Add working directory to filename, so it could be recognized as map namespace lump in MapManager.CompileLump() + errorFile = Path.Combine(processinfo.WorkingDirectory, errorFile); + } + } + // end logic copied from AccCompiler - CompilerError err = new CompilerError(); - err.linenumber = errorLine; - err.filename = errorFile; - err.description = errorContent; - - ReportError(err); - foundAnyErrors = true; - } + CompilerError err = new CompilerError(); + err.linenumber = errorLine; + err.filename = errorFile; + err.description = errorContent; - if (!foundAnyErrors) - ReportError(new CompilerError(string.Join(Environment.NewLine, errorLines))); - } - } - } + ReportError(err); + foundAnyErrors = true; + } + + if (!foundAnyErrors) + ReportError(new CompilerError(string.Join(Environment.NewLine, errorLines))); + } + } + } }