mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-27 06:02:11 +00:00
sorting error checkers with highest cost first (estimated CPU usage)
This commit is contained in:
parent
46434b8b7c
commit
d7a843938a
4 changed files with 21 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -38,12 +38,13 @@ using CodeImp.DoomBuilder.Config;
|
|||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
public class ErrorChecker
|
||||
public class ErrorChecker : IComparable<ErrorChecker>
|
||||
{
|
||||
#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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue