From eb78b332a6f6f818b9bcf13bb127228351016d7b Mon Sep 17 00:00:00 2001 From: StempunkDev Date: Thu, 15 Jan 2026 00:02:05 +0100 Subject: [PATCH] feat: add compactPackData function to filter out undefined glaciers and icebergs --- public/modules/io/save.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/public/modules/io/save.js b/public/modules/io/save.js index 4b60fa71..fd69f495 100644 --- a/public/modules/io/save.js +++ b/public/modules/io/save.js @@ -38,6 +38,12 @@ async function saveMap(method) { } function prepareMapData() { + + function compactPackData() { + // Place all the compaction functions here + pack.ice.glaciers = pack.ice.glaciers.filter(g => g !== undefined); + pack.ice.icebergs = pack.ice.icebergs.filter(i => i !== undefined); + } const date = new Date(); const dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); const license = "File can be loaded in azgaar.github.io/Fantasy-Map-Generator"; @@ -89,6 +95,8 @@ function prepareMapData() { const serializedSVG = new XMLSerializer().serializeToString(cloneEl); + compactPackData(); + const {spacing, cellsX, cellsY, boundary, points, features, cellsDesired} = grid; const gridGeneral = JSON.stringify({spacing, cellsX, cellsY, boundary, points, features, cellsDesired}); const packFeatures = JSON.stringify(pack.features);