From: "Enrico Weigelt, metux IT consult" <enrico.weig...@gr13.net>
--- .../client/gui/dialog/SelectDestinationDialog.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/net/sf/freecol/client/gui/dialog/SelectDestinationDialog.java b/src/net/sf/freecol/client/gui/dialog/SelectDestinationDialog.java index f9c10d55aee..d482f7837e9 100644 --- a/src/net/sf/freecol/client/gui/dialog/SelectDestinationDialog.java +++ b/src/net/sf/freecol/client/gui/dialog/SelectDestinationDialog.java @@ -406,6 +406,15 @@ public final class SelectDestinationDialog extends FreeColDialog<Location> getImageLibrary().getSmallUnitImage(unit)), c); } + /** + * Quick check for whether a settlement is reachable by the unit. + * Used to knock out obviously impossible candidates before invoking + * the expensive full path search. + */ + private final boolean unitCanReach(Unit unit, Settlement s) { + return unit.isNaval() ? s.isConnectedPort() + : Map.isSameContiguity(unit.getLocation(), s.getTile()); + } /** * Load destinations for a given unit and carried goods types. @@ -424,12 +433,6 @@ public final class SelectDestinationDialog extends FreeColDialog<Location> final Europe europe = player.getEurope(); final Game game = getGame(); final Map map = game.getMap(); - // Quick check for whether a settlement is reachable by the unit. - // Used to knock out obviously impossible candidates before invoking - // the expensive full path search. - final Predicate<Settlement> canReach = s -> - (unit.isNaval()) ? s.isConnectedPort() - : Map.isSameContiguity(unit.getLocation(), s.getTile()); if (this.destinationComparator == null) { this.destinationComparator = new DestinationComparator(player); @@ -450,7 +453,7 @@ public final class SelectDestinationDialog extends FreeColDialog<Location> // Find all the player accessible settlements except the current one. td.addAll(transform(player.getSettlements(), - s -> s != inSettlement && canReach.test(s), + s -> s != inSettlement && unitCanReach(unit, s), s -> new Destination(s, unit.getTurnsToReach(s), unit, goodsTypes))); @@ -462,7 +465,7 @@ public final class SelectDestinationDialog extends FreeColDialog<Location> for (Player op : game.getLivePlayers(player)) if (op.hasContacted(player) && (canTrade || !op.isEuropean())) for (Settlement s : op.getSettlements()) - if (canReach.test(s) && s.hasContacted(op)) + if (unitCanReach(unit, s) && s.hasContacted(op)) locs.add(s.getTile()); MultipleAdjacentDecider md = new MultipleAdjacentDecider(locs); -- 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 Freecol-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freecol-developers