mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-04-02 21:47:24 +02:00
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:
parent
09a4f17270
commit
32b2762f6c
1 changed files with 5 additions and 4 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue