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
|
||||
public override bool Run()
|
||||
{
|
||||
ProcessStartInfo processinfo;
|
||||
Process process;
|
||||
TimeSpan deltatime;
|
||||
int line = 0;
|
||||
|
@ -90,8 +89,7 @@ namespace CodeImp.DoomBuilder.Compilers
|
|||
General.WriteLogLine("Copying script include: " + include);
|
||||
|
||||
//create the directory path as needed
|
||||
if (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(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
|
||||
|
||||
// Setup process info
|
||||
processinfo = new ProcessStartInfo();
|
||||
ProcessStartInfo processinfo = new ProcessStartInfo();
|
||||
processinfo.Arguments = args;
|
||||
//processinfo.FileName = Path.Combine(this.tempdir.FullName, info.ProgramFile);
|
||||
processinfo.FileName = Path.Combine(info.Path, info.ProgramFile); //mxd
|
||||
|
|
|
@ -425,11 +425,13 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
navigator.Items.Clear();
|
||||
|
||||
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.Functions.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
internal ScriptType VerifyScriptType()
|
||||
|
|
|
@ -22,7 +22,6 @@ using System.Windows.Forms;
|
|||
using CodeImp.DoomBuilder.Config;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Compilers;
|
||||
using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -72,11 +71,18 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// This compiles the script file
|
||||
public override void Compile()
|
||||
{
|
||||
string inputfile, outputfile;
|
||||
Compiler compiler;
|
||||
//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>());
|
||||
|
||||
// List of errors
|
||||
List<CompilerError> errors = new List<CompilerError>();
|
||||
//mxd. Errors already?..
|
||||
if(errors.Count > 0)
|
||||
{
|
||||
// Feed errors to panel
|
||||
panel.ShowErrors(errors);
|
||||
return;
|
||||
}
|
||||
|
||||
Compiler compiler;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -91,11 +97,11 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// Make random output filename
|
||||
outputfile = General.MakeTempFilename(compiler.Location, "tmp");
|
||||
string outputfile = General.MakeTempFilename(compiler.Location, "tmp");
|
||||
|
||||
// Run compiler
|
||||
compiler.Parameters = config.Parameters;
|
||||
|
@ -117,16 +123,14 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
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
|
||||
compiler.Dispose();
|
||||
|
||||
//mxd. Update script navigator
|
||||
UpdateNavigator();
|
||||
|
||||
// Feed errors to panel
|
||||
panel.ShowErrors(errors);
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System.Collections.Generic;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Compilers;
|
||||
using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -33,8 +33,8 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
#region ================== Variables
|
||||
|
||||
private string lumpname;
|
||||
private bool ismapheader;
|
||||
private readonly string lumpname;
|
||||
private readonly bool ismapheader;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -87,16 +87,21 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// Compile script
|
||||
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
|
||||
if(ismapheader)
|
||||
success = General.Map.CompileLump(MapManager.CONFIG_MAP_HEADER, true);
|
||||
else
|
||||
success = General.Map.CompileLump(lumpname, true);
|
||||
General.Map.CompileLump((ismapheader ? MapManager.CONFIG_MAP_HEADER : lumpname), true);
|
||||
|
||||
//mxd. Update script names cache and script navigator
|
||||
if(success && config.ScriptType == ScriptType.ACS) General.Map.UpdateScriptNames();
|
||||
//mxd. Update script navigator
|
||||
UpdateNavigator();
|
||||
|
||||
// Feed errors to panel
|
||||
|
|
|
@ -12,8 +12,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
internal delegate void IncludeDelegate(AcsParserSE parser, string includefile);
|
||||
internal IncludeDelegate OnInclude;
|
||||
|
||||
private readonly List<string> parsedlumps;
|
||||
private readonly List<string> includes;
|
||||
private readonly HashSet<string> parsedlumps;
|
||||
private readonly HashSet<string> includes;
|
||||
private List<string> includestoskip;
|
||||
|
||||
private readonly List<ScriptItem> namedscripts;
|
||||
private readonly List<ScriptItem> numberedscripts;
|
||||
|
@ -29,24 +30,37 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
namedscripts = new List<ScriptItem>();
|
||||
numberedscripts = new List<ScriptItem>();
|
||||
functions = new List<ScriptItem>();
|
||||
parsedlumps = new List<string>();
|
||||
includes = new List<string>();
|
||||
parsedlumps = new HashSet<string>();
|
||||
includes = new HashSet<string>();
|
||||
includestoskip = new List<string>();
|
||||
specialtokens += "(,)";
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
//already parsed this?
|
||||
// Already parsed this?
|
||||
if(parsedlumps.Contains(sourcefilename)) return false;
|
||||
parsedlumps.Add(sourcefilename);
|
||||
if (isinclude) includes.Add(sourcefilename);
|
||||
if(isinclude && !includes.Contains(sourcefilename)) includes.Add(sourcefilename);
|
||||
includestoskip = configincludes;
|
||||
int bracelevel = 0;
|
||||
|
||||
// Keep local data
|
||||
|
@ -156,9 +170,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
if(!string.IsNullOrEmpty(includelump))
|
||||
{
|
||||
string includename = Path.GetFileName(includelump);
|
||||
|
||||
if (includename == "zcommon.acs" || includename == "common.acs" || includes.Contains(includename))
|
||||
continue;
|
||||
if(includestoskip.Contains(includename) || includes.Contains(includename)) continue;
|
||||
|
||||
// Callback to parse this file
|
||||
if(OnInclude != null) OnInclude(this, includelump.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar));
|
||||
|
@ -170,7 +182,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
}
|
||||
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;
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace CodeImp.DoomBuilder
|
|||
//mxd
|
||||
private Dictionary<string, ScriptItem> namedscripts;
|
||||
private Dictionary<int, ScriptItem> numberedscripts;
|
||||
private List<string> scriptincludes;
|
||||
private readonly HashSet<string> scriptincludes;
|
||||
|
||||
// Disposing
|
||||
private bool isdisposed;
|
||||
|
@ -130,7 +130,7 @@ namespace CodeImp.DoomBuilder
|
|||
//mxd. Scripts
|
||||
internal Dictionary<string, ScriptItem> NamedScripts { get { return namedscripts; } }
|
||||
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; } }
|
||||
|
||||
|
@ -160,7 +160,7 @@ namespace CodeImp.DoomBuilder
|
|||
//mxd
|
||||
numberedscripts = new Dictionary<int, ScriptItem>();
|
||||
namedscripts = new Dictionary<string, ScriptItem>();
|
||||
scriptincludes = new List<string>();
|
||||
scriptincludes = new HashSet<string>();
|
||||
}
|
||||
|
||||
// Disposer
|
||||
|
@ -437,8 +437,8 @@ namespace CodeImp.DoomBuilder
|
|||
map.Update();
|
||||
thingsfilter.Update();
|
||||
|
||||
//mxd. check script names
|
||||
UpdateScriptNames();
|
||||
//mxd. Update includes list and script names
|
||||
UpdateScriptNames(true);
|
||||
|
||||
//mxd. Restore selection groups
|
||||
options.ReadSelectionGroups();
|
||||
|
@ -527,8 +527,8 @@ namespace CodeImp.DoomBuilder
|
|||
//mxd. Sector textures may've been changed
|
||||
data.UpdateUsedTextures();
|
||||
|
||||
//mxd. check script names
|
||||
UpdateScriptNames();
|
||||
//mxd. Update includes list and script names
|
||||
UpdateScriptNames(true);
|
||||
|
||||
//mxd. Restore selection groups
|
||||
options.ReadSelectionGroups();
|
||||
|
@ -1862,11 +1862,29 @@ namespace CodeImp.DoomBuilder
|
|||
errors.Clear();
|
||||
}*/
|
||||
|
||||
//mxd
|
||||
internal void UpdateScriptNames()
|
||||
//mxd. Update includes list and script names
|
||||
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> numberedscriptslist = new List<ScriptItem>();
|
||||
List<string> scripincludeslist = new List<string>();
|
||||
List<CompilerError> compilererrors = new List<CompilerError>();
|
||||
|
||||
// Load the script lumps
|
||||
foreach(MapLumpInfo maplumpinfo in config.MapLumps.Values)
|
||||
|
@ -1874,48 +1892,78 @@ namespace CodeImp.DoomBuilder
|
|||
// Is this a script lump?
|
||||
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
|
||||
MemoryStream stream = GetLumpData(maplumpinfo.Name);
|
||||
if(stream != null)
|
||||
if(stream != null && scriptconfig != null && scriptconfig.Compiler != null)
|
||||
{
|
||||
// Get script names
|
||||
AcsParserSE parser = new AcsParserSE();
|
||||
parser.OnInclude = UpdateScriptsFromLocation;
|
||||
parser.Parse(stream, "SCRIPTS", true, false);
|
||||
|
||||
AcsParserSE parser = new AcsParserSE { OnInclude = UpdateScriptsFromLocation };
|
||||
if(parser.Parse(stream, "SCRIPTS", scriptconfig.Compiler.Files, true, false))
|
||||
{
|
||||
// Add them to arrays
|
||||
namedscriptslist.AddRange(parser.NamedScripts);
|
||||
numberedscriptslist.AddRange(parser.NumberedScripts);
|
||||
scriptincludes.AddRange(parser.Includes);
|
||||
scripincludeslist.AddRange(parser.Includes);
|
||||
}
|
||||
// Check for errors
|
||||
else if(parser.HasError)
|
||||
{
|
||||
compilererrors.Add(new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add to collections
|
||||
scriptincludes.Clear();
|
||||
if(compilererrors.Count == 0)
|
||||
{
|
||||
namedscripts = new Dictionary<string, ScriptItem>(namedscriptslist.Count);
|
||||
numberedscripts = new Dictionary<int, ScriptItem>(numberedscriptslist.Count);
|
||||
|
||||
// Sort script names
|
||||
namedscriptslist.Sort(ScriptItem.SortByName);
|
||||
numberedscriptslist.Sort(ScriptItem.SortByIndex);
|
||||
|
||||
// Add to collections
|
||||
namedscripts = new Dictionary<string, ScriptItem>(namedscriptslist.Count);
|
||||
numberedscripts = new Dictionary<int, ScriptItem>(numberedscriptslist.Count);
|
||||
|
||||
foreach(ScriptItem item in namedscriptslist)
|
||||
{
|
||||
if(!namedscripts.ContainsKey(item.Name.ToLowerInvariant()))
|
||||
namedscripts.Add(item.Name.ToLowerInvariant(), item);
|
||||
}
|
||||
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);
|
||||
if(!numberedscripts.ContainsKey(item.Index)) numberedscripts.Add(item.Index, item);
|
||||
foreach(string include in scripincludeslist)
|
||||
if(!scriptincludes.Contains(include)) scriptincludes.Add(include);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear collections
|
||||
namedscripts.Clear();
|
||||
numberedscripts.Clear();
|
||||
}
|
||||
|
||||
return compilererrors;
|
||||
}
|
||||
|
||||
//mxd
|
||||
private static void UpdateScriptsFromLocation(AcsParserSE parser, string path)
|
||||
{
|
||||
MemoryStream s = General.Map.Data.LoadFile(path);
|
||||
if(s != null && s.Length > 0) parser.Parse(s, path, true, true);
|
||||
parser.Parse(General.Map.Data.LoadFile(path), path, true, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -2071,8 +2119,8 @@ namespace CodeImp.DoomBuilder
|
|||
General.MainWindow.DisplayStatus(oldstatus);
|
||||
Cursor.Current = oldcursor;
|
||||
|
||||
//mxd
|
||||
UpdateScriptNames();
|
||||
//mxd. Update includes list and script names
|
||||
UpdateScriptNames(true);
|
||||
}
|
||||
|
||||
// Game Configuration action
|
||||
|
@ -2146,7 +2194,6 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Reload resources
|
||||
ReloadResources();
|
||||
UpdateScriptNames(); //mxd
|
||||
|
||||
//mxd. Translate texture names
|
||||
bool nameschanged = map.TranslateTextureNames(config.UseLongTextureNames, false);
|
||||
|
|
|
@ -165,8 +165,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// Don't bother when alpha is unchanged
|
||||
if(alpha == 255) RenderPass = RenderPass.Mask;
|
||||
// Don't bother when alpha is unchanged, unless Additive RenderStyle is used
|
||||
if(RenderPass != RenderPass.Additive && alpha == 255) RenderPass = RenderPass.Mask;
|
||||
|
||||
int sectorcolor = new PixelColor(alpha, 255, 255, 255).ToInt();
|
||||
fogfactor = 0f; //mxd
|
||||
|
|
Loading…
Reference in a new issue