From: "Enrico Weigelt, metux IT consult" <[email protected]>
---
.../gui/panel/report/ReportCompactColonyPanel.java | 7 +++----
src/net/sf/freecol/common/model/Colony.java | 18 ++++++++----------
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git
a/src/net/sf/freecol/client/gui/panel/report/ReportCompactColonyPanel.java
b/src/net/sf/freecol/client/gui/panel/report/ReportCompactColonyPanel.java
index 37c750b553f..d4010c5bcc8 100644
--- a/src/net/sf/freecol/client/gui/panel/report/ReportCompactColonyPanel.java
+++ b/src/net/sf/freecol/client/gui/panel/report/ReportCompactColonyPanel.java
@@ -500,7 +500,7 @@ public final class ReportCompactColonyPanel extends
ReportPanel
if (!s.colony.getTile().isCoastland()) {
key = "annotation.inland";
t.add(Messages.message("report.colony.annotation.inland"));
- } else if ((building =
s.colony.getWorkLocationWithAbility(Ability.PRODUCE_IN_WATER, Building.class))
== null) {
+ } else if ((building =
s.colony.getBuildingWithAbility(Ability.PRODUCE_IN_WATER)) == null) {
key = "annotation.coastal";
t.add(Messages.message("report.colony.annotation.coastal"));
} else {
@@ -510,7 +510,7 @@ public final class ReportCompactColonyPanel extends
ReportPanel
if (ResourceManager.hasResource(key))
annotations += ResourceManager.getString(key);
- if ((building = s.colony.getWorkLocationWithAbility(Ability.EXPORT,
Building.class)) != null) {
+ if ((building = s.colony.getBuildingWithAbility(Ability.EXPORT)) !=
null) {
annotations += "*";
t.add(Messages.message(building.getLabel()));
}
@@ -753,8 +753,7 @@ public final class ReportCompactColonyPanel extends
ReportPanel
// places.
// Colour: cAlarm if completion is blocked, otherwise cPlain.
int empty = 0;
- Building school = s.colony.getWorkLocationWithAbility(Ability.TEACH,
- Building.class);
+ Building school = s.colony.getBuildingWithAbility(Ability.TEACH);
if (school != null) empty = school.getType().getWorkPlaces();
for (Entry<Unit, Integer> e
: mapEntriesByValue(s.teachers, descendingIntegerComparator))
{
diff --git a/src/net/sf/freecol/common/model/Colony.java
b/src/net/sf/freecol/common/model/Colony.java
index 86107881814..78564a13144 100644
--- a/src/net/sf/freecol/common/model/Colony.java
+++ b/src/net/sf/freecol/common/model/Colony.java
@@ -732,20 +732,18 @@ public class Colony extends Settlement implements
Nameable, TradeLocation {
}
/**
- * Gets a work location of a specific class with a given ability.
+ * Gets a buildingg with a given ability.
*
- * @param <T> The actual return type.
* @param ability An ability key.
- * @param returnClass The expected subclass.
- * @return A {@code WorkLocation} with the required
+ * @return A {@code Building} with the required
* {@code Ability}, or null if not found.
*/
- public <T extends WorkLocation> T getWorkLocationWithAbility(String
ability,
- Class<T>
returnClass) {
- WorkLocation wl = getWorkLocationWithAbility(ability);
- try {
- if (wl != null) return returnClass.cast(wl);
- } catch (ClassCastException cce) {};
+ public Building getBuildingWithAbility(String ability) {
+ synchronized (this.buildingMap) {
+ for (Building b : this.buildingMap.values())
+ if (b.isCurrent() && b.hasAbility(ability))
+ return b;
+ }
return null;
}
--
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