From 151b7f706f90742af2a46f548abcdf24d47b11bf Mon Sep 17 00:00:00 2001 From: Michael Enion Date: Tue, 17 Sep 2024 09:05:04 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix|MovePenalty|Error=20in=20sf2?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Starfinder requires that context parameter be an object, so pass it a blank object. Fix for initializing token failing if TerrainMapper is not present. --- scripts/measurement/MovePenalty.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/measurement/MovePenalty.js b/scripts/measurement/MovePenalty.js index 4fc2fea..f5a932a 100644 --- a/scripts/measurement/MovePenalty.js +++ b/scripts/measurement/MovePenalty.js @@ -132,7 +132,7 @@ export class MovePenalty { * @returns {object} */ static _constructTokenClone(token) { - const actor = new CONFIG.Actor.documentClass(token.actor.toObject()); + const actor = new CONFIG.Actor.documentClass(token.actor.toObject(), {}); const document = new CONFIG.Token.documentClass(token.document.toObject()); const tClone = { document, actor, _original: token }; @@ -495,11 +495,13 @@ export class MovePenalty { */ #initializeTokenClone() { const tClone = this.#localTokenClone; - const Terrain = CONFIG.terrainmapper.Terrain; - const tokenTerrains = Terrain.allOnToken(tClone); - if ( tokenTerrains.length ) { - CONFIG.terrainmapper.Terrain.removeFromTokenLocally(tClone, tokenTerrains, { refresh: false }); - tClone.actor._initialize(); // This is slow + const Terrain = CONFIG.terrainmapper?.Terrain; + if ( Terrain ) { + const tokenTerrains = Terrain.allOnToken(tClone); + if ( tokenTerrains.length ) { + CONFIG.terrainmapper.Terrain.removeFromTokenLocally(tClone, tokenTerrains, { refresh: false }); + tClone.actor._initialize(); // This is slow + } } return tClone; }