diff --git a/Source/BuilderModes/ErrorChecks/CheckStuckedThings.cs b/Source/BuilderModes/ErrorChecks/CheckStuckedThings.cs index 08dabbc3..aaf87a12 100644 --- a/Source/BuilderModes/ErrorChecks/CheckStuckedThings.cs +++ b/Source/BuilderModes/ErrorChecks/CheckStuckedThings.cs @@ -39,7 +39,7 @@ using System.Threading; namespace CodeImp.DoomBuilder.BuilderModes { - [ErrorChecker("Check for stucked things", true)] + [ErrorChecker("Check for stucked things", true, 1000)] public class CheckStuckedThings : ErrorChecker { #region ================== Constants @@ -78,7 +78,7 @@ namespace CodeImp.DoomBuilder.BuilderModes float blockingsize = t.Size - ALLOWED_STUCK_DISTANCE; Vector2D lt = new Vector2D(t.Position.x - blockingsize, t.Position.y - blockingsize); Vector2D rb = new Vector2D(t.Position.x + blockingsize, t.Position.y + blockingsize); - + // Go for all the lines to see if this thing is stucked foreach(Linedef l in General.Map.Map.Linedefs) { diff --git a/Source/BuilderModes/ErrorChecks/ErrorChecker.cs b/Source/BuilderModes/ErrorChecks/ErrorChecker.cs index 6d4908e6..6128066d 100644 --- a/Source/BuilderModes/ErrorChecks/ErrorChecker.cs +++ b/Source/BuilderModes/ErrorChecks/ErrorChecker.cs @@ -38,12 +38,13 @@ using CodeImp.DoomBuilder.Config; namespace CodeImp.DoomBuilder.BuilderModes { - public class ErrorChecker + public class ErrorChecker : IComparable { #region ================== Variables private int lastprogress; private int totalprogress = -1; + protected ErrorCheckerAttribute attribs; #endregion @@ -59,6 +60,9 @@ namespace CodeImp.DoomBuilder.BuilderModes // Override this to determine and set the total progress public ErrorChecker() { + // Initialize + object[] attrs = this.GetType().GetCustomAttributes(typeof(ErrorCheckerAttribute), true); + attribs = (ErrorCheckerAttribute)attrs[0]; } #endregion @@ -96,6 +100,12 @@ namespace CodeImp.DoomBuilder.BuilderModes this.totalprogress = totalprogress; } + // This is for sorting by cost + public int CompareTo(ErrorChecker other) + { + return (other.attribs.Cost - this.attribs.Cost); + } + #endregion } } diff --git a/Source/BuilderModes/ErrorChecks/ErrorCheckerAttribute.cs b/Source/BuilderModes/ErrorChecks/ErrorCheckerAttribute.cs index 6429e540..5023fe5e 100644 --- a/Source/BuilderModes/ErrorChecks/ErrorCheckerAttribute.cs +++ b/Source/BuilderModes/ErrorChecks/ErrorCheckerAttribute.cs @@ -45,6 +45,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private string displayname; private bool defaultchecked; + private int cost; #endregion @@ -52,17 +53,19 @@ namespace CodeImp.DoomBuilder.BuilderModes public string DisplayName { get { return displayname; } set { displayname = value; } } public bool DefaultChecked { get { return defaultchecked; } set { defaultchecked = value; } } + public int Cost { get { return cost; } set { cost = value; } } #endregion #region ================== Constructor / Destructor // Constructor - public ErrorCheckerAttribute(string displayname, bool defaultchecked) + public ErrorCheckerAttribute(string displayname, bool defaultchecked, int cost) { // Initialize this.displayname = displayname; this.defaultchecked = defaultchecked; + this.cost = cost; } #endregion diff --git a/Source/BuilderModes/Interface/ErrorCheckForm.cs b/Source/BuilderModes/Interface/ErrorCheckForm.cs index 493b5140..17d08dd5 100644 --- a/Source/BuilderModes/Interface/ErrorCheckForm.cs +++ b/Source/BuilderModes/Interface/ErrorCheckForm.cs @@ -275,6 +275,10 @@ namespace CodeImp.DoomBuilder.BuilderModes } } + // Sort the checkers with highest cost first + // See CompareTo method in ErrorChecker for sorting comparison + checkers.Sort(); + // Setup SetProgressMaximum(totalprogress);