From: "Enrico Weigelt, metux IT consult" <[email protected]>
---
src/net/sf/freecol/common/model/BaseProduction.java | 3 +--
src/net/sf/freecol/common/model/ProductionType.java | 14 ++++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/net/sf/freecol/common/model/BaseProduction.java
b/src/net/sf/freecol/common/model/BaseProduction.java
index d0f81ee0db8..7a4297f36f2 100644
--- a/src/net/sf/freecol/common/model/BaseProduction.java
+++ b/src/net/sf/freecol/common/model/BaseProduction.java
@@ -49,8 +49,7 @@ public interface BaseProduction {
getAvailableProductionTypes(unitType == null));
}
if (productionType == null) return 0;
- AbstractGoods best = productionType.getOutput(goodsType);
- return (best == null) ? 0 : best.getAmount();
+ return productionType.getOutputAmount(goodsType);
}
/**
diff --git a/src/net/sf/freecol/common/model/ProductionType.java
b/src/net/sf/freecol/common/model/ProductionType.java
index a971b951d87..c5f965205bf 100644
--- a/src/net/sf/freecol/common/model/ProductionType.java
+++ b/src/net/sf/freecol/common/model/ProductionType.java
@@ -227,6 +227,20 @@ public class ProductionType extends FreeColSpecObject {
}
/**
+ * Get the amount of goods of the given goods type in this production type.
+ *
+ * @param goodsType The {@code GoodsType} to check.
+ * @return The {@code AbstractGoods} output amount if any, otherwise 0
+ */
+ public final int getOutputAmount(GoodsType goodsType) {
+ if (outputs == null)
+ return 0;
+
+ AbstractGoods g = AbstractGoods.findByType(outputs, goodsType);
+ return (g == null ? 0 : g.getAmount());
+ }
+
+ /**
* Get the type of the most productive output.
*
* @return The {@code GoodsType} of the most productive output.
--
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