Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
/_bmad
/_bmad-output
.github/agents/bmad-*
.github/prompts/bmad-*
.github/prompts/bmad-*
/.claude
70 changes: 70 additions & 0 deletions public/config/tectonic-templates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"use strict";

const tectonicTemplates = (function () {
return {
tectonic: {
id: 14,
name: "Tectonic",
template: "tectonic",
probability: 10,
config: {
plateCount: 20,
continentalRatio: 0.2,
collisionIntensity: 1.5,
noiseLevel: 0.3,
hotspotCount: 3,
smoothingPasses: 3,
erosionPasses: 5,
seaLevel: 5
}
},
tectonicPangea: {
id: 15,
name: "Tectonic Pangea",
template: "tectonic",
probability: 5,
config: {
plateCount: 8,
continentalRatio: 0.55,
collisionIntensity: 1.2,
noiseLevel: 0.25,
hotspotCount: 3,
smoothingPasses: 4,
erosionPasses: 2,
seaLevel: -3
}
},
tectonicArchipelago: {
id: 16,
name: "Tectonic Archipelago",
template: "tectonic",
probability: 5,
config: {
plateCount: 15,
continentalRatio: 0.25,
collisionIntensity: 0.8,
noiseLevel: 0.35,
hotspotCount: 5,
smoothingPasses: 3,
erosionPasses: 2,
seaLevel: 3
}
},
tectonicRift: {
id: 17,
name: "Tectonic Rift",
template: "tectonic",
probability: 3,
config: {
plateCount: 10,
continentalRatio: 0.4,
collisionIntensity: 1.5,
noiseLevel: 0.3,
hotspotCount: 2,
smoothingPasses: 3,
erosionPasses: 3,
seaLevel: 0
}
}
};
})();
24 changes: 19 additions & 5 deletions public/modules/dynamic/heightmap-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,19 @@ function insertHtml() {

const sections = document.getElementsByClassName("heightmap-selection_container");

sections[0].innerHTML = Object.keys(heightmapTemplates)
const allTemplateKeys = Object.keys(heightmapTemplates);
if (typeof tectonicTemplates !== "undefined") {
allTemplateKeys.push(...Object.keys(tectonicTemplates));
}

sections[0].innerHTML = allTemplateKeys
.map(key => {
const name = heightmapTemplates[key].name;
const isTectonic = typeof tectonicTemplates !== "undefined" && key in tectonicTemplates;
const name = isTectonic ? tectonicTemplates[key].name : heightmapTemplates[key].name;
Math.random = aleaPRNG(initialSeed);
const heights = HeightmapGenerator.fromTemplate(graph, key);
const heights = isTectonic
? HeightmapGenerator.fromTectonic(graph, tectonicTemplates[key].config)
: HeightmapGenerator.fromTemplate(graph, key);

Comment on lines +202 to 210
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heightmap selection screen generates previews by calling HeightmapGenerator.fromTectonic(...) for each tectonic template. Because fromTectonic currently stores window.tectonicGenerator / window.tectonicMetadata, opening the selection dialog can overwrite the active map's tectonic state (or create tectonic state when the current map isn't tectonic). Consider using a preview-only API that doesn't touch globals, or explicitly clearing/restoring those globals around preview rendering.

Copilot uses AI. Check for mistakes.
return /* html */ `<article data-id="${key}" data-seed="${initialSeed}">
<img src="${getHeightmapPreview(heights)}" alt="${name}" />
Expand Down Expand Up @@ -255,6 +263,8 @@ function getSeed() {
}

function getName(id) {
const isTectonic = typeof tectonicTemplates !== "undefined" && id in tectonicTemplates;
if (isTectonic) return tectonicTemplates[id].name;
const isTemplate = id in heightmapTemplates;
return isTemplate ? heightmapTemplates[id].name : precreatedHeightmaps[id].name;
}
Expand All @@ -266,7 +276,10 @@ function getGraph(currentGraph) {
}

function drawTemplatePreview(id) {
const heights = HeightmapGenerator.fromTemplate(graph, id);
const isTectonic = typeof tectonicTemplates !== "undefined" && id in tectonicTemplates;
const heights = isTectonic
? HeightmapGenerator.fromTectonic(graph, tectonicTemplates[id].config)
: HeightmapGenerator.fromTemplate(graph, id);
const dataUrl = getHeightmapPreview(heights);
const article = byId("heightmapSelection").querySelector(`[data-id="${id}"]`);
article.querySelector("img").src = dataUrl;
Expand Down Expand Up @@ -294,8 +307,9 @@ function redrawAll() {
const {id, seed} = article.dataset;
Math.random = aleaPRNG(seed);

const isTectonic = typeof tectonicTemplates !== "undefined" && id in tectonicTemplates;
const isTemplate = id in heightmapTemplates;
if (isTemplate) drawTemplatePreview(id);
if (isTectonic || isTemplate) drawTemplatePreview(id);
else drawPrecreatedHeightmap(id);
}
}
Expand Down
8 changes: 7 additions & 1 deletion public/modules/ui/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,14 @@ function randomizeHeightmapTemplate() {
for (const key in heightmapTemplates) {
templates[key] = heightmapTemplates[key].probability || 0;
}
if (typeof tectonicTemplates !== "undefined") {
for (const key in tectonicTemplates) {
templates[key] = tectonicTemplates[key].probability || 0;
}
}
const template = rw(templates);
const name = heightmapTemplates[template].name;
const isTectonic = typeof tectonicTemplates !== "undefined" && template in tectonicTemplates;
const name = isTectonic ? tectonicTemplates[template].name : heightmapTemplates[template].name;
applyOption(byId("templateInput"), template, name);
}

Expand Down
Loading