mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-04-26 12:30:56 +00:00
Fixed, Script Editor: in some cases includes list was not updated before trying to compile the script leading to compilation failure.
Changed, ACC compiler: when building includes list, the compiler no longer tries to find/copy include files defined in current script configuration (previously it was hardcoded to skip "zcommon.acs" and "common.acs" only). Fixed, Visual mode: things with Additive RenderStyle were rendered as additive only when their alpha was less than 1.0.
This commit is contained in:
parent
9b87dc71e3
commit
f452fca58c
7 changed files with 165 additions and 96 deletions
|
@ -66,7 +66,6 @@ namespace CodeImp.DoomBuilder.Compilers
|
||||||
// This runs the compiler
|
// This runs the compiler
|
||||||
public override bool Run()
|
public override bool Run()
|
||||||
{
|
{
|
||||||
ProcessStartInfo processinfo;
|
|
||||||
Process process;
|
Process process;
|
||||||
TimeSpan deltatime;
|
TimeSpan deltatime;
|
||||||
int line = 0;
|
int line = 0;
|
||||||
|
@ -74,24 +73,23 @@ namespace CodeImp.DoomBuilder.Compilers
|
||||||
|
|
||||||
//xabis
|
//xabis
|
||||||
// Copy includes from the resources into the compiler's folder, preserving relative pathing and naming
|
// Copy includes from the resources into the compiler's folder, preserving relative pathing and naming
|
||||||
foreach (string include in General.Map.ScriptIncludes)
|
foreach(string include in General.Map.ScriptIncludes)
|
||||||
{
|
{
|
||||||
//grab the script text from the resources
|
//grab the script text from the resources
|
||||||
MemoryStream s = General.Map.Data.LoadFile(include);
|
MemoryStream s = General.Map.Data.LoadFile(include);
|
||||||
|
|
||||||
if (s != null)
|
if(s != null)
|
||||||
{
|
{
|
||||||
//pull the pk3 or directory sub folder out if applicable
|
//pull the pk3 or directory sub folder out if applicable
|
||||||
FileInfo fi = new FileInfo(Path.Combine(this.tempdir.FullName, include));
|
FileInfo fi = new FileInfo(Path.Combine(this.tempdir.FullName, include));
|
||||||
|
|
||||||
//do not allow files to be overwritten, either accidentally or maliciously
|
//do not allow files to be overwritten, either accidentally or maliciously
|
||||||
if (!fi.Exists)
|
if(!fi.Exists)
|
||||||
{
|
{
|
||||||
General.WriteLogLine("Copying script include: " + include);
|
General.WriteLogLine("Copying script include: " + include);
|
||||||
|
|
||||||
//create the directory path as needed
|
//create the directory path as needed
|
||||||
if (fi.DirectoryName != "")
|
if(!string.IsNullOrEmpty(fi.DirectoryName)) Directory.CreateDirectory(fi.DirectoryName);
|
||||||
Directory.CreateDirectory(fi.DirectoryName);
|
|
||||||
|
|
||||||
//dump the script into the target file
|
//dump the script into the target file
|
||||||
BinaryReader reader = new BinaryReader(s);
|
BinaryReader reader = new BinaryReader(s);
|
||||||
|
@ -110,7 +108,7 @@ namespace CodeImp.DoomBuilder.Compilers
|
||||||
args = args.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); //mxd. This fixes include path when the map is in a root directory
|
args = args.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); //mxd. This fixes include path when the map is in a root directory
|
||||||
|
|
||||||
// Setup process info
|
// Setup process info
|
||||||
processinfo = new ProcessStartInfo();
|
ProcessStartInfo processinfo = new ProcessStartInfo();
|
||||||
processinfo.Arguments = args;
|
processinfo.Arguments = args;
|
||||||
//processinfo.FileName = Path.Combine(this.tempdir.FullName, info.ProgramFile);
|
//processinfo.FileName = Path.Combine(this.tempdir.FullName, info.ProgramFile);
|
||||||
processinfo.FileName = Path.Combine(info.Path, info.ProgramFile); //mxd
|
processinfo.FileName = Path.Combine(info.Path, info.ProgramFile); //mxd
|
||||||
|
|
|
@ -425,10 +425,12 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
navigator.Items.Clear();
|
navigator.Items.Clear();
|
||||||
|
|
||||||
AcsParserSE parser = new AcsParserSE();
|
AcsParserSE parser = new AcsParserSE();
|
||||||
parser.Parse(stream, "ACS");
|
if(parser.Parse(stream, "ACS"))
|
||||||
navigator.Items.AddRange(parser.NamedScripts.ToArray());
|
{
|
||||||
navigator.Items.AddRange(parser.NumberedScripts.ToArray());
|
navigator.Items.AddRange(parser.NamedScripts.ToArray());
|
||||||
navigator.Items.AddRange(parser.Functions.ToArray());
|
navigator.Items.AddRange(parser.NumberedScripts.ToArray());
|
||||||
|
navigator.Items.AddRange(parser.Functions.ToArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
|
|
|
@ -22,7 +22,6 @@ using System.Windows.Forms;
|
||||||
using CodeImp.DoomBuilder.Config;
|
using CodeImp.DoomBuilder.Config;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using CodeImp.DoomBuilder.Compilers;
|
using CodeImp.DoomBuilder.Compilers;
|
||||||
using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -72,12 +71,19 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
// This compiles the script file
|
// This compiles the script file
|
||||||
public override void Compile()
|
public override void Compile()
|
||||||
{
|
{
|
||||||
string inputfile, outputfile;
|
//mxd. List of errors. UpdateScriptNames can return errors and also updates acs includes list
|
||||||
|
List<CompilerError> errors = (config.ScriptType == ScriptType.ACS ? General.Map.UpdateScriptNames() : new List<CompilerError>());
|
||||||
|
|
||||||
|
//mxd. Errors already?..
|
||||||
|
if(errors.Count > 0)
|
||||||
|
{
|
||||||
|
// Feed errors to panel
|
||||||
|
panel.ShowErrors(errors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Compiler compiler;
|
Compiler compiler;
|
||||||
|
|
||||||
// List of errors
|
|
||||||
List<CompilerError> errors = new List<CompilerError>();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Initialize compiler
|
// Initialize compiler
|
||||||
|
@ -91,11 +97,11 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the source file into the temporary directory
|
// Copy the source file into the temporary directory
|
||||||
inputfile = Path.Combine(compiler.Location, Path.GetFileName(filepathname));
|
string inputfile = Path.Combine(compiler.Location, Path.GetFileName(filepathname));
|
||||||
File.Copy(filepathname, inputfile);
|
File.Copy(filepathname, inputfile);
|
||||||
|
|
||||||
// Make random output filename
|
// Make random output filename
|
||||||
outputfile = General.MakeTempFilename(compiler.Location, "tmp");
|
string outputfile = General.MakeTempFilename(compiler.Location, "tmp");
|
||||||
|
|
||||||
// Run compiler
|
// Run compiler
|
||||||
compiler.Parameters = config.Parameters;
|
compiler.Parameters = config.Parameters;
|
||||||
|
@ -117,15 +123,13 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
|
|
||||||
errors.Add(newerr);
|
errors.Add(newerr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd. Should be called only if current script is compiled successfully
|
|
||||||
if (compiler.Errors.Length == 0 && config.ScriptType == ScriptType.ACS)
|
|
||||||
General.Map.UpdateScriptNames();
|
|
||||||
UpdateNavigator();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispose compiler
|
// Dispose compiler
|
||||||
compiler.Dispose();
|
compiler.Dispose();
|
||||||
|
|
||||||
|
//mxd. Update script navigator
|
||||||
|
UpdateNavigator();
|
||||||
|
|
||||||
// Feed errors to panel
|
// Feed errors to panel
|
||||||
panel.ShowErrors(errors);
|
panel.ShowErrors(errors);
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
|
|
||||||
#region ================== Namespaces
|
#region ================== Namespaces
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using CodeImp.DoomBuilder.Config;
|
using CodeImp.DoomBuilder.Config;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using CodeImp.DoomBuilder.Compilers;
|
using CodeImp.DoomBuilder.Compilers;
|
||||||
using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
|
|
||||||
#region ================== Variables
|
#region ================== Variables
|
||||||
|
|
||||||
private string lumpname;
|
private readonly string lumpname;
|
||||||
private bool ismapheader;
|
private readonly bool ismapheader;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -87,16 +87,21 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
// Compile script
|
// Compile script
|
||||||
public override void Compile()
|
public override void Compile()
|
||||||
{
|
{
|
||||||
bool success; //mxd
|
//mxd. List of errors. UpdateScriptNames can return errors and also updates acs includes list
|
||||||
|
List<CompilerError> errors = (config.ScriptType == ScriptType.ACS ? General.Map.UpdateScriptNames() : new List<CompilerError>());
|
||||||
|
|
||||||
|
//mxd. Errors already?..
|
||||||
|
if(errors.Count > 0)
|
||||||
|
{
|
||||||
|
// Feed errors to panel
|
||||||
|
panel.ShowErrors(errors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Compile
|
// Compile
|
||||||
if(ismapheader)
|
General.Map.CompileLump((ismapheader ? MapManager.CONFIG_MAP_HEADER : lumpname), true);
|
||||||
success = General.Map.CompileLump(MapManager.CONFIG_MAP_HEADER, true);
|
|
||||||
else
|
//mxd. Update script navigator
|
||||||
success = General.Map.CompileLump(lumpname, true);
|
|
||||||
|
|
||||||
//mxd. Update script names cache and script navigator
|
|
||||||
if(success && config.ScriptType == ScriptType.ACS) General.Map.UpdateScriptNames();
|
|
||||||
UpdateNavigator();
|
UpdateNavigator();
|
||||||
|
|
||||||
// Feed errors to panel
|
// Feed errors to panel
|
||||||
|
|
|
@ -12,8 +12,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
internal delegate void IncludeDelegate(AcsParserSE parser, string includefile);
|
internal delegate void IncludeDelegate(AcsParserSE parser, string includefile);
|
||||||
internal IncludeDelegate OnInclude;
|
internal IncludeDelegate OnInclude;
|
||||||
|
|
||||||
private readonly List<string> parsedlumps;
|
private readonly HashSet<string> parsedlumps;
|
||||||
private readonly List<string> includes;
|
private readonly HashSet<string> includes;
|
||||||
|
private List<string> includestoskip;
|
||||||
|
|
||||||
private readonly List<ScriptItem> namedscripts;
|
private readonly List<ScriptItem> namedscripts;
|
||||||
private readonly List<ScriptItem> numberedscripts;
|
private readonly List<ScriptItem> numberedscripts;
|
||||||
|
@ -29,24 +30,37 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
namedscripts = new List<ScriptItem>();
|
namedscripts = new List<ScriptItem>();
|
||||||
numberedscripts = new List<ScriptItem>();
|
numberedscripts = new List<ScriptItem>();
|
||||||
functions = new List<ScriptItem>();
|
functions = new List<ScriptItem>();
|
||||||
parsedlumps = new List<string>();
|
parsedlumps = new HashSet<string>();
|
||||||
includes = new List<string>();
|
includes = new HashSet<string>();
|
||||||
|
includestoskip = new List<string>();
|
||||||
specialtokens += "(,)";
|
specialtokens += "(,)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename)
|
||||||
{
|
{
|
||||||
return Parse(stream, sourcefilename, false, false);
|
return Parse(stream, sourcefilename, new List<string>(), false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Parse(Stream stream, string sourcefilename, bool processincludes, bool isinclude)
|
public bool Parse(Stream stream, string sourcefilename, bool processincludes, bool isinclude)
|
||||||
{
|
{
|
||||||
|
return Parse(stream, sourcefilename, includestoskip, processincludes, isinclude);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Parse(Stream stream, string sourcefilename, List<string> configincludes, bool processincludes, bool isinclude)
|
||||||
|
{
|
||||||
|
if(stream == null || stream.Length == 0)
|
||||||
|
{
|
||||||
|
ReportError("Unable to load " + (isinclude ? "include" : "") + " file '" + sourcefilename + "'!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
base.Parse(stream, sourcefilename);
|
base.Parse(stream, sourcefilename);
|
||||||
|
|
||||||
//already parsed this?
|
// Already parsed this?
|
||||||
if (parsedlumps.Contains(sourcefilename)) return false;
|
if(parsedlumps.Contains(sourcefilename)) return false;
|
||||||
parsedlumps.Add(sourcefilename);
|
parsedlumps.Add(sourcefilename);
|
||||||
if (isinclude) includes.Add(sourcefilename);
|
if(isinclude && !includes.Contains(sourcefilename)) includes.Add(sourcefilename);
|
||||||
|
includestoskip = configincludes;
|
||||||
int bracelevel = 0;
|
int bracelevel = 0;
|
||||||
|
|
||||||
// Keep local data
|
// Keep local data
|
||||||
|
@ -55,7 +69,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
BinaryReader localreader = datareader;
|
BinaryReader localreader = datareader;
|
||||||
|
|
||||||
// Continue until at the end of the stream
|
// Continue until at the end of the stream
|
||||||
while (SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
{
|
{
|
||||||
string token = ReadToken();
|
string token = ReadToken();
|
||||||
if(string.IsNullOrEmpty(token)) continue;
|
if(string.IsNullOrEmpty(token)) continue;
|
||||||
|
@ -65,7 +79,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
if(token == "}") { bracelevel--; continue; }
|
if(token == "}") { bracelevel--; continue; }
|
||||||
if(bracelevel > 0) continue;
|
if(bracelevel > 0) continue;
|
||||||
|
|
||||||
switch (token.ToLowerInvariant())
|
switch(token.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
case "script":
|
case "script":
|
||||||
{
|
{
|
||||||
|
@ -74,7 +88,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
token = ReadToken();
|
token = ReadToken();
|
||||||
|
|
||||||
//is it named script?
|
//is it named script?
|
||||||
if (token.IndexOf('"') != -1)
|
if(token.IndexOf('"') != -1)
|
||||||
{
|
{
|
||||||
startpos += 1;
|
startpos += 1;
|
||||||
string scriptname = StripTokenQuotes(token);
|
string scriptname = StripTokenQuotes(token);
|
||||||
|
@ -90,7 +104,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
else //should be numbered script
|
else //should be numbered script
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
if (int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out n))
|
if(int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out n))
|
||||||
{
|
{
|
||||||
// Try to parse argument names
|
// Try to parse argument names
|
||||||
List<KeyValuePair<string, string>> args = ParseArgs();
|
List<KeyValuePair<string, string>> args = ParseArgs();
|
||||||
|
@ -106,10 +120,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
string name = "";
|
string name = "";
|
||||||
bracelevel = 1;
|
bracelevel = 1;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(token))
|
if(!string.IsNullOrEmpty(token))
|
||||||
{
|
{
|
||||||
int commentstart = token.IndexOf("//");
|
int commentstart = token.IndexOf("//");
|
||||||
if (commentstart != -1) //found comment
|
if(commentstart != -1) //found comment
|
||||||
{
|
{
|
||||||
commentstart += 2;
|
commentstart += 2;
|
||||||
name = token.Substring(commentstart, token.Length - commentstart).Trim();
|
name = token.Substring(commentstart, token.Length - commentstart).Trim();
|
||||||
|
@ -148,20 +162,18 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (processincludes && (token == "#include" || token == "#import"))
|
if(processincludes && (token == "#include" || token == "#import"))
|
||||||
{
|
{
|
||||||
SkipWhitespace(true);
|
SkipWhitespace(true);
|
||||||
string includelump = StripTokenQuotes(ReadToken()).ToLowerInvariant();
|
string includelump = StripTokenQuotes(ReadToken()).ToLowerInvariant();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(includelump))
|
if(!string.IsNullOrEmpty(includelump))
|
||||||
{
|
{
|
||||||
string includename = Path.GetFileName(includelump);
|
string includename = Path.GetFileName(includelump);
|
||||||
|
if(includestoskip.Contains(includename) || includes.Contains(includename)) continue;
|
||||||
if (includename == "zcommon.acs" || includename == "common.acs" || includes.Contains(includename))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Callback to parse this file
|
// Callback to parse this file
|
||||||
if (OnInclude != null) OnInclude(this, includelump.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar));
|
if(OnInclude != null) OnInclude(this, includelump.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar));
|
||||||
|
|
||||||
// Set our buffers back to continue parsing
|
// Set our buffers back to continue parsing
|
||||||
datastream = localstream;
|
datastream = localstream;
|
||||||
|
@ -170,7 +182,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
General.ErrorLogger.Add(ErrorType.Error, "Error in '" + sourcefilename + "' at line " + GetCurrentLineNumber() + ": got #include directive without include path!");
|
ReportError("Error in '" + sourcefilename + "' at line " + GetCurrentLineNumber() + ": got #include directive without include path!");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace CodeImp.DoomBuilder
|
||||||
//mxd
|
//mxd
|
||||||
private Dictionary<string, ScriptItem> namedscripts;
|
private Dictionary<string, ScriptItem> namedscripts;
|
||||||
private Dictionary<int, ScriptItem> numberedscripts;
|
private Dictionary<int, ScriptItem> numberedscripts;
|
||||||
private List<string> scriptincludes;
|
private readonly HashSet<string> scriptincludes;
|
||||||
|
|
||||||
// Disposing
|
// Disposing
|
||||||
private bool isdisposed;
|
private bool isdisposed;
|
||||||
|
@ -130,7 +130,7 @@ namespace CodeImp.DoomBuilder
|
||||||
//mxd. Scripts
|
//mxd. Scripts
|
||||||
internal Dictionary<string, ScriptItem> NamedScripts { get { return namedscripts; } }
|
internal Dictionary<string, ScriptItem> NamedScripts { get { return namedscripts; } }
|
||||||
internal Dictionary<int, ScriptItem> NumberedScripts { get { return numberedscripts; } }
|
internal Dictionary<int, ScriptItem> NumberedScripts { get { return numberedscripts; } }
|
||||||
internal List<string> ScriptIncludes { get { return scriptincludes; } }
|
internal HashSet<string> ScriptIncludes { get { return scriptincludes; } }
|
||||||
|
|
||||||
public ViewMode ViewMode { get { return renderer2d.ViewMode; } }
|
public ViewMode ViewMode { get { return renderer2d.ViewMode; } }
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ namespace CodeImp.DoomBuilder
|
||||||
//mxd
|
//mxd
|
||||||
numberedscripts = new Dictionary<int, ScriptItem>();
|
numberedscripts = new Dictionary<int, ScriptItem>();
|
||||||
namedscripts = new Dictionary<string, ScriptItem>();
|
namedscripts = new Dictionary<string, ScriptItem>();
|
||||||
scriptincludes = new List<string>();
|
scriptincludes = new HashSet<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disposer
|
// Disposer
|
||||||
|
@ -437,8 +437,8 @@ namespace CodeImp.DoomBuilder
|
||||||
map.Update();
|
map.Update();
|
||||||
thingsfilter.Update();
|
thingsfilter.Update();
|
||||||
|
|
||||||
//mxd. check script names
|
//mxd. Update includes list and script names
|
||||||
UpdateScriptNames();
|
UpdateScriptNames(true);
|
||||||
|
|
||||||
//mxd. Restore selection groups
|
//mxd. Restore selection groups
|
||||||
options.ReadSelectionGroups();
|
options.ReadSelectionGroups();
|
||||||
|
@ -527,8 +527,8 @@ namespace CodeImp.DoomBuilder
|
||||||
//mxd. Sector textures may've been changed
|
//mxd. Sector textures may've been changed
|
||||||
data.UpdateUsedTextures();
|
data.UpdateUsedTextures();
|
||||||
|
|
||||||
//mxd. check script names
|
//mxd. Update includes list and script names
|
||||||
UpdateScriptNames();
|
UpdateScriptNames(true);
|
||||||
|
|
||||||
//mxd. Restore selection groups
|
//mxd. Restore selection groups
|
||||||
options.ReadSelectionGroups();
|
options.ReadSelectionGroups();
|
||||||
|
@ -1746,7 +1746,7 @@ namespace CodeImp.DoomBuilder
|
||||||
{
|
{
|
||||||
scriptconfig = config.MapLumps[lumpname].Script;
|
scriptconfig = config.MapLumps[lumpname].Script;
|
||||||
}
|
}
|
||||||
if (scriptconfig.Compiler == null) return true;
|
if(scriptconfig.Compiler == null) return true;
|
||||||
|
|
||||||
// Find the lump
|
// Find the lump
|
||||||
if(lumpname == CONFIG_MAP_HEADER) reallumpname = TEMP_MAP_HEADER;
|
if(lumpname == CONFIG_MAP_HEADER) reallumpname = TEMP_MAP_HEADER;
|
||||||
|
@ -1757,7 +1757,7 @@ namespace CodeImp.DoomBuilder
|
||||||
string sourcefile = (filepathname.Length > 0 ? filepathname : tempwad.Filename);
|
string sourcefile = (filepathname.Length > 0 ? filepathname : tempwad.Filename);
|
||||||
|
|
||||||
// New list of errors
|
// New list of errors
|
||||||
if (clearerrors) errors.Clear();
|
if(clearerrors) errors.Clear();
|
||||||
|
|
||||||
// Determine the script configuration to use
|
// Determine the script configuration to use
|
||||||
try
|
try
|
||||||
|
@ -1862,11 +1862,29 @@ namespace CodeImp.DoomBuilder
|
||||||
errors.Clear();
|
errors.Clear();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
//mxd
|
//mxd. Update includes list and script names
|
||||||
internal void UpdateScriptNames()
|
internal List<CompilerError> UpdateScriptNames(bool logerrors)
|
||||||
|
{
|
||||||
|
List<CompilerError> compilererrors = UpdateScriptNames();
|
||||||
|
if(logerrors && compilererrors.Count > 0)
|
||||||
|
{
|
||||||
|
foreach(CompilerError error in compilererrors)
|
||||||
|
{
|
||||||
|
General.ErrorLogger.Add(ErrorType.Error, "ACS error in '" + error.filename
|
||||||
|
+ "', line " + error.linenumber + ". " + error.description + ".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return compilererrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
//mxd. Update includes list and script names
|
||||||
|
internal List<CompilerError> UpdateScriptNames()
|
||||||
{
|
{
|
||||||
List<ScriptItem> namedscriptslist = new List<ScriptItem>();
|
List<ScriptItem> namedscriptslist = new List<ScriptItem>();
|
||||||
List<ScriptItem> numberedscriptslist = new List<ScriptItem>();
|
List<ScriptItem> numberedscriptslist = new List<ScriptItem>();
|
||||||
|
List<string> scripincludeslist = new List<string>();
|
||||||
|
List<CompilerError> compilererrors = new List<CompilerError>();
|
||||||
|
|
||||||
// Load the script lumps
|
// Load the script lumps
|
||||||
foreach(MapLumpInfo maplumpinfo in config.MapLumps.Values)
|
foreach(MapLumpInfo maplumpinfo in config.MapLumps.Values)
|
||||||
|
@ -1874,48 +1892,78 @@ namespace CodeImp.DoomBuilder
|
||||||
// Is this a script lump?
|
// Is this a script lump?
|
||||||
if((maplumpinfo.ScriptBuild || maplumpinfo.Script != null) && maplumpinfo.Name == "SCRIPTS")
|
if((maplumpinfo.ScriptBuild || maplumpinfo.Script != null) && maplumpinfo.Name == "SCRIPTS")
|
||||||
{
|
{
|
||||||
|
ScriptConfiguration scriptconfig;
|
||||||
|
if(maplumpinfo.ScriptBuild)
|
||||||
|
{
|
||||||
|
//mxd. More boilderplate
|
||||||
|
if(!General.CompiledScriptConfigs.ContainsKey(General.Map.Options.ScriptCompiler))
|
||||||
|
{
|
||||||
|
compilererrors.Add(new CompilerError("Unable to compile lump '" + maplumpinfo.Name + "'. Unable to find required script compiler configuration ('" + General.Map.Options.ScriptCompiler + "')."));
|
||||||
|
return compilererrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptconfig = General.CompiledScriptConfigs[General.Map.Options.ScriptCompiler];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scriptconfig = maplumpinfo.Script;
|
||||||
|
}
|
||||||
|
|
||||||
// Load the lump data
|
// Load the lump data
|
||||||
MemoryStream stream = GetLumpData(maplumpinfo.Name);
|
MemoryStream stream = GetLumpData(maplumpinfo.Name);
|
||||||
if(stream != null)
|
if(stream != null && scriptconfig != null && scriptconfig.Compiler != null)
|
||||||
{
|
{
|
||||||
// Get script names
|
// Get script names
|
||||||
AcsParserSE parser = new AcsParserSE();
|
AcsParserSE parser = new AcsParserSE { OnInclude = UpdateScriptsFromLocation };
|
||||||
parser.OnInclude = UpdateScriptsFromLocation;
|
if(parser.Parse(stream, "SCRIPTS", scriptconfig.Compiler.Files, true, false))
|
||||||
parser.Parse(stream, "SCRIPTS", true, false);
|
{
|
||||||
|
// Add them to arrays
|
||||||
// Add them to arrays
|
namedscriptslist.AddRange(parser.NamedScripts);
|
||||||
namedscriptslist.AddRange(parser.NamedScripts);
|
numberedscriptslist.AddRange(parser.NumberedScripts);
|
||||||
numberedscriptslist.AddRange(parser.NumberedScripts);
|
scripincludeslist.AddRange(parser.Includes);
|
||||||
scriptincludes.AddRange(parser.Includes);
|
}
|
||||||
|
// Check for errors
|
||||||
|
else if(parser.HasError)
|
||||||
|
{
|
||||||
|
compilererrors.Add(new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort script names
|
|
||||||
namedscriptslist.Sort(ScriptItem.SortByName);
|
|
||||||
numberedscriptslist.Sort(ScriptItem.SortByIndex);
|
|
||||||
|
|
||||||
// Add to collections
|
// Add to collections
|
||||||
namedscripts = new Dictionary<string, ScriptItem>(namedscriptslist.Count);
|
scriptincludes.Clear();
|
||||||
numberedscripts = new Dictionary<int, ScriptItem>(numberedscriptslist.Count);
|
if(compilererrors.Count == 0)
|
||||||
|
{
|
||||||
|
namedscripts = new Dictionary<string, ScriptItem>(namedscriptslist.Count);
|
||||||
|
numberedscripts = new Dictionary<int, ScriptItem>(numberedscriptslist.Count);
|
||||||
|
|
||||||
foreach (ScriptItem item in namedscriptslist)
|
// Sort script names
|
||||||
{
|
namedscriptslist.Sort(ScriptItem.SortByName);
|
||||||
if(!namedscripts.ContainsKey(item.Name.ToLowerInvariant()))
|
numberedscriptslist.Sort(ScriptItem.SortByIndex);
|
||||||
namedscripts.Add(item.Name.ToLowerInvariant(), item);
|
|
||||||
|
foreach(ScriptItem item in namedscriptslist)
|
||||||
|
if(!namedscripts.ContainsKey(item.Name.ToLowerInvariant())) namedscripts.Add(item.Name.ToLowerInvariant(), item);
|
||||||
|
foreach(ScriptItem item in numberedscriptslist)
|
||||||
|
if(!numberedscripts.ContainsKey(item.Index)) numberedscripts.Add(item.Index, item);
|
||||||
|
foreach(string include in scripincludeslist)
|
||||||
|
if(!scriptincludes.Contains(include)) scriptincludes.Add(include);
|
||||||
}
|
}
|
||||||
foreach(ScriptItem item in numberedscriptslist)
|
else
|
||||||
{
|
{
|
||||||
if(!numberedscripts.ContainsKey(item.Index))
|
// Clear collections
|
||||||
numberedscripts.Add(item.Index, item);
|
namedscripts.Clear();
|
||||||
|
numberedscripts.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return compilererrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
private static void UpdateScriptsFromLocation(AcsParserSE parser, string path)
|
private static void UpdateScriptsFromLocation(AcsParserSE parser, string path)
|
||||||
{
|
{
|
||||||
MemoryStream s = General.Map.Data.LoadFile(path);
|
parser.Parse(General.Map.Data.LoadFile(path), path, true, true);
|
||||||
if(s != null && s.Length > 0) parser.Parse(s, path, true, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -2071,8 +2119,8 @@ namespace CodeImp.DoomBuilder
|
||||||
General.MainWindow.DisplayStatus(oldstatus);
|
General.MainWindow.DisplayStatus(oldstatus);
|
||||||
Cursor.Current = oldcursor;
|
Cursor.Current = oldcursor;
|
||||||
|
|
||||||
//mxd
|
//mxd. Update includes list and script names
|
||||||
UpdateScriptNames();
|
UpdateScriptNames(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Game Configuration action
|
// Game Configuration action
|
||||||
|
@ -2146,7 +2194,6 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// Reload resources
|
// Reload resources
|
||||||
ReloadResources();
|
ReloadResources();
|
||||||
UpdateScriptNames(); //mxd
|
|
||||||
|
|
||||||
//mxd. Translate texture names
|
//mxd. Translate texture names
|
||||||
bool nameschanged = map.TranslateTextureNames(config.UseLongTextureNames, false);
|
bool nameschanged = map.TranslateTextureNames(config.UseLongTextureNames, false);
|
||||||
|
|
|
@ -165,8 +165,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't bother when alpha is unchanged
|
// Don't bother when alpha is unchanged, unless Additive RenderStyle is used
|
||||||
if(alpha == 255) RenderPass = RenderPass.Mask;
|
if(RenderPass != RenderPass.Additive && alpha == 255) RenderPass = RenderPass.Mask;
|
||||||
|
|
||||||
int sectorcolor = new PixelColor(alpha, 255, 255, 255).ToInt();
|
int sectorcolor = new PixelColor(alpha, 255, 255, 255).ToInt();
|
||||||
fogfactor = 0f; //mxd
|
fogfactor = 0f; //mxd
|
||||||
|
|
Loading…
Reference in a new issue