From 41c89799256bae754d5c59bb9e49a8bdb20db280 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 1 Feb 2022 10:32:54 +0100 Subject: [PATCH 1/3] Add support for Dungeonslayers 4 (#146) --- src/systems.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/systems.js b/src/systems.js index 7bca86d..b14acd2 100644 --- a/src/systems.js +++ b/src/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; From a252da620a550e4e0d4c06c8256ea6c643c962d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Tue, 1 Feb 2022 11:33:33 +0100 Subject: [PATCH 2/3] Always allow the GM to use pathfinding --- lang/de.json | 4 ++-- lang/en.json | 4 ++-- src/keybindings.js | 17 ++++++++--------- src/pathfinding.js | 2 +- src/settings.js | 3 ++- src/util.js | 7 +++++++ 6 files changed, 22 insertions(+), 15 deletions(-) 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/src/keybindings.js b/src/keybindings.js index cfa5b49..c2747e2 100644 --- a/src/keybindings.js +++ b/src/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/src/pathfinding.js b/src/pathfinding.js index 35e533f..507ae3f 100644 --- a/src/pathfinding.js +++ b/src/pathfinding.js @@ -10,7 +10,7 @@ let use5105 = false; export function isPathfindingEnabled() { if (canvas.grid.type === CONST.GRID_TYPES.GRIDLESS) return false; - 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/src/settings.js b/src/settings.js index 7ba23b2..51caa58 100644 --- a/src/settings.js +++ b/src/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/src/util.js b/src/util.js index f9bf828..ebcb2a0 100644 --- a/src/util.js +++ b/src/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; +} From 9d5dccb50403062592e1f5cc0706f9b977c483d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Tue, 1 Feb 2022 11:35:46 +0100 Subject: [PATCH 3/3] Release v1.11.2 --- CHANGELOG.md | 11 +++++++++++ module.json | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) 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/module.json b/module.json index 1f33ae9..fa03a5f 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",