2013-04-11 11:26:57 +00:00
|
|
|
|
using System.Threading;
|
2012-08-29 10:09:02 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes.ErrorChecks {
|
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
[ErrorChecker("Check unknown things", true, 50)]
|
|
|
|
|
public class CheckUnknownThings : ErrorChecker {
|
|
|
|
|
private int PROGRESS_STEP = 1000;
|
2012-08-29 10:09:02 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Constructor
|
|
|
|
|
public CheckUnknownThings() {
|
2012-08-29 10:09:02 +00:00
|
|
|
|
// Total progress is done when all things are checked
|
|
|
|
|
SetTotalProgress(General.Map.Map.Things.Count / PROGRESS_STEP);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// This runs the check
|
|
|
|
|
public override void Run() {
|
|
|
|
|
int progress = 0;
|
|
|
|
|
int stepprogress = 0;
|
2012-08-29 10:09:02 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Go for all things
|
|
|
|
|
foreach (Thing t in General.Map.Map.Things) {
|
|
|
|
|
if (General.Map.Data.GetThingInfoEx(t.Type) == null)
|
|
|
|
|
SubmitResult(new ResultUnknownThing(t));
|
2012-08-29 10:09:02 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Handle thread interruption
|
|
|
|
|
try { Thread.Sleep(0); } catch (ThreadInterruptedException) { return; }
|
2012-08-29 10:09:02 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// We are making progress!
|
|
|
|
|
if ((++progress / PROGRESS_STEP) > stepprogress) {
|
|
|
|
|
stepprogress = (progress / PROGRESS_STEP);
|
|
|
|
|
AddProgress(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-08-29 10:09:02 +00:00
|
|
|
|
}
|