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

---
 src/net/sf/freecol/common/model/Colony.java | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/net/sf/freecol/common/model/Colony.java 
b/src/net/sf/freecol/common/model/Colony.java
index df4d3e387ef..a84496bbe5e 100644
--- a/src/net/sf/freecol/common/model/Colony.java
+++ b/src/net/sf/freecol/common/model/Colony.java
@@ -2622,9 +2622,18 @@ loop:   for (WorkLocation wl : 
getWorkLocationsForProducing(goodsType)) {
         // units outside the colony as well, use
         // @see Tile#getDefendingUnit instead.
         final CombatModel cm = getGame().getCombatModel();
-        final Comparator<Unit> comp
-                = cachingDoubleComparator(u -> cm.getDefencePower(attacker, 
u));
-        return maximize(getUnits(), comp);
+
+        double max_defense = 0;
+        Unit max_unit = null;
+        for (Unit u : getUnits()) {
+            double defpwr = cm.getDefencePower(attacker, u);
+            if ((max_unit == null) || (defpwr > max_defense)) {
+                max_defense = defpwr;
+                max_unit = u;
+            }
+        }
+
+        return max_unit;
     }
 
     /**
-- 
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