From: "Enrico Weigelt, metux IT consult" <enrico.weig...@gr13.net>

---
 src/net/sf/freecol/common/model/Unit.java | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/net/sf/freecol/common/model/Unit.java 
b/src/net/sf/freecol/common/model/Unit.java
index 577341356f6..0660ebe3ac4 100644
--- a/src/net/sf/freecol/common/model/Unit.java
+++ b/src/net/sf/freecol/common/model/Unit.java
@@ -98,14 +98,6 @@ public class Unit extends GoodsLocation
     public static final Comparator<Unit> decreasingSkillComparator
         = increasingSkillComparator.reversed();
 
-    /**
-     * Comparator to rank settlements by accessibility by sea to Europe.
-     */
-    private static final Comparator<Settlement> settlementStartComparator
-        = cachingIntComparator(s ->
-            (s == null || !s.getTile().isHighSeasConnected()) ? INFINITY
-                : s.getTile().getHighSeasCount());
-
     /** A state a Unit can have. */
     public static enum UnitState {
         ACTIVE,
@@ -2634,8 +2626,19 @@ public class Unit extends GoodsLocation
         // Must be a land unit not on the map.  May have a carrier.
         // Get our nearest settlement to Europe, fallback to any other.
         final Player owner = getOwner();
-        Settlement sett = minimize(owner.getSettlements(),
-                                   settlementStartComparator);
+        Settlement sett = null;
+        int sett_dist = INFINITY;
+        for (Settlement s : owner.getSettlements()) {
+            int hsc = s.getTile().getHighSeasCount();
+            int dist = (hsc < 0 ? INFINITY : hsc);
+
+            if ((sett == null) || (dist < sett_dist)) {
+                sett = s;
+                sett_dist = dist;
+                continue;
+            }
+        }
+
         if (sett == null) sett = owner.getFirstSettlement();
         if (sett != null) return sett;
 
-- 
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

Reply via email to