general cleanup

This commit is contained in:
Leijurv 2018-11-14 14:27:30 -08:00
parent 8385bc35ed
commit f808fc9802
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -35,11 +35,6 @@ import java.util.Optional;
*/ */
public abstract class AbstractNodeCostSearch implements IPathFinder { public abstract class AbstractNodeCostSearch implements IPathFinder {
/**
* The currently running search task
*/
private static AbstractNodeCostSearch currentlyRunning = null;
protected final int startX; protected final int startX;
protected final int startY; protected final int startY;
protected final int startZ; protected final int startZ;
@ -114,19 +109,10 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
return new PathCalculationResult(PathCalculationResult.Type.EXCEPTION, Optional.empty()); return new PathCalculationResult(PathCalculationResult.Type.EXCEPTION, Optional.empty());
} finally { } finally {
// this is run regardless of what exception may or may not be raised by calculate0 // this is run regardless of what exception may or may not be raised by calculate0
currentlyRunning = null;
isFinished = true; isFinished = true;
} }
} }
/**
* Don't set currentlyRunning to this until everything is all ready to go, and we're about to enter the main loop.
* For example, bestSoFar is null so bestPathSoFar (which gets bestSoFar[0]) could NPE if we set currentlyRunning before calculate0
*/
protected void loopBegin() {
currentlyRunning = this;
}
protected abstract Optional<IPath> calculate0(long timeout); protected abstract Optional<IPath> calculate0(long timeout);
/** /**
@ -161,22 +147,6 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
return node; return node;
} }
public static void forceCancel() {
currentlyRunning = null;
}
public PathNode mostRecentNodeConsidered() {
return mostRecentConsidered;
}
public PathNode bestNodeSoFar() {
return bestSoFar[0];
}
public PathNode startNode() {
return startNode;
}
@Override @Override
public Optional<IPath> pathToMostRecentNodeConsidered() { public Optional<IPath> pathToMostRecentNodeConsidered() {
try { try {