From b822ada78218eecbc7365aee2c852e3ae8fc25ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Sat, 29 Jan 2022 13:39:42 +0100 Subject: [PATCH] Re-check for grid settings everytime pathfinding is restarted --- src/main.js | 2 -- src/pathfinding.js | 11 ++++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main.js b/src/main.js index 12f2aa5..5b67e6e 100644 --- a/src/main.js +++ b/src/main.js @@ -7,7 +7,6 @@ import {disableSnap, registerKeybindings} from "./keybindings.js"; import {libWrapper} from "./libwrapper_shim.js"; import {performMigrations} from "./migration.js" import {removeLastHistoryEntryIfAt, resetMovementHistory} from "./movement_tracking.js"; -import { initializePathfinding } from "./pathfinding.js"; import {extendRuler} from "./ruler.js"; import {registerSettings, RightClickAction, settingsKey} from "./settings.js" import {recalculate} from "./socket.js"; @@ -35,7 +34,6 @@ Hooks.once("init", () => { }) Hooks.once("ready", () => { - initializePathfinding(); performMigrations() checkDependencies(); Hooks.callAll("dragRuler.ready", SpeedProvider) diff --git a/src/pathfinding.js b/src/pathfinding.js index 721aea5..294f57f 100644 --- a/src/pathfinding.js +++ b/src/pathfinding.js @@ -5,13 +5,6 @@ import {settingsKey} from "./settings.js"; let cachedNodes = undefined; let use5105 = false; -export function initializePathfinding() { - if (game.system.id === "pf2e") - use5105 = true; - if (canvas.grid.diagonalRule === "5105") - use5105 = true; -} - export function isPathfindingEnabled() { if (canvas.grid.type !== CONST.GRID_TYPES.SQUARE) return false; @@ -92,6 +85,10 @@ function* neighbors(pos) { } function calculatePath(from, to) { + if (game.system.id === "pf2e") + use5105 = true; + if (canvas.grid.diagonalRule === "5105") + use5105 = true; // On 5/10/5 it's possible that we'd need to start on layer 1 if there is a previous route // However I cannot think of any case where not doing it would lead to a non-optimal path, so I've ommited that const nextNodes = [{node: getNode(to), cost: 0, estimated: estimateCost(to, from), previous: null}];