separate normal terminaison from abort

This commit is contained in:
SpaceToad 2014-06-22 23:31:07 +02:00
parent e4ab3b0fa0
commit 2e209805b8
4 changed files with 26 additions and 8 deletions
api/buildcraft/api/robots
common/buildcraft/core

View file

@ -40,6 +40,10 @@ public class AIRobot {
}
public void delegateAIAborted(AIRobot ai) {
}
public final void terminate() {
abortDelegateAI();
end();
@ -50,6 +54,16 @@ public class AIRobot {
}
}
public final void abort() {
abortDelegateAI();
end();
if (parentAI != null) {
parentAI.delegateAI = null;
parentAI.delegateAIAborted(this);
}
}
public final void cycle() {
preempt(delegateAI);
@ -72,7 +86,7 @@ public class AIRobot {
public final void abortDelegateAI() {
if (delegateAI != null) {
delegateAI.terminate();
delegateAI.abort();
}
}
}

View file

@ -56,7 +56,7 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
if (ai instanceof AIRobotSearchBlock) {
BlockIndex index = ((AIRobotSearchBlock) ai).blockFound;
if (reserveBlock(index)) {
if (index != null && reserveBlock(index)) {
startDelegateAI(new AIRobotBreakWithTool(robot, ((AIRobotSearchBlock) ai).blockFound));
}
} else if (ai instanceof AIRobotBreakWithTool) {

View file

@ -76,11 +76,11 @@ public class PathFinding {
}
public void iterate(int itNumber) {
if (nextIteration == null) {
return;
}
for (int i = 0; i < itNumber; ++i) {
if (nextIteration == null) {
return;
}
if (endReached) {
result = new LinkedList<BlockIndex>();

View file

@ -21,8 +21,12 @@ public class PathFindingJob extends Thread {
@Override
public void run() {
while (!isTerminated() && !pathFinding.isDone()) {
pathFinding.iterate();
try {
while (!isTerminated() && !pathFinding.isDone()) {
pathFinding.iterate();
}
} catch (Throwable t) {
t.printStackTrace();
}
}