From 467c9c2a9ba4f0b2a8c1a33b8ea4126a96176b00 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 28 Jul 2021 01:12:06 +0300 Subject: [PATCH] restore river cells of load --- modules/load.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/load.js b/modules/load.js index 7d7bd482..15a46fa9 100644 --- a/modules/load.js +++ b/modules/load.js @@ -710,8 +710,23 @@ function parseLoadedData(data) { if (version < 1.65) { // v 1.65 changed rivers data for (const river of pack.rivers) { - river.sourceWidth = 0; - // get points and cells + const node = document.getElementById("river" + river.i); + if (node && !river.cells) { + const riverCells = new Set(); + const length = node.getTotalLength() / 2; + const segments = Math.ceil(length / 6); + const increment = length / segments; + for (let i = increment * segments, c = i; i >= 0; i -= increment, c += increment) { + const p1 = node.getPointAtLength(i); + const p2 = node.getPointAtLength(c); + const x = (p1.x + p2.x) / 2; + const y = (p1.y + p2.y) / 2; + const cell = findCell(x, y, 6); + if (cell) riverCells.add(cell); + } + + river.cells = Array.from(riverCells); + } } } })();