2013-05-31 13:57:49 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
2013-05-30 15:50:46 +00:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
2014-09-30 12:02:41 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
2013-05-30 15:50:46 +00:00
|
|
|
|
{
|
|
|
|
|
[ErrorChecker("Check unconnected vertices", true, 50)]
|
|
|
|
|
public class CheckStrayVertices : ErrorChecker
|
|
|
|
|
{
|
2014-06-30 08:17:43 +00:00
|
|
|
|
private const int PROGRESS_STEP = 1000;
|
2013-05-30 15:50:46 +00:00
|
|
|
|
|
|
|
|
|
// Constructor
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public CheckStrayVertices()
|
|
|
|
|
{
|
2013-05-30 15:50:46 +00:00
|
|
|
|
// Total progress is done when all vertices are checked
|
|
|
|
|
SetTotalProgress(General.Map.Map.Vertices.Count / PROGRESS_STEP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This runs the check
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void Run()
|
|
|
|
|
{
|
2013-05-30 15:50:46 +00:00
|
|
|
|
int progress = 0;
|
|
|
|
|
int stepprogress = 0;
|
|
|
|
|
|
2015-07-13 11:20:02 +00:00
|
|
|
|
// Go for all vertices
|
2014-12-03 23:15:26 +00:00
|
|
|
|
foreach(Vertex v in General.Map.Map.Vertices)
|
|
|
|
|
{
|
|
|
|
|
if(v.Linedefs == null || v.Linedefs.Count == 0) SubmitResult(new ResultStrayVertex(v));
|
2013-05-30 15:50:46 +00:00
|
|
|
|
|
|
|
|
|
// Handle thread interruption
|
|
|
|
|
try { Thread.Sleep(0); } catch(ThreadInterruptedException) { return; }
|
|
|
|
|
|
|
|
|
|
// We are making progress!
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if((++progress / PROGRESS_STEP) > stepprogress)
|
|
|
|
|
{
|
2013-05-30 15:50:46 +00:00
|
|
|
|
stepprogress = (progress / PROGRESS_STEP);
|
|
|
|
|
AddProgress(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|