Skip to content

Commit

Permalink
Fix a bug that occurs with using the first path found when the path c…
Browse files Browse the repository at this point in the history
…ontains 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)
  • Loading branch information
Page- committed Oct 7, 2014
1 parent 6c0b39a commit c2ddde1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/changelog.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 4 additions & 2 deletions src/controller/pathfinding/Pathfinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public static TIntObjectMap<Distance> 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<Distance> distances = new TIntObjectHashMap<Distance>();
int sectorsTravelled = 0;
Expand All @@ -64,7 +66,7 @@ public static TIntObjectMap<Distance> 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++)
{
Expand Down Expand Up @@ -112,7 +114,7 @@ public static TIntObjectMap<Distance> 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++)
{
Expand Down

0 comments on commit c2ddde1

Please sign in to comment.