From 1cd9069b1549927e1454f98da0b7040c4575dbcc Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sun, 6 Jun 2021 01:30:29 +0300 Subject: [PATCH] get back to using vertices --- modules/lakes.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/modules/lakes.js b/modules/lakes.js index f4bc8c6f..0c91ca67 100644 --- a/modules/lakes.js +++ b/modules/lakes.js @@ -32,20 +32,9 @@ // get array of land cells aroound lake const getShoreline = function (lake) { - const queue = [lake.firstCell]; - const used = [queue[0]]; - const landCellsAround = []; - while (queue.length) { - const q = queue.pop(); - for (const c of pack.cells.c[q]) { - if (used[c]) continue; - used[c] = true; - if (pack.cells.f[c] === lake.i) queue.push(c); - if (pack.cells.h[c] >= 20) landCellsAround.push(c); - } - } - - lake.shoreline = landCellsAround; + const uniqueCells = new Set(); + lake.vertices.forEach(v => pack.vertices.c[v].forEach(c => pack.cells.h[c] >= 20 && uniqueCells.add(c))); + lake.shoreline = [...uniqueCells]; }; const cleanupLakeData = function () {