fix: add rivers when rivers array is empty

This commit is contained in:
Azgaar 2021-08-01 13:31:54 +03:00
parent f57a72d764
commit 078b83633f
2 changed files with 2 additions and 2 deletions

View file

@ -79,7 +79,7 @@ function createRiver() {
const riverCells = createRiver.cells;
if (riverCells.length < 2) return tip("Add at least 2 cells", false, "error");
const riverId = last(rivers).i + 1;
const riverId = rivers.length ? last(rivers).i + 1 : 1;
const parent = cells.r[last(riverCells)] || riverId;
riverCells.forEach(cell => {

View file

@ -539,7 +539,7 @@ function addRiverOnClick() {
const {alterHeights, resolveDepressions, addMeandering, getRiverPath, getBasin, getName, getType, getWidth, getOffset, getApproximateLength} = Rivers;
const riverCells = [];
let riverId = last(rivers).i + 1;
let riverId = rivers.length ? last(rivers).i + 1 : 1;
let parent = riverId;
const initialFlux = grid.cells.prec[cells.g[i]];