From ecaf39f29528abf6c7b9bd7a860110bf18582316 Mon Sep 17 00:00:00 2001 From: Will Bennion Date: Thu, 12 Dec 2024 18:20:27 +0000 Subject: [PATCH] Fix error when loading scenes without THT data. --- module.json | 2 +- module/utils/height-map-migrations.mjs | 2 +- test/utils/height-map-migrations.test.mjs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/module.json b/module.json index 1c38080..749ea45 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "name": "terrain-height-tools", "title": "Terrain Height Tools", "description": "Tools for painting grid cells with terrain heights and calculating line of sight with respect to these heights.", - "version": "0.4.5", + "version": "0.4.6", "compatibility": { "minimum": "11", "verified": "11", diff --git a/module/utils/height-map-migrations.mjs b/module/utils/height-map-migrations.mjs index ebfcb26..a005105 100644 --- a/module/utils/height-map-migrations.mjs +++ b/module/utils/height-map-migrations.mjs @@ -53,7 +53,7 @@ const migrations = [ export function migrateData(data, targetVersion = DATA_VERSION) { // If there is no data, return a blank V1 map if (!data) { - return { v: 1, data: {} }; + return { v: 2, data: [] }; } // Try to get the `v` value from the data. If there is no `v` value, then treat it as v0. Then, sequentially apply diff --git a/test/utils/height-map-migrations.test.mjs b/test/utils/height-map-migrations.test.mjs index def9bae..a9d65dd 100644 --- a/test/utils/height-map-migrations.test.mjs +++ b/test/utils/height-map-migrations.test.mjs @@ -240,11 +240,11 @@ describe("migrateData()", () => { it("should correctly initialise a blank HeightMapDataV1 when given undefined", () => { const blank = migrateData(undefined); - assert.deepEqual(blank, { v: 1, data: {} }); + assert.deepEqual(blank, { v: 2, data: [] }); }); it("should correctly initialise a blank HeightMapDataV1 when given null", () => { const blank = migrateData(null); - assert.deepEqual(blank, { v: 1, data: {} }); + assert.deepEqual(blank, { v: 2, data: [] }); }); });