Use local Map for zone backup instead of mutating zone objects

Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-18 22:18:34 +00:00
parent 09a4f17270
commit 32b2762f6c

View file

@ -330,9 +330,10 @@ function editHeightmap(options) {
c.y = p[1]; c.y = p[1];
} }
const zoneGridCellsMap = new Map();
for (const zone of pack.zones) { for (const zone of pack.zones) {
if (!zone.cells || !zone.cells.length) continue; if (!zone.cells || !zone.cells.length) continue;
zone.gridCells = zone.cells.map(i => pack.cells.g[i]); zoneGridCellsMap.set(zone.i, zone.cells.map(i => pack.cells.g[i]));
} }
Features.markupGrid(); Features.markupGrid();
@ -451,9 +452,9 @@ function editHeightmap(options) {
} }
for (const zone of pack.zones) { for (const zone of pack.zones) {
if (!zone.gridCells || !zone.gridCells.length) continue; const gridCells = zoneGridCellsMap.get(zone.i);
zone.cells = zone.gridCells.flatMap(g => gridToPackMap.get(g) || []); if (!gridCells || !gridCells.length) continue;
delete zone.gridCells; zone.cells = gridCells.flatMap(g => gridToPackMap.get(g) || []);
} }
// recalculate ice // recalculate ice