2013-04-11 11:26:57 +00:00
|
|
|
|
using System.Threading;
|
2012-08-29 10:09:02 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
|
2014-09-30 12:02:41 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
[ErrorChecker("Check unknown things", true, 50)]
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public class CheckUnknownThings : ErrorChecker
|
|
|
|
|
{
|
2014-05-27 09:22:44 +00:00
|
|
|
|
|
|
|
|
|
private const int PROGRESS_STEP = 1000;
|
2012-08-29 10:09:02 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Constructor
|
2014-12-03 23:15:26 +00:00
|
|
|
|
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
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void Run()
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
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
|
2015-12-28 15:01:53 +00:00
|
|
|
|
foreach(Thing t in General.Map.Map.Things)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-12-28 15:01:53 +00:00
|
|
|
|
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
|
2016-02-01 22:04:00 +00:00
|
|
|
|
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!
|
2015-12-28 15:01:53 +00:00
|
|
|
|
if((++progress / PROGRESS_STEP) > stepprogress)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
stepprogress = (progress / PROGRESS_STEP);
|
|
|
|
|
AddProgress(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-08-29 10:09:02 +00:00
|
|
|
|
}
|