UltimateZoneBuilder/Source/Plugins/BuilderModes/ErrorChecks/CheckUnknownScripts.cs
MaxED bfd57379bb Added, Map Analysis mode: added "Check unknown ACS scripts" error check.
Added, Map Analysis mode: added "Edit Thing..." option to "Unknown Thing" and "Obsolete Thing" error check results.
Added: a warning is now displayed when a thing has both voxel and model attached.
Changed, Thing/Linedef Info panels: unknown ACS script names/numbers are now shown in red.
Fixed, Edit Things window, UDMF: unneeded undo was created when opening the window.
Re-fixed: in some cases invalid sectors were created after dragging map elements when using "Merge Dragged Geometry" and "Replace with Dragged Geometry" drag modes, when at least one of dragged linedef was facing into an enclosed void area (previous fix entirely disabled the associated logic).
2016-09-12 14:08:45 +00:00

106 lines
2.9 KiB
C#

#region ================== Namespaces
using System;
using System.Threading;
using CodeImp.DoomBuilder.GZBuilder;
using CodeImp.DoomBuilder.Map;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[ErrorChecker("Check unknown ACS scripts", true, 50)]
public class CheckUnknownScripts : ErrorChecker
{
#region ================== Constants
private const int PROGRESS_STEP = 1000;
#endregion
#region ================== Properties
// Only possible in Hexen/UDMF map formats
public override bool SkipCheck { get { return (!General.Map.UDMF && !General.Map.HEXEN); } }
#endregion
#region ================== Constructor / Destructor
public CheckUnknownScripts()
{
// Total progress is done when all things are checked
SetTotalProgress((General.Map.Map.Things.Count + General.Map.Map.Linedefs.Count) / PROGRESS_STEP);
}
#endregion
#region ================== Methods
// This runs the check
public override void Run()
{
int progress = 0;
int stepprogress = 0;
// Go for all linedefs
foreach(Linedef l in General.Map.Map.Linedefs)
{
bool isacsscript = (Array.IndexOf(GZGeneral.ACS_SPECIALS, l.Action) != -1);
bool isnamedacsscript = (isacsscript && General.Map.UDMF && l.Fields.ContainsKey("arg0str"));
if(isnamedacsscript)
{
string scriptname = l.Fields.GetValue("arg0str", string.Empty);
if(!General.Map.ScriptNameExists(scriptname))
SubmitResult(new ResultUnknownLinedefScript(l, true));
}
else if(isacsscript && !General.Map.ScriptNumberExists(l.Args[0]))
{
SubmitResult(new ResultUnknownLinedefScript(l, false));
}
// Handle thread interruption
try { Thread.Sleep(0); }
catch(ThreadInterruptedException) { return; }
// We are making progress!
if((++progress / PROGRESS_STEP) > stepprogress)
{
stepprogress = (progress / PROGRESS_STEP);
AddProgress(1);
}
}
// Go for all things
foreach(Thing t in General.Map.Map.Things)
{
bool isacsscript = (Array.IndexOf(GZGeneral.ACS_SPECIALS, t.Action) != -1);
bool isnamedacsscript = (isacsscript && General.Map.UDMF && t.Fields.ContainsKey("arg0str"));
if(isnamedacsscript)
{
string scriptname = t.Fields.GetValue("arg0str", string.Empty);
if(!General.Map.ScriptNameExists(scriptname))
SubmitResult(new ResultUnknownThingScript(t, true));
}
else if(isacsscript && !General.Map.ScriptNumberExists(t.Args[0]))
{
SubmitResult(new ResultUnknownThingScript(t, false));
}
// Handle thread interruption
try { Thread.Sleep(0); } catch(ThreadInterruptedException) { return; }
// We are making progress!
if((++progress / PROGRESS_STEP) > stepprogress)
{
stepprogress = (progress / PROGRESS_STEP);
AddProgress(1);
}
}
}
#endregion
}
}