Skip to content

Commit

Permalink
Fixed GREEDY edge status prohibiting valid tile rotation
Browse files Browse the repository at this point in the history
The check in NetworkGraph.getReachableSides() on an edge having GREEDY status has been disabled. This resolves issue Rails-18xx#478.

Other fixes:
 - A bug in ListAndFixSavedFiles that mixed up Stop and Station numbers.
 - Distances from tokenable stops to the nearest base token went wrong when hexes had multiple cities on one hex
 (e.g. Paris in 1826).
  • Loading branch information
Erik Vos committed Sep 14, 2022
1 parent 9b640c9 commit 65001d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/sf/rails/algorithms/NetworkGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public ImmutableMap<MapHex, HexSidesSet> getReachableSides() {
// first create builders for all HexSides
Map<MapHex, HexSidesSet.Builder> hexSides = Maps.newHashMap();
for (NetworkVertex vertex : graph.vertexSet()) {
if (vertex.isSide() && iterator.getSeenData().get(vertex)
!= NetworkIterator.greedyState.GREEDY ) {
if (vertex.isSide() /*&& iterator.getSeenData().get(vertex)
!= NetworkIterator.greedyState.GREEDY */) {
MapHex hex = vertex.getHex();
if (!hexSides.containsKey(hex)) {
hexSides.put(hex, HexSidesSet.builder());
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/net/sf/rails/tools/ListAndFixSavedFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,12 @@ private class LayBaseTokenDialog extends EditDialog {
action.getLocationNameString(),
action.getLocationNameString());
addTextField(this, "Station",
action.getChosenStop().getNumber(),
String.valueOf(action.getChosenStop().getNumber())); // 0
// getChosenStation is deprecated, but chosenStop is still derived from it,
// and therefore must be used in ListAndFixSavedFiles
action.getChosenStation(),
String.valueOf(action.getChosenStation())); // 0
//action.getChosenStop().getNumber(),
//String.valueOf(action.getChosenStop().getNumber())); // 0
finish();
}

Expand All @@ -845,11 +849,12 @@ PossibleAction processInput() {
log.info("Action was {}", action);
String input = "";
input = ((JTextField)inputElements.get(0)).getText();

action.setLocationNames(input);
try {
input = ((JTextField)inputElements.get(1)).getText();
int chosenStop = Integer.valueOf(input);
action.setChosenStation(chosenStop);
int chosenStation = Integer.valueOf(input);
action.setChosenStation(chosenStation);
} catch (NumberFormatException e) {
log.error ("Error in chosenStop: {}", input, e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/LocalisedText.properties
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ BUY_WHICH_TRAIN=Buy which train?
BuyPrivatePrompt={0} from {1} for {2}
BuyRight=Buy {0} right for {1}
BankIsBrokenDisplayText=Bank is broken. Play continues until {0}
BankIsBrokenReportText=Bank is broken
BankIsBrokenReportText=BANK IS BROKEN
gameOverPlaySetOfORs=the current set of operating rounds is finished.
gameOverPlayOnlyOR=the current operating round is finished.
BankHas=The Bank has {0}.
Expand Down

0 comments on commit 65001d1

Please sign in to comment.