Skip GUI path finding when it is doomed.

This commit is contained in:
Mike Pope 2017-02-01 20:25:53 +10:30
parent 93325f5c94
commit d385568856
1 changed files with 8 additions and 5 deletions

View File

@ -80,12 +80,15 @@ public final class CanvasMouseMotionListener extends AbstractCanvasListener
if (lastTile != tile) {
Unit active = canvas.getActiveUnit();
lastTile = tile;
if (active != null && active.getTile() != tile) {
PathNode dragPath = active.findPath(tile);
canvas.setGotoPath(dragPath);
} else {
canvas.setGotoPath(null);
PathNode dragPath = null;
// Only call the expensive path finder if there
// are no obvious showstoppers.
if (active != null && active.getTile() != tile
&& tile.isExplored()
&& active.getSimpleMoveType(tile).isLegal()) {
dragPath = active.findPath(tile);
}
canvas.setGotoPath(dragPath);
}
}
}