mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
Added, Map Analysis mode: added "Check unknown actions and effects" check.
This commit is contained in:
parent
74f749fd68
commit
2499a2155a
6 changed files with 353 additions and 0 deletions
|
@ -1041,6 +1041,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
}
|
||||
|
||||
//mxd
|
||||
public static bool IsGeneralizedSectorEffect(int effect) { return IsGeneralizedSectorEffect(effect, General.Map.Config.GenEffectOptions); }
|
||||
public static bool IsGeneralizedSectorEffect(int effect, List<GeneralizedOption> options)
|
||||
{
|
||||
if(effect == 0) return false;
|
||||
|
@ -1053,6 +1054,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
GeneralizedBit bit = options[i].Bits[j];
|
||||
if(bit.Index > 0 && (cureffect & bit.Index) == bit.Index) return true;
|
||||
cureffect -= bit.Index;
|
||||
if(cureffect < 1) return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -253,6 +253,7 @@
|
|||
<Compile Include="ErrorChecks\CheckShortLinedefs.cs" />
|
||||
<Compile Include="ErrorChecks\CheckStrayVertices.cs" />
|
||||
<Compile Include="ErrorChecks\CheckTextureAlignment.cs" />
|
||||
<Compile Include="ErrorChecks\CheckUnknownActions.cs" />
|
||||
<Compile Include="ErrorChecks\CheckUnknownFlats.cs" />
|
||||
<Compile Include="ErrorChecks\CheckUnknownTextures.cs" />
|
||||
<Compile Include="ErrorChecks\CheckUnknownThings.cs" />
|
||||
|
@ -271,8 +272,11 @@
|
|||
<Compile Include="ErrorChecks\ResultMissingTexture.cs" />
|
||||
<Compile Include="ErrorChecks\ResultTexturesMisaligned.cs" />
|
||||
<Compile Include="ErrorChecks\ResultUnknownFlat.cs" />
|
||||
<Compile Include="ErrorChecks\ResultUnknownLinedefAction.cs" />
|
||||
<Compile Include="ErrorChecks\ResultUnknownSectorEffect.cs" />
|
||||
<Compile Include="ErrorChecks\ResultUnknownTexture.cs" />
|
||||
<Compile Include="ErrorChecks\ResultUnknownThing.cs" />
|
||||
<Compile Include="ErrorChecks\ResultUnknownThingAction.cs" />
|
||||
<Compile Include="ErrorChecks\ResultUnusedTexture.cs" />
|
||||
<Compile Include="ErrorChecks\ResultUnusedThing.cs" />
|
||||
<Compile Include="ErrorChecks\ResultVertexOverlappingLine.cs" />
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
using System.Threading;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes.ErrorChecks
|
||||
{
|
||||
[ErrorChecker("Check unknown actions/effects", true, 50)]
|
||||
public class CheckUnknownActions : ErrorChecker
|
||||
{
|
||||
private const int PROGRESS_STEP = 1000;
|
||||
|
||||
// Constructor
|
||||
public CheckUnknownActions()
|
||||
{
|
||||
int count = General.Map.Map.Sectors.Count + General.Map.Map.Linedefs.Count;
|
||||
if(General.Map.FormatInterface.HasThingAction) count += General.Map.Map.Things.Count;
|
||||
|
||||
// Total progress is done when all relevant map elements are checked
|
||||
SetTotalProgress(count / PROGRESS_STEP);
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
// Check action...
|
||||
if(l.Action != 0 && !General.Map.Config.LinedefActions.ContainsKey(l.Action)
|
||||
&& !GameConfiguration.IsGeneralized(l.Action))
|
||||
{
|
||||
SubmitResult(new ResultUnknownLinedefAction(l));
|
||||
}
|
||||
|
||||
// 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 Sectors
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
{
|
||||
// Check action...
|
||||
if(s.Effect != 0 && !General.Map.Config.SectorEffects.ContainsKey(s.Effect)
|
||||
&& !GameConfiguration.IsGeneralizedSectorEffect(s.Effect))
|
||||
{
|
||||
SubmitResult(new ResultUnknownSectorEffect(s));
|
||||
}
|
||||
|
||||
// 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?
|
||||
if(!General.Map.FormatInterface.HasThingAction) return;
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
{
|
||||
// Check action...
|
||||
if(t.Action != 0 && !General.Map.Config.LinedefActions.ContainsKey(t.Action)
|
||||
&& !GameConfiguration.IsGeneralized(t.Action))
|
||||
{
|
||||
SubmitResult(new ResultUnknownThingAction(t));
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
public class ResultUnknownLinedefAction : ErrorResult
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private readonly Linedef line;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override int Buttons { get { return 2; } }
|
||||
public override string Button1Text { get { return "Remove Action"; } }
|
||||
public override string Button2Text { get { return "Browse Action..."; } } //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
// Constructor
|
||||
public ResultUnknownLinedefAction(Linedef l)
|
||||
{
|
||||
// Initialize
|
||||
line = l;
|
||||
viewobjects.Add(l);
|
||||
hidden = l.IgnoredErrorChecks.Contains(this.GetType()); //mxd
|
||||
description = "This linedef uses unknown action. This can potentially cause gameplay issues.";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This sets if this result is displayed in ErrorCheckForm (mxd)
|
||||
internal override void Hide(bool hide)
|
||||
{
|
||||
hidden = hide;
|
||||
Type t = this.GetType();
|
||||
if(hide) line.IgnoredErrorChecks.Add(t);
|
||||
else if(line.IgnoredErrorChecks.Contains(t)) line.IgnoredErrorChecks.Remove(t);
|
||||
}
|
||||
|
||||
// This must return the string that is displayed in the listbox
|
||||
public override string ToString()
|
||||
{
|
||||
return "Linedef " + line.Index + " uses unknown action " + line.Action;
|
||||
}
|
||||
|
||||
// Rendering
|
||||
public override void PlotSelection(IRenderer2D renderer)
|
||||
{
|
||||
renderer.PlotLinedef(line, General.Colors.Selection);
|
||||
renderer.PlotVertex(line.Start, ColorCollection.VERTICES);
|
||||
renderer.PlotVertex(line.End, ColorCollection.VERTICES);
|
||||
}
|
||||
|
||||
// Fix by removing action
|
||||
public override bool Button1Click(bool batchmode)
|
||||
{
|
||||
if(!batchmode) General.Map.UndoRedo.CreateUndo("Unknown linedef action removal");
|
||||
line.Action = 0;
|
||||
General.Map.Map.Update();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fix by picking action
|
||||
public override bool Button2Click(bool batchmode)
|
||||
{
|
||||
if(!batchmode) General.Map.UndoRedo.CreateUndo("Unknown linedef action correction");
|
||||
line.Action = General.Interface.BrowseLinedefActions(BuilderPlug.Me.ErrorCheckForm, line.Action);
|
||||
General.Map.Map.Update();
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
public class ResultUnknownSectorEffect : ErrorResult
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private readonly Sector sector;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override int Buttons { get { return 2; } }
|
||||
public override string Button1Text { get { return "Remove Effect"; } }
|
||||
public override string Button2Text { get { return "Browse Effect..."; } } //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor
|
||||
|
||||
// Constructor
|
||||
public ResultUnknownSectorEffect(Sector s)
|
||||
{
|
||||
// Initialize
|
||||
sector = s;
|
||||
viewobjects.Add(s);
|
||||
hidden = s.IgnoredErrorChecks.Contains(this.GetType()); //mxd
|
||||
description = "This sector uses unknown effect. This can potentially cause gameplay issues.";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This sets if this result is displayed in ErrorCheckForm (mxd)
|
||||
internal override void Hide(bool hide)
|
||||
{
|
||||
hidden = hide;
|
||||
Type t = this.GetType();
|
||||
if(hide) sector.IgnoredErrorChecks.Add(t);
|
||||
else if(sector.IgnoredErrorChecks.Contains(t)) sector.IgnoredErrorChecks.Remove(t);
|
||||
}
|
||||
|
||||
// This must return the string that is displayed in the listbox
|
||||
public override string ToString()
|
||||
{
|
||||
return "Sector " + sector.Index + " uses unknown effect " + sector.Effect;
|
||||
}
|
||||
|
||||
// Rendering
|
||||
public override void PlotSelection(IRenderer2D renderer)
|
||||
{
|
||||
renderer.PlotSector(sector, General.Colors.Selection);
|
||||
}
|
||||
|
||||
// Fix by removing effect
|
||||
public override bool Button1Click(bool batchmode)
|
||||
{
|
||||
if(!batchmode) General.Map.UndoRedo.CreateUndo("Unknown sector effect removal");
|
||||
sector.Effect = 0;
|
||||
General.Map.Map.Update();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fix by picking effect
|
||||
public override bool Button2Click(bool batchmode)
|
||||
{
|
||||
if(!batchmode) General.Map.UndoRedo.CreateUndo("Unknown sector effect correction");
|
||||
sector.Effect = General.Interface.BrowseSectorEffect(BuilderPlug.Me.ErrorCheckForm, sector.Effect);
|
||||
General.Map.Map.Update();
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
public class ResultUnknownThingAction : ErrorResult
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private readonly Thing thing;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override int Buttons { get { return 2; } }
|
||||
public override string Button1Text { get { return "Remove Action"; } }
|
||||
public override string Button2Text { get { return "Browse Action..."; } } //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
// Constructor
|
||||
public ResultUnknownThingAction(Thing t)
|
||||
{
|
||||
// Initialize
|
||||
thing = t;
|
||||
viewobjects.Add(t);
|
||||
hidden = t.IgnoredErrorChecks.Contains(this.GetType()); //mxd
|
||||
description = "This thing uses unknown action. This can potentially cause gameplay issues.";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This sets if this result is displayed in ErrorCheckForm (mxd)
|
||||
internal override void Hide(bool hide)
|
||||
{
|
||||
hidden = hide;
|
||||
Type t = this.GetType();
|
||||
if(hide) thing.IgnoredErrorChecks.Add(t);
|
||||
else if(thing.IgnoredErrorChecks.Contains(t)) thing.IgnoredErrorChecks.Remove(t);
|
||||
}
|
||||
|
||||
// This must return the string that is displayed in the listbox
|
||||
public override string ToString()
|
||||
{
|
||||
return "Thing " + thing.Index + " uses unknown action " + thing.Action;
|
||||
}
|
||||
|
||||
// Rendering
|
||||
public override void RenderOverlaySelection(IRenderer2D renderer)
|
||||
{
|
||||
renderer.RenderThing(thing, General.Colors.Selection, General.Settings.ActiveThingsAlpha);
|
||||
}
|
||||
|
||||
// Fix by removing action
|
||||
public override bool Button1Click(bool batchmode)
|
||||
{
|
||||
if(!batchmode) General.Map.UndoRedo.CreateUndo("Unknown thing action removal");
|
||||
thing.Action = 0;
|
||||
General.Map.Map.Update();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fix by picking action
|
||||
public override bool Button2Click(bool batchmode)
|
||||
{
|
||||
if(!batchmode) General.Map.UndoRedo.CreateUndo("Unknown thing action correction");
|
||||
thing.Action = General.Interface.BrowseLinedefActions(BuilderPlug.Me.ErrorCheckForm, thing.Action);
|
||||
General.Map.Map.Update();
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue