summaryrefslogtreecommitdiff
path: root/nodejs/lib/utils.ts
diff options
context:
space:
mode:
authorJulien Dessaux2024-05-20 22:52:14 +0200
committerJulien Dessaux2024-05-20 22:52:14 +0200
commit92ef1e8c2e549c4c10c77fbc29adc917f46c3e4d (patch)
treec217d67a69a6b9db10d9b1ef731a6ec53ba3d21a /nodejs/lib/utils.ts
parent[node] implement shipyard info retrieval and database caching (diff)
downloadspacetraders-92ef1e8c2e549c4c10c77fbc29adc917f46c3e4d.tar.gz
spacetraders-92ef1e8c2e549c4c10c77fbc29adc917f46c3e4d.tar.bz2
spacetraders-92ef1e8c2e549c4c10c77fbc29adc917f46c3e4d.zip
Fixed pathing function for probes
Diffstat (limited to 'nodejs/lib/utils.ts')
-rw-r--r--nodejs/lib/utils.ts1
1 files changed, 1 insertions, 0 deletions
diff --git a/nodejs/lib/utils.ts b/nodejs/lib/utils.ts
index ec3ab09..24aa3b4 100644
--- a/nodejs/lib/utils.ts
+++ b/nodejs/lib/utils.ts
@@ -64,6 +64,7 @@ type Step = {waypoint: Waypoint, prev: string, fuel: number, total: number};
type ShortestPath = Array<{symbol: string, fuel: number}>;
export async function shortestPath(origin: Waypoint, destination: Waypoint, range: number, waypoints: Array<Waypoint>): Promise<ShortestPath> {
+ if (range === 0) range = Infinity;
let backtrace: {[key: string]: Step} = {};
let fuels: {[key: string]: number} = {}; // fuel = distance + 1 per hop
let unvisited: {[key: string]: Waypoint} = {};