diff --git a/index.css b/index.css
index 12f94071..bfd1ed67 100644
--- a/index.css
+++ b/index.css
@@ -980,7 +980,7 @@ fieldset {
#templateBody > div > span {
float: right;
- margin: 0 1px 0 0.5px;
+ margin-inline: 1px;
}
#templateBody > div > i {
@@ -989,10 +989,9 @@ fieldset {
#templateBody input,
#templateBody select {
- width: 4em;
+ width: 4.5em;
height: 1em;
border: 0;
- font-size: 0.95em;
background-color: #ffffff95;
color: #05044d;
font-style: italic;
diff --git a/index.html b/index.html
index 34fdd323..cd8e9394 100644
--- a/index.html
+++ b/index.html
@@ -4055,9 +4055,10 @@
onclick="wiki('Heightmap-template-editor')"
>
@@ -7824,7 +7825,7 @@
-
+
@@ -7857,16 +7858,16 @@
-
-
-
+
+
+
-
+
diff --git a/main.js b/main.js
index 36a59cae..69323e92 100644
--- a/main.js
+++ b/main.js
@@ -692,7 +692,7 @@ async function generate(options) {
applyMapSize();
randomizeOptions();
- if (shouldRegenerateGrid(grid)) grid = precreatedGraph || generateGrid();
+ if (shouldRegenerateGrid(grid, precreatedSeed)) grid = precreatedGraph || generateGrid();
else delete grid.cells.h;
grid.cells.h = await HeightmapGenerator.generate(grid);
@@ -774,12 +774,10 @@ async function generate(options) {
function setSeed(precreatedSeed) {
if (!precreatedSeed) {
const first = !mapHistory[0];
- const url = new URL(window.location.href);
- const params = url.searchParams;
- const urlSeed = url.searchParams.get("seed");
+ const params = new URL(window.location.href).searchParams;
+ const urlSeed = params.get("seed");
if (first && params.get("from") === "MFCG" && urlSeed.length === 13) seed = urlSeed.slice(0, -4);
else if (first && urlSeed) seed = urlSeed;
- else if (optionsSeed.value && optionsSeed.value != seed) seed = optionsSeed.value;
else seed = generateSeed();
} else {
seed = precreatedSeed;
diff --git a/modules/dynamic/heightmap-selection.js b/modules/dynamic/heightmap-selection.js
index 9b78d118..2fb3ba7c 100644
--- a/modules/dynamic/heightmap-selection.js
+++ b/modules/dynamic/heightmap-selection.js
@@ -262,7 +262,7 @@ function getName(id) {
}
function getGraph(currentGraph) {
- const newGraph = shouldRegenerateGrid(currentGraph) ? generateGrid() : deepCopy(currentGraph);
+ const newGraph = shouldRegenerateGrid(currentGraph, seed) ? generateGrid() : deepCopy(currentGraph);
delete newGraph.cells.h;
return newGraph;
}
diff --git a/modules/ui/general.js b/modules/ui/general.js
index fa030418..238dd2f1 100644
--- a/modules/ui/general.js
+++ b/modules/ui/general.js
@@ -452,7 +452,7 @@ function unlock(id) {
// check if option is locked
function locked(id) {
const lockEl = document.getElementById("lock_" + id);
- return lockEl.dataset.locked == 1;
+ return lockEl.dataset.locked === "1";
}
// return key value stored in localStorage or null
diff --git a/modules/ui/heightmap-editor.js b/modules/ui/heightmap-editor.js
index 7f83354a..07216f90 100644
--- a/modules/ui/heightmap-editor.js
+++ b/modules/ui/heightmap-editor.js
@@ -1041,8 +1041,10 @@ function editHeightmap(options) {
const steps = byId("templateBody").querySelectorAll("#templateBody > div");
if (!steps.length) return;
- const seed = byId("templateSeed").value;
- if (seed) Math.random = aleaPRNG(seed);
+ const currentSeed = byId("templateSeed").value;
+ const seed = (locked("templateSeed") && currentSeed) || generateSeed();
+ Math.random = aleaPRNG(seed);
+ byId("templateSeed").value = seed;
grid.cells.h = createTypedArray({maxValue: 100, length: grid.points.length});
HeightmapGenerator.setGraph(grid);
diff --git a/modules/ui/options.js b/modules/ui/options.js
index c072d1cb..f8ccfb38 100644
--- a/modules/ui/options.js
+++ b/modules/ui/options.js
@@ -257,8 +257,8 @@ function testSpeaker() {
}
function generateMapWithSeed() {
- if (optionsSeed.value == seed) return tip("The current map already has this seed", false, "error");
- regeneratePrompt();
+ if (optionsSeed.value === seed) return tip("The current map already has this seed", false, "error");
+ regeneratePrompt({seed: optionsSeed.value});
}
function showSeedHistoryDialog() {
@@ -288,7 +288,7 @@ function restoreSeed(id) {
if (locked("template")) unlock("template");
- regeneratePrompt();
+ regeneratePrompt({seed});
}
function restoreDefaultZoomExtent() {
diff --git a/utils/graphUtils.js b/utils/graphUtils.js
index 75b64253..c6315088 100644
--- a/utils/graphUtils.js
+++ b/utils/graphUtils.js
@@ -2,7 +2,9 @@
// FMG utils related to graph
// check if new grid graph should be generated or we can use the existing one
-function shouldRegenerateGrid(grid) {
+function shouldRegenerateGrid(grid, expectedSeed) {
+ if (expectedSeed && expectedSeed !== grid.seed) return true;
+
const cellsDesired = +byId("pointsInput").dataset.cells;
if (cellsDesired !== grid.cellsDesired) return true;
@@ -17,7 +19,7 @@ function generateGrid() {
Math.random = aleaPRNG(seed); // reset PRNG
const {spacing, cellsDesired, boundary, points, cellsX, cellsY} = placePoints();
const {cells, vertices} = calculateVoronoi(points, boundary);
- return {spacing, cellsDesired, boundary, points, cellsX, cellsY, cells, vertices};
+ return {spacing, cellsDesired, boundary, points, cellsX, cellsY, cells, vertices, seed};
}
// place random points to calculate Voronoi diagram
@@ -96,7 +98,10 @@ function getJitteredGrid(width, height, spacing) {
// return cell index on a regular square grid
function findGridCell(x, y, grid) {
- return Math.floor(Math.min(y / grid.spacing, grid.cellsY - 1)) * grid.cellsX + Math.floor(Math.min(x / grid.spacing, grid.cellsX - 1));
+ return (
+ Math.floor(Math.min(y / grid.spacing, grid.cellsY - 1)) * grid.cellsX +
+ Math.floor(Math.min(x / grid.spacing, grid.cellsX - 1))
+ );
}
// return array of cell indexes in radius on a regular square grid
@@ -246,7 +251,14 @@ void (function addFindAll() {
i++;
// Stop searching if this quadrant can’t contain a closer node.
- if (!(t.node = t.q.node) || (t.x1 = t.q.x0) > t.x3 || (t.y1 = t.q.y0) > t.y3 || (t.x2 = t.q.x1) < t.x0 || (t.y2 = t.q.y1) < t.y0) continue;
+ if (
+ !(t.node = t.q.node) ||
+ (t.x1 = t.q.x0) > t.x3 ||
+ (t.y1 = t.q.y0) > t.y3 ||
+ (t.x2 = t.q.x1) < t.x0 ||
+ (t.y2 = t.q.y1) < t.y0
+ )
+ continue;
// Bisect the current quadrant.
if (t.node.length) {
diff --git a/versioning.js b/versioning.js
index 87a04f2d..222364aa 100644
--- a/versioning.js
+++ b/versioning.js
@@ -1,7 +1,7 @@
"use strict";
// version and caching control
-const version = "1.89.00"; // generator version, update each time
+const version = "1.89.00";
{
document.title += " v" + version;