From 65001d178cbd4f3e6f8028a8890d11be1e96444d Mon Sep 17 00:00:00 2001 From: Erik Vos Date: Tue, 23 Aug 2022 16:03:20 +0200 Subject: [PATCH] Fixed GREEDY edge status prohibiting valid tile rotation The check in NetworkGraph.getReachableSides() on an edge having GREEDY status has been disabled. This resolves issue #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). --- .../java/net/sf/rails/algorithms/NetworkGraph.java | 4 ++-- .../net/sf/rails/tools/ListAndFixSavedFiles.java | 13 +++++++++---- src/main/resources/LocalisedText.properties | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/sf/rails/algorithms/NetworkGraph.java b/src/main/java/net/sf/rails/algorithms/NetworkGraph.java index ea12879f5..f60202bea 100755 --- a/src/main/java/net/sf/rails/algorithms/NetworkGraph.java +++ b/src/main/java/net/sf/rails/algorithms/NetworkGraph.java @@ -122,8 +122,8 @@ public ImmutableMap getReachableSides() { // first create builders for all HexSides Map 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()); diff --git a/src/main/java/net/sf/rails/tools/ListAndFixSavedFiles.java b/src/main/java/net/sf/rails/tools/ListAndFixSavedFiles.java index baf330f15..fde1f38ad 100644 --- a/src/main/java/net/sf/rails/tools/ListAndFixSavedFiles.java +++ b/src/main/java/net/sf/rails/tools/ListAndFixSavedFiles.java @@ -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(); } @@ -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); } diff --git a/src/main/resources/LocalisedText.properties b/src/main/resources/LocalisedText.properties index b99a4a273..bbcbeb085 100644 --- a/src/main/resources/LocalisedText.properties +++ b/src/main/resources/LocalisedText.properties @@ -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}.