From: "Enrico Weigelt, metux IT consult" <[email protected]>
---
.../common/model/pathfinding/CostDeciders.java | 34 +++++++++++-----------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/net/sf/freecol/common/model/pathfinding/CostDeciders.java
b/src/net/sf/freecol/common/model/pathfinding/CostDeciders.java
index 5fa82b1d58a..2f83cd2d892 100644
--- a/src/net/sf/freecol/common/model/pathfinding/CostDeciders.java
+++ b/src/net/sf/freecol/common/model/pathfinding/CostDeciders.java
@@ -19,8 +19,6 @@
package net.sf.freecol.common.model.pathfinding;
-import java.util.function.Predicate;
-
import net.sf.freecol.common.model.Ability;
import net.sf.freecol.common.model.Europe;
import net.sf.freecol.common.model.Location;
@@ -185,23 +183,25 @@ public final class CostDeciders {
Location newLocation, int movesLeft) {
int cost = super.getCost(unit, oldLocation, newLocation,
movesLeft);
Tile tile = newLocation.getTile();
- if (cost != ILLEGAL_MOVE && cost != Map.INFINITY && tile != null) {
- if (tile.isDangerousToShip(unit)) {
- cost = ILLEGAL_MOVE;
- } else {
- // Move might end if there is a credible naval
- // threat in an adjacent tile.
- final Player owner = unit.getOwner();
- final Predicate<Unit> threatPred = u ->
- (u.getOwner() != owner
- && (u.hasAbility(Ability.PIRACY)
- || (u.getOwner().atWarWith(owner)
- && u.isOffensiveUnit())));
- if (any(flatten(tile.getSurroundingTiles(1,1),
- Tile::getUnits),
- threatPred)) {
+
+ if (cost == ILLEGAL_MOVE || cost == Map.INFINITY && tile == null)
+ return cost;
+
+ if (tile.isDangerousToShip(unit))
+ return ILLEGAL_MOVE;
+
+ // Move might end if there is a credible naval
+ // threat in an adjacent tile.
+ final Player owner = unit.getOwner();
+ for (Tile t : tile.getSurroundingTiles(1,1)) {
+ for (Unit u : t.getUnits()) {
+ if (u.getOwner() != owner
+ && (u.hasAbility(Ability.PIRACY) ||
+ (u.getOwner().atWarWith(owner) &&
u.isOffensiveUnit())
+ )) {
this.movesLeft = 0;
this.newTurns++;
+ return cost;
}
}
}
--
2.11.0.rc0.7.gbe5a750
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Freecol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freecol-developers