From 5e96be458eada71bee19627a4677297399acea21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Sat, 29 Jan 2022 22:14:34 +0100 Subject: [PATCH] Fix a regression in 5/5/5 --- src/pathfinding.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pathfinding.js b/src/pathfinding.js index d9e13eb..d2636f7 100644 --- a/src/pathfinding.js +++ b/src/pathfinding.js @@ -65,12 +65,12 @@ function getNode(pos, initialize=true) { if (use5105 && isDiagonal) targetLayer = 1 - targetLayer; const neighbor = getNode({...neighborPos, layer: targetLayer}, false); - // TODO We currently assume a cost of one for all transitions. Change this for 5/10/5 or difficult terrain support + // TODO We currently assume a cost of one for all transitions. Change this for 5/10/5 or difficult terrain support let edgeCost = 1; if (isDiagonal) { // We charge 0.0001 more for edges to avoid unnecessary diagonal steps - edgeCost = targetLayer === 1 ? 1.0001 : 2; + edgeCost = pos.layer === 1 && targetLayer === 0 ? 2 : 1.0001; } node.edges.push({target: neighbor, cost: edgeCost}); }