From: "Enrico Weigelt, metux IT consult" <enrico.weig...@gr13.net>
--- src/net/sf/freecol/common/model/Force.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/net/sf/freecol/common/model/Force.java b/src/net/sf/freecol/common/model/Force.java index a4872c1c6fe..4550b896232 100644 --- a/src/net/sf/freecol/common/model/Force.java +++ b/src/net/sf/freecol/common/model/Force.java @@ -22,7 +22,6 @@ package net.sf.freecol.common.model; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.function.Predicate; import javax.xml.stream.XMLStreamException; @@ -183,12 +182,16 @@ public class Force extends FreeColSpecObject { final Specification spec = getSpecification(); final UnitType unitType = au.getType(spec); final int n = au.getNumber(); - final Predicate<AbstractUnit> matchPred = a -> - spec.getUnitType(a.getId()) == unitType - && a.getRoleId().equals(au.getRoleId()); if (unitType.hasAbility(Ability.NAVAL_UNIT)) { - AbstractUnit refUnit = find(this.navalUnits, matchPred); + AbstractUnit refUnit = null; + for (AbstractUnit a : this.navalUnits) { + if (spec.getUnitType(a.getId()) == unitType + && a.getRoleId().equals(au.getRoleId())) { + refUnit = a; + break; + } + } if (refUnit != null) { refUnit.setNumber(refUnit.getNumber() + n); if (unitType.canCarryUnits()) { @@ -198,7 +201,14 @@ public class Force extends FreeColSpecObject { this.navalUnits.add(au); } } else { - AbstractUnit refUnit = find(this.landUnits, matchPred); + AbstractUnit refUnit = null; + for (AbstractUnit a : this.landUnits) { + if (spec.getUnitType(a.getId()) == unitType + && a.getRoleId().equals(au.getRoleId())) { + refUnit = a; + break; + } + } if (refUnit != null) { refUnit.setNumber(refUnit.getNumber() + n); this.spaceRequired += unitType.getSpaceTaken() * n; -- 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