From: "Enrico Weigelt, metux IT consult" <[email protected]>
---
src/net/sf/freecol/common/model/ProductionType.java | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/net/sf/freecol/common/model/ProductionType.java
b/src/net/sf/freecol/common/model/ProductionType.java
index 58d1469f5db..0f7e8e8964f 100644
--- a/src/net/sf/freecol/common/model/ProductionType.java
+++ b/src/net/sf/freecol/common/model/ProductionType.java
@@ -257,12 +257,17 @@ public class ProductionType extends FreeColSpecObject {
* @return The {@code GoodsType} of the most productive output.
*/
public GoodsType getBestOutputType() {
- AbstractGoods goods;
- return (outputs == null
- || (goods = maximize(outputs,
- AbstractGoods.ascendingAmountComparator)) == null)
- ? null
- : goods.getType();
+ if (outputs == null) return null;
+ GoodsType best_type = null;
+ int best_amount = 0;
+ for (AbstractGoods ag : outputs) {
+ int amount = ag.getAmount();
+ if ((best_type == null) || (amount > best_amount)) {
+ best_amount = amount;
+ best_type = ag.getType();
+ }
+ }
+ return best_type;
}
/**
--
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