From 39f7bab4b655731cd1812cd301eac5531234386d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Sun, 21 Nov 2021 20:57:26 +0100 Subject: [PATCH] Pass enableTerrainRuler option to all measureDistances calls This fixes a regression introduced with e1265ad6fb96d60dfd511a3357fbc79cf7d37ffc --- src/api.js | 3 ++- src/movement_tracking.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api.js b/src/api.js index 7e58f6f..6295122 100644 --- a/src/api.js +++ b/src/api.js @@ -131,10 +131,11 @@ export function getColorForDistanceAndToken(distance, token, ranges=null) { } export function getMovedDistanceFromToken(token) { + const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active; const history = getMovementHistory(token); const segments = Ruler.dragRulerGetRaysFromWaypoints(history, {x: token.x, y: token.y}).map(ray => {return {ray}}); const shape = getTokenShape(token); - const distances = measureDistances(segments, token, shape); + const distances = measureDistances(segments, token, shape, {enableTerrainRuler: terrainRulerAvailable}); // Sum up the distances return distances.reduce((acc, val) => acc + val, 0); } diff --git a/src/movement_tracking.js b/src/movement_tracking.js index 2dd2122..541f3a5 100644 --- a/src/movement_tracking.js +++ b/src/movement_tracking.js @@ -56,7 +56,7 @@ function calculateUpdate(combat, token, rays) { // Ignore rays that have the same start and end coordinates if (ray.A.x !== ray.B.x || ray.A.y !== ray.B.y) { if (terrainRulerAvailable) { - measureDistances([{ray}], token, getTokenShape(token), {terrainRulerInitialState: waypoints[waypoints.length - 1]?.dragRulerFinalState}); + measureDistances([{ray}], token, getTokenShape(token), {terrainRulerInitialState: waypoints[waypoints.length - 1]?.dragRulerFinalState, enableTerrainRuler: terrainRulerAvailable}); ray.A.dragRulerVisitedSpaces = ray.terrainRulerVisitedSpaces; ray.A.dragRulerFinalState = ray.terrainRulerFinalState; }