mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
v. 0.58.02b
Emergency drop to fix the issue 114
This commit is contained in:
parent
f3e36dc455
commit
e8801a31cf
1 changed files with 37 additions and 36 deletions
73
script.js
73
script.js
|
|
@ -1887,8 +1887,8 @@ function fantasyMap() {
|
||||||
depression = 0;
|
depression = 0;
|
||||||
for (let i = 0; i < land.length; i++) {
|
for (let i = 0; i < land.length; i++) {
|
||||||
if (land[i].ctype === 99) continue;
|
if (land[i].ctype === 99) continue;
|
||||||
const heights = land[i].neighbors.map(function(n) {return cells[n].height});
|
const nHeights = land[i].neighbors.map(function(n) {return cells[n].height});
|
||||||
const minHigh = d3.min(heights);
|
const minHigh = d3.min(nHeights);
|
||||||
if (land[i].height <= minHigh) {
|
if (land[i].height <= minHigh) {
|
||||||
depression++;
|
depression++;
|
||||||
land[i].pit = land[i].pit ? land[i].pit + 1 : 1;
|
land[i].pit = land[i].pit ? land[i].pit + 1 : 1;
|
||||||
|
|
@ -4714,8 +4714,8 @@ function fantasyMap() {
|
||||||
let height = i.height;
|
let height = i.height;
|
||||||
if (height < 20 && !i.lake) return;
|
if (height < 20 && !i.lake) return;
|
||||||
if (i.lake) {
|
if (i.lake) {
|
||||||
const heights = i.neighbors.map(function(e) {if (cells[e].height >= 20) return cells[e].height;})
|
const nHeights = i.neighbors.map(function(e) {if (cells[e].height >= 20) return cells[e].height;})
|
||||||
const mean = d3.mean(heights);
|
const mean = d3.mean(nHeights);
|
||||||
if (!mean) return;
|
if (!mean) return;
|
||||||
height = Math.trunc(mean);
|
height = Math.trunc(mean);
|
||||||
if (height < 20 || isNaN(height)) height = 20;
|
if (height < 20 || isNaN(height)) height = 20;
|
||||||
|
|
@ -5215,9 +5215,9 @@ function fantasyMap() {
|
||||||
cell.river = river;
|
cell.river = river;
|
||||||
var x = cell.data[0], y = cell.data[1];
|
var x = cell.data[0], y = cell.data[1];
|
||||||
dataRiver.push({x, y, cell:index});
|
dataRiver.push({x, y, cell:index});
|
||||||
var heights = [];
|
var nHeights = [];
|
||||||
cell.neighbors.forEach(function(e) {heights.push(cells[e].height);});
|
cell.neighbors.forEach(function(e) {nHeights.push(cells[e].height);});
|
||||||
var minId = heights.indexOf(d3.min(heights));
|
var minId = nHeights.indexOf(d3.min(nHeights));
|
||||||
var min = cell.neighbors[minId];
|
var min = cell.neighbors[minId];
|
||||||
var tx = cells[min].data[0], ty = cells[min].data[1];
|
var tx = cells[min].data[0], ty = cells[min].data[1];
|
||||||
if (cells[min].height < 20) {
|
if (cells[min].height < 20) {
|
||||||
|
|
@ -6161,16 +6161,7 @@ function fantasyMap() {
|
||||||
// update data
|
// update data
|
||||||
newPoints = [], riversData = [], queue = [], elSelected = "";
|
newPoints = [], riversData = [], queue = [], elSelected = "";
|
||||||
points = JSON.parse(data[1]);
|
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]);
|
cells = JSON.parse(data[2]);
|
||||||
|
|
||||||
manors = JSON.parse(data[3]);
|
manors = JSON.parse(data[3]);
|
||||||
if (data[7]) cultures = JSON.parse(data[7]);
|
if (data[7]) cultures = JSON.parse(data[7]);
|
||||||
if (data[7] === undefined) generateCultures();
|
if (data[7] === undefined) generateCultures();
|
||||||
|
|
@ -6182,39 +6173,49 @@ function fantasyMap() {
|
||||||
if (b === undefined) c.base = 0;
|
if (b === undefined) c.base = 0;
|
||||||
if (!nameBase[b] || !nameBases[b]) 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 validations
|
||||||
cells.forEach(function(c) {
|
cells.forEach(function(c, d) {
|
||||||
// collect points
|
// collect points
|
||||||
newPoints.push(c.data);
|
newPoints.push(c.data);
|
||||||
|
|
||||||
// update old 0-1 height range to new 0-100 range
|
// update old 0-1 height range to a new 0-100 range
|
||||||
if (c.height > 1) return;
|
if (c.height < 1) c.height = Math.trunc(c.height * 100);
|
||||||
if (c.height === 1 && c.region === undefined && c.flux === undefined) return;
|
if (c.height === 1 && c.flux !== undefined) c.height = 100;
|
||||||
c.height = Math.trunc(c.height * 100);
|
|
||||||
|
|
||||||
// check if there unavailable cultures
|
// check if there unavailable cultures
|
||||||
if (c.culture > cultures.length - 1) cultures.push({name:"AUTO_"+c.culture, color:"#ff0000", base:0});
|
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);});
|
land = $.grep(cells, function(e) {return (e.height >= 20);});
|
||||||
calculateVoronoi(newPoints);
|
calculateVoronoi(newPoints);
|
||||||
|
|
||||||
// calculate areas / population for old maps
|
// get heights Uint8Array
|
||||||
const graphSizeAdj = 90 / Math.sqrt(cells.length, 2); // adjust to different graphSize
|
if (data[10]) {heights = new Uint8Array(data[10].split(","));}
|
||||||
land.forEach(function(i) {
|
else {
|
||||||
const p = i.index;
|
heights = new Uint8Array(points.length);
|
||||||
if (!polygons[p] || !polygons[p].length) return;
|
for (let i=0; i < points.length; i++) {
|
||||||
const area = d3.polygonArea(polygons[p]);
|
const cell = diagram.find(points[i][0], points[i][1]).index;
|
||||||
i.area = rn(Math.abs(area), 2);
|
heights[i] = cells[cell].height;
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// restore Heightmap customization mode
|
// restore Heightmap customization mode
|
||||||
if (customization === 1) {
|
if (customization === 1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue