diff --git a/CHANGELOG.md b/CHANGELOG.md index bbfb1d2..f4a3172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## 1.11.2 +### Bugfixes +- Fixed a memory leak that could cause the rule to slow down after using the pathfinding functionality for a while + +### Misc +- GMs are now always allowed to use the pathfinding tool. The setting now only prevents players from using it. + +### Compatibility +- Drag Ruler's generic speed provider is now aware of good defaults for Dungeonslayers 4 + + ## 1.11.1 ### Bugfixes - Fixed a bug that would cause the pathfinding algorithm to make tokens of size 2 and 4 to take an unnecessary step diff --git a/js/keybindings.js b/js/keybindings.js index cfa5b49..c2747e2 100644 --- a/js/keybindings.js +++ b/js/keybindings.js @@ -52,15 +52,14 @@ export function registerKeybindings() { precedence: -1, }); - if (game.settings.get(settingsKey, "allowPathfinding")) { - game.keybindings.register(settingsKey, "togglePathfinding", { - name: "drag-ruler.keybindings.togglePathfinding.name", - hint: "drag-ruler.keybindings.togglePathfinding.hint", - onDown: handleTogglePathfinding, - onUp: handleTogglePathfinding, - precedence: -1, - }); - } + game.keybindings.register(settingsKey, "togglePathfinding", { + name: "drag-ruler.keybindings.togglePathfinding.name", + hint: "drag-ruler.keybindings.togglePathfinding.hint", + onDown: handleTogglePathfinding, + onUp: handleTogglePathfinding, + precedence: -1, + restricted: !game.settings.get(settingsKey, "allowPathfinding"), + }); } function handleDeleteWaypoint() { diff --git a/js/pathfinding.js b/js/pathfinding.js index 703a55a..f8182d9 100644 --- a/js/pathfinding.js +++ b/js/pathfinding.js @@ -11,7 +11,7 @@ let use5105 = false; let gridlessPathfinder = undefined; export function isPathfindingEnabled() { - if (!game.settings.get(settingsKey, "allowPathfinding")) + if (!game.user.isGM && !game.settings.get(settingsKey, "allowPathfinding")) return false; return game.settings.get(settingsKey, "autoPathfinding") != togglePathfinding; } diff --git a/js/settings.js b/js/settings.js index 7ba23b2..51caa58 100644 --- a/js/settings.js +++ b/js/settings.js @@ -1,5 +1,6 @@ import {availableSpeedProviders, currentSpeedProvider, getDefaultSpeedProvider, updateSpeedProvider} from "./api.js"; import {SpeedProvider} from "./speed_provider.js" +import { early_isGM } from "./util.js"; export const settingsKey = "drag-ruler"; @@ -96,7 +97,7 @@ export function registerSettings() { name: "drag-ruler.settings.autoPathfinding.name", hint: "drag-ruler.settings.autoPathfinding.hint", scpoe: "client", - config: true, + config: early_isGM(), type: Boolean, defualt: false, }); diff --git a/js/systems.js b/js/systems.js index 7bca86d..b14acd2 100644 --- a/js/systems.js +++ b/js/systems.js @@ -17,6 +17,8 @@ export function getDefaultSpeedAttribute() { return "actor.data.data.movement.walk.value"; case "swade": return "actor.data.data.stats.speed.adjusted"; + case "ds4": + return "actor.data.data.combatValues.movement.total"; } return "" } @@ -32,6 +34,7 @@ export function getDefaultDashMultiplier() { case "D35E": case "sfrpg": case "shadowrun5e": + case "ds4": return 2 case "CoC7": return 5; diff --git a/js/util.js b/js/util.js index f9bf828..ebcb2a0 100644 --- a/js/util.js +++ b/js/util.js @@ -272,3 +272,10 @@ export function getMeasurePosition() { const measurePosition = {x: mousePosition.x + rulerOffset.x, y: mousePosition.y + rulerOffset.y}; return measurePosition; } + +// isGM function for use during loading when game.user isn't available yet +export function early_isGM() { + const level = game.data.users.find(u => u._id == game.data.userId).role; + const gmLevel = CONST.USER_ROLES.ASSISTANT; + return level >= gmLevel; +} diff --git a/lang/de.json b/lang/de.json index 424a33b..35f9557 100644 --- a/lang/de.json +++ b/lang/de.json @@ -48,8 +48,8 @@ }, "settings": { "allowPathfinding": { - "name": "Wegfindung aktivieren", - "hint": "Aktiviert Drag Ruler's Wegfindungsfunktion. Bitte beachte, dass die Wegfindung Wege durch unerkundeten Nebel des Kriegs und Ätherische Wände berechnen kann. Dies kann deinen Spielern Geheimnisse lüften, von denen sie noch nicht erfahren sollten." + "name": "Wegfindung für Spieler erlauben", + "hint": "Erlaubt es Spielern die Wegfindungs zu benutzen. Bitte beachte, dass die Wegfindung Wege durch unerkundeten Nebel des Kriegs und Ätherische Wände berechnen kann. Dies kann deinen Spielern Geheimnisse lüften, von denen sie noch nicht erfahren sollten." }, "alwaysShowSpeedForPCs": { "name": "Geschwindigkeit von Spielercharakteren für jeden anzeigen", diff --git a/lang/en.json b/lang/en.json index fae78e3..afdab5d 100644 --- a/lang/en.json +++ b/lang/en.json @@ -48,8 +48,8 @@ }, "settings": { "allowPathfinding": { - "name": "Enable pathfinding feature", - "hint": "Enables Drag Ruler's pathfinding functionality in this world. Be aware that pathfinding can route through unexplored fog of war and Ethereal Walls, which might reveal secrets to your players ahead of time." + "name": "Allow pathfinding for players", + "hint": "Allows players to use Drag Ruler's pathfinding functionality in this world. Be aware that pathfinding can route through unexplored fog of war and Ethereal Walls, which might reveal secrets to your players ahead of time." }, "alwaysShowSpeedForPCs": { "name": "Show PC speed to everyone", diff --git a/module.json b/module.json index d677e4f..f1d01fa 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "name": "drag-ruler", "title": "Drag Ruler", "description": "When dragging a token displays a ruler showing how far you've moved that token.", - "version": "1.11.1", + "version": "1.11.2", "minimumCoreVersion" : "9.245", "compatibleCoreVersion" : "9", "authors": [ @@ -65,7 +65,7 @@ ], "socket": true, "url": "https://github.com/manuelVo/foundryvtt-drag-ruler", - "download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.11.1.zip", + "download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.11.2.zip", "manifest": "https://raw.githubusercontent.com/manuelVo/foundryvtt-drag-ruler/master/module.json", "readme": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/README.md", "changelog": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/CHANGELOG.md",