From e2e7f2e0760710688209d89d7d4b7c746f2ceb37 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Tue, 19 Nov 2019 23:42:08 +0300 Subject: [PATCH] v1.22.18 --- main.js | 4 ++-- modules/ui/tools.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index c7595bef..75fd8841 100644 --- a/main.js +++ b/main.js @@ -1139,13 +1139,13 @@ function rankCells() { cells.s = new Int16Array(cells.i.length); // cell suitability array cells.pop = new Float32Array(cells.i.length); // cell population array - const flMean = d3.median(cells.fl.filter(f => f)), flMax = d3.max(cells.fl) + d3.max(cells.conf); // to normalize flux + const flMean = d3.median(cells.fl.filter(f => f)) || 0, flMax = d3.max(cells.fl) + d3.max(cells.conf); // to normalize flux const areaMean = d3.mean(cells.area); // to adjust population by cell area for (const i of cells.i) { let s = +biomesData.habitability[cells.biome[i]]; // base suitability derived from biome habitability if (!s) continue; // uninhabitable biomes has 0 suitability - s += normalize(cells.fl[i] + cells.conf[i], flMean, flMax) * 250; // big rivers and confluences are valued + if (flMean) s += normalize(cells.fl[i] + cells.conf[i], flMean, flMax) * 250; // big rivers and confluences are valued s -= (cells.h[i] - 50) / 5; // low elevation is valued, high is not; if (cells.t[i] === 1) { diff --git a/modules/ui/tools.js b/modules/ui/tools.js index f3a3071d..ba464ab2 100644 --- a/modules/ui/tools.js +++ b/modules/ui/tools.js @@ -114,7 +114,7 @@ function regenerateBurgs() { if (burgsTree.find(x, y, s) !== undefined) continue; // to close to existing burg const state = cells.state[cell]; - const capital = state > 0 ? !states[state].capital : 0; // if state doesn't have capital, make this burg a capital, no capital for neutral lands + const capital = state && !states[state].capital; // if state doesn't have capital, make this burg a capital, no capital for neutral lands if (capital) {states[state].capital = id; states[state].center = cell;} const culture = cells.culture[cell];