From e8801a31cf75780047eb4a56e738c7c324e767d1 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 29 Aug 2018 13:34:18 +0300 Subject: [PATCH 1/5] v. 0.58.02b Emergency drop to fix the issue 114 --- script.js | 73 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/script.js b/script.js index 012e7f94..80cf201f 100644 --- a/script.js +++ b/script.js @@ -1887,8 +1887,8 @@ function fantasyMap() { depression = 0; for (let i = 0; i < land.length; i++) { if (land[i].ctype === 99) continue; - const heights = land[i].neighbors.map(function(n) {return cells[n].height}); - const minHigh = d3.min(heights); + const nHeights = land[i].neighbors.map(function(n) {return cells[n].height}); + const minHigh = d3.min(nHeights); if (land[i].height <= minHigh) { depression++; land[i].pit = land[i].pit ? land[i].pit + 1 : 1; @@ -4714,8 +4714,8 @@ function fantasyMap() { let height = i.height; if (height < 20 && !i.lake) return; if (i.lake) { - const heights = i.neighbors.map(function(e) {if (cells[e].height >= 20) return cells[e].height;}) - const mean = d3.mean(heights); + const nHeights = i.neighbors.map(function(e) {if (cells[e].height >= 20) return cells[e].height;}) + const mean = d3.mean(nHeights); if (!mean) return; height = Math.trunc(mean); if (height < 20 || isNaN(height)) height = 20; @@ -5215,9 +5215,9 @@ function fantasyMap() { cell.river = river; var x = cell.data[0], y = cell.data[1]; dataRiver.push({x, y, cell:index}); - var heights = []; - cell.neighbors.forEach(function(e) {heights.push(cells[e].height);}); - var minId = heights.indexOf(d3.min(heights)); + var nHeights = []; + cell.neighbors.forEach(function(e) {nHeights.push(cells[e].height);}); + var minId = nHeights.indexOf(d3.min(nHeights)); var min = cell.neighbors[minId]; var tx = cells[min].data[0], ty = cells[min].data[1]; if (cells[min].height < 20) { @@ -6161,16 +6161,7 @@ function fantasyMap() { // update data newPoints = [], riversData = [], queue = [], elSelected = ""; points = JSON.parse(data[1]); - if (data[10]) {heights = new Uint8Array(data[10].split(","));} - else { - heights = new Uint8Array(points.length); - for (let i=0; i < points.length; i++) { - const cell = diagram.find(points[i][0], points[i][1]).index; - heights[i] = cells[cell].height; - } - } cells = JSON.parse(data[2]); - manors = JSON.parse(data[3]); if (data[7]) cultures = JSON.parse(data[7]); if (data[7] === undefined) generateCultures(); @@ -6182,39 +6173,49 @@ function fantasyMap() { if (b === undefined) c.base = 0; if (!nameBase[b] || !nameBases[b]) c.base = 0; }); + const graphSizeAdj = 90 / Math.sqrt(cells.length, 2); // adjust to different graphSize // cells validations - cells.forEach(function(c) { + cells.forEach(function(c, d) { // collect points newPoints.push(c.data); - // update old 0-1 height range to new 0-100 range - if (c.height > 1) return; - if (c.height === 1 && c.region === undefined && c.flux === undefined) return; - c.height = Math.trunc(c.height * 100); + // update old 0-1 height range to a new 0-100 range + if (c.height < 1) c.height = Math.trunc(c.height * 100); + if (c.height === 1 && c.flux !== undefined) c.height = 100; // check if there unavailable cultures if (c.culture > cultures.length - 1) cultures.push({name:"AUTO_"+c.culture, color:"#ff0000", base:0}); + + // calculate areas / population for old maps + if (c.height >= 20) { + if (!polygons[d] || !polygons[d].length) return; + if (c.area === undefined || isNaN(c.area)) { + const area = d3.polygonArea(polygons[d]); + c.area = rn(Math.abs(area), 2); + } + if (c.pop === undefined || isNaN(c.pop)) { + let population = 0; + const elevationFactor = Math.pow((100 - c.height) / 100, 3); + population = elevationFactor * c.area * graphSizeAdj; + if (c.region === "neutral") population *= 0.5; + c.pop = rn(population, 1); + } + } }); land = $.grep(cells, function(e) {return (e.height >= 20);}); calculateVoronoi(newPoints); - // calculate areas / population for old maps - const graphSizeAdj = 90 / Math.sqrt(cells.length, 2); // adjust to different graphSize - land.forEach(function(i) { - const p = i.index; - if (!polygons[p] || !polygons[p].length) return; - const area = d3.polygonArea(polygons[p]); - i.area = rn(Math.abs(area), 2); - if (i.pop === undefined) { - let population = 0; - const elevationFactor = Math.pow((100 - i.height) / 100, 3); - population = elevationFactor * i.area * graphSizeAdj; - if (i.region === "neutral") population *= 0.5; - i.pop = rn(population, 1); - } - }); + // get heights Uint8Array + if (data[10]) {heights = new Uint8Array(data[10].split(","));} + else { + heights = new Uint8Array(points.length); + for (let i=0; i < points.length; i++) { + const cell = diagram.find(points[i][0], points[i][1]).index; + heights[i] = cells[cell].height; + } + } // restore Heightmap customization mode if (customization === 1) { From 0f79271c7f4dce01f8a7195e51ad522eaf9404bb Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 29 Aug 2018 13:35:06 +0300 Subject: [PATCH 2/5] v. 0.58.03b --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 714d9b56..471381aa 100644 --- a/index.html +++ b/index.html @@ -32,8 +32,8 @@ - - + + @@ -1143,5 +1143,5 @@ - + From efd6a0eda32d54fa805e3490053bf7453d4b6b31 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 29 Aug 2018 16:10:03 +0300 Subject: [PATCH 3/5] v. 0.59.04b --- script.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/script.js b/script.js index 80cf201f..4943c1fc 100644 --- a/script.js +++ b/script.js @@ -6166,12 +6166,20 @@ function fantasyMap() { if (data[7]) cultures = JSON.parse(data[7]); if (data[7] === undefined) generateCultures(); + // place random point + function placePoint() { + const x = Math.floor(Math.random() * graphWidth * 0.8 + graphWidth * 0.1); + const y = Math.floor(Math.random() * graphHeight * 0.8 + graphHeight * 0.1); + return [x, y]; + } + // ensure each culure has a valid namesbase assigned, if not assign first base if (!nameBase[0]) applyDefaultNamesData(); cultures.forEach(function(c) { const b = c.base; if (b === undefined) c.base = 0; if (!nameBase[b] || !nameBases[b]) c.base = 0; + if (c.center === undefined) c.center = placePoint(); }); const graphSizeAdj = 90 / Math.sqrt(cells.length, 2); // adjust to different graphSize @@ -6182,18 +6190,23 @@ function fantasyMap() { // update old 0-1 height range to a new 0-100 range if (c.height < 1) c.height = Math.trunc(c.height * 100); - if (c.height === 1 && c.flux !== undefined) c.height = 100; + if (c.height === 1 && c.region !== undefined && c.flux !== undefined) c.height = 100; + + // check if there are any unavailable cultures + if (c.culture > cultures.length - 1) { + const center = [c.data[0], c.data[1]]; + const cult = {name:"AUTO_"+c.culture, color:"#ff0000", base:0, center}; + cultures.push(cult); + } - // check if there unavailable cultures - if (c.culture > cultures.length - 1) cultures.push({name:"AUTO_"+c.culture, color:"#ff0000", base:0}); - - // calculate areas / population for old maps if (c.height >= 20) { if (!polygons[d] || !polygons[d].length) return; + // calculate area if (c.area === undefined || isNaN(c.area)) { const area = d3.polygonArea(polygons[d]); c.area = rn(Math.abs(area), 2); } + // calculate population if (c.pop === undefined || isNaN(c.pop)) { let population = 0; const elevationFactor = Math.pow((100 - c.height) / 100, 3); @@ -6201,6 +6214,8 @@ function fantasyMap() { if (c.region === "neutral") population *= 0.5; c.pop = rn(population, 1); } + // if culture is undefined, set to 0 + if (c.culture === undefined || isNaN(c.culture)) c.culture = 0; } }); From 5ddbfed1e49c21de3885496ae0d39f3eac8e5ca2 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 29 Aug 2018 18:19:26 +0300 Subject: [PATCH 4/5] v. 0.59.05b --- script.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 4943c1fc..364a7af1 100644 --- a/script.js +++ b/script.js @@ -5734,11 +5734,13 @@ function fantasyMap() { // downalod map as SVG or PNG file function saveAsImage(type) { console.time("saveAsImage"); - // get all used fonts + const webSafe = ["Georgia", "Times+New+Roman", "Comic+Sans+MS", "Lucida+Sans+Unicode", "Courier+New", "Verdana", "Arial", "Impact"]; + // get non-standard fonts used for labels to fetch them from web const fontsInUse = []; // to store fonts currently in use labels.selectAll("g").each(function(d) { const font = d3.select(this).attr("data-font"); if (!font) return; + if (webSafe.indexOf(font) !== -1) return; // do not fetch web-safe fonts if (fontsInUse.indexOf(font) === -1) fontsInUse.push(font); }); const fontsToLoad = "https://fonts.googleapis.com/css?family=" + fontsInUse.join("|"); From 73493a791db3b95b6ed6a8f96db6ffdbe6c17854 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sat, 1 Sep 2018 00:32:46 +0300 Subject: [PATCH 5/5] v. 0.50.06b --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 471381aa..b85594a1 100644 --- a/index.html +++ b/index.html @@ -32,8 +32,8 @@ - - + + @@ -159,7 +159,7 @@
Azgaar's
Fantasy Map Generator
-
v. 0.58b
+
v. 0.59b

LOADING...

@@ -1143,5 +1143,5 @@ - +