Skip to content

Commit

Permalink
Kill path finding jobs upon interruption, for #1873.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceToad committed Jun 22, 2014
1 parent eeb637d commit e4ab3b0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
7 changes: 7 additions & 0 deletions common/buildcraft/core/robots/AIRobotMoveToBlock.java
Expand Up @@ -95,4 +95,11 @@ private void setNextInPath() {
prevDistance = Double.MAX_VALUE;
}
}

@Override
public void end() {
if (pathSearchJob != null) {
pathSearchJob.terminate();
}
}
}
Expand Up @@ -74,4 +74,10 @@ public void delegateAIEnded(AIRobot ai) {
}
}

@Override
public void end() {
if (pathFindingJob != null) {
pathFindingJob.terminate();
}
}
}
7 changes: 7 additions & 0 deletions common/buildcraft/core/robots/boards/AIRobotSearchBlock.java
Expand Up @@ -55,4 +55,11 @@ public void delegateAIEnded(AIRobot ai) {
terminate();
}
}

@Override
public void end() {
if (blockScannerJob != null) {
blockScannerJob.terminate();
}
}
}
12 changes: 11 additions & 1 deletion common/buildcraft/core/utils/PathFindingJob.java
Expand Up @@ -12,16 +12,26 @@ public class PathFindingJob extends Thread {

private PathFinding pathFinding;

private boolean stop = false;

public PathFindingJob(PathFinding iPathFinding) {
super("Path Finding");
pathFinding = iPathFinding;
}

@Override
public void run() {
while (!pathFinding.isDone()) {
while (!isTerminated() && !pathFinding.isDone()) {
pathFinding.iterate();
}
}

public synchronized void terminate() {
stop = true;
}

public synchronized boolean isTerminated() {
return stop;
}

}

0 comments on commit e4ab3b0

Please sign in to comment.