diff --git a/src/changelog.txt b/src/changelog.txt index 4317cd7..dd8b06c 100644 --- a/src/changelog.txt +++ b/src/changelog.txt @@ -1,3 +1,6 @@ +v1.3.7 +BugFix: Fix a bug that occurs with using the first path found when the path contains warps whilst there is another path that is longer that uses two or more less warps. (2 warps vs 0, 3 warps vs 0/1, etc) + v1.3.6 Feature: Added trade potential to the ship list. Enhancement: Reduced peak memory usage fairly significantly, this is particularly noticeable for 3+ port routes. diff --git a/src/controller/pathfinding/Pathfinding.java b/src/controller/pathfinding/Pathfinding.java index 26c2832..812e43b 100644 --- a/src/controller/pathfinding/Pathfinding.java +++ b/src/controller/pathfinding/Pathfinding.java @@ -49,6 +49,8 @@ public static TIntObjectMap findDistanceToX(Object x, Sector[] sectors, int sectorId, long lowLimit, long highLimit, long distanceLimit, boolean useFirst) { + final int warpAddIndex = Settings.TURNS_WARP_SECTOR_EQUIVALENCE-1; + Sector checkSector; TIntObjectMap distances = new TIntObjectHashMap(); int sectorsTravelled = 0; @@ -64,7 +66,7 @@ public static TIntObjectMap findDistanceToX(Object x, int nextSector = sectors[sectorId].getWarps().get(i).getTargetSector(); Distance d = new Distance(sectorId); d.addWarpToPath(nextSector); - distanceQ.get(Settings.TURNS_WARP_SECTOR_EQUIVALENCE).add(d); + distanceQ.get(warpAddIndex).add(d); } for (int i = 0; i < sectors[sectorId].numConnections(); i++) { @@ -112,7 +114,7 @@ public static TIntObjectMap findDistanceToX(Object x, Distance cloneDistance = distance.clone(); cloneDistance.addWarpToPath(c.getTargetSector()); - distanceQ.get(Settings.TURNS_WARP_SECTOR_EQUIVALENCE).add(cloneDistance); + distanceQ.get(warpAddIndex).add(cloneDistance); } for (int i = 0; i < checkSector.numConnections(); i++) {