Skip to content

Commit

Permalink
Fix displayUnitCount calculation (this is possibly BR#2925/40 zero-si…
Browse files Browse the repository at this point in the history
…zed colony bug!)
  • Loading branch information
Mike Pope committed Sep 13, 2020
1 parent 8f6bccf commit be1114c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/net/sf/freecol/common/model/Colony.java
Original file line number Diff line number Diff line change
Expand Up @@ -3032,16 +3032,17 @@ protected void writeAttributes(FreeColXMLWriter xw) throws XMLStreamException {
xw.writeAttribute(PRODUCTION_BONUS_TAG, productionBonus);

} else {

int uc = getApparentUnitCount();
if (uc <= 0) {
if (uc > 0) { // Valid if above zero
xw.writeAttribute(UNIT_COUNT_TAG, uc);
} else if (uc == 0) { // Zero is an error! Find that bug
FreeCol.trace(logger, "Unit count fail: " + uc
+ " id=" + getId()
+ " id=" + getId() + " name=" + getName()
+ " unitCount=" + getUnitCount()
+ " displayUnitCount=" + this.displayUnitCount
+ " scope=" + xw.getWriteScope()
+ "/" + xw.getClientPlayer());
}
xw.writeAttribute(UNIT_COUNT_TAG, uc);
} // else do nothing, negative means no value set
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/common/model/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ public Tile getTileToCache() {
Colony colony = getColony();
if (colony != null) {
tile.getColony()
.setDisplayUnitCount(Math.min(1, colony.getUnitCount()));
.setDisplayUnitCount(Math.max(1, colony.getUnitCount()));
}
return tile;
}
Expand Down

0 comments on commit be1114c

Please sign in to comment.