mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
fix: clean cultures on regeneration, v1.89.07
This commit is contained in:
parent
acbe839ee7
commit
d40cab2e28
7 changed files with 41 additions and 35 deletions
|
|
@ -7845,10 +7845,10 @@
|
||||||
<script src="modules/river-generator.js"></script>
|
<script src="modules/river-generator.js"></script>
|
||||||
<script src="modules/lakes.js"></script>
|
<script src="modules/lakes.js"></script>
|
||||||
<script src="modules/names-generator.js?v=1.87.14"></script>
|
<script src="modules/names-generator.js?v=1.87.14"></script>
|
||||||
<script src="modules/cultures-generator.js?v=1.89.06"></script>
|
<script src="modules/cultures-generator.js?v=1.89.07"></script>
|
||||||
<script src="modules/burgs-and-states.js?v=1.89.05"></script>
|
<script src="modules/burgs-and-states.js?v=1.89.07"></script>
|
||||||
<script src="modules/routes-generator.js"></script>
|
<script src="modules/routes-generator.js"></script>
|
||||||
<script src="modules/religions-generator.js?v=1.89.01"></script>
|
<script src="modules/religions-generator.js?v=1.89.07"></script>
|
||||||
<script src="modules/military-generator.js"></script>
|
<script src="modules/military-generator.js"></script>
|
||||||
<script src="modules/markers-generator.js?v=1.87.13"></script>
|
<script src="modules/markers-generator.js?v=1.87.13"></script>
|
||||||
<script src="modules/coa-generator.js"></script>
|
<script src="modules/coa-generator.js"></script>
|
||||||
|
|
@ -7867,7 +7867,7 @@
|
||||||
|
|
||||||
<script defer src="modules/relief-icons.js"></script>
|
<script defer src="modules/relief-icons.js"></script>
|
||||||
<script defer src="modules/ui/style.js"></script>
|
<script defer src="modules/ui/style.js"></script>
|
||||||
<script defer src="modules/ui/editors.js?v=1.89.05"></script>
|
<script defer src="modules/ui/editors.js?v=1.89.07"></script>
|
||||||
<script defer src="modules/ui/tools.js?v=1.89.00"></script>
|
<script defer src="modules/ui/tools.js?v=1.89.00"></script>
|
||||||
<script defer src="modules/ui/world-configurator.js"></script>
|
<script defer src="modules/ui/world-configurator.js"></script>
|
||||||
<script defer src="modules/ui/heightmap-editor.js?v=1.89.06"></script>
|
<script defer src="modules/ui/heightmap-editor.js?v=1.89.06"></script>
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,7 @@ window.BurgsAndStates = (function () {
|
||||||
TIME && console.timeEnd("drawBurgs");
|
TIME && console.timeEnd("drawBurgs");
|
||||||
};
|
};
|
||||||
|
|
||||||
// growth algorithm to assign cells to states like we did for cultures
|
// expand cultures across the map (Dijkstra-like algorithm)
|
||||||
const expandStates = function () {
|
const expandStates = function () {
|
||||||
TIME && console.time("expandStates");
|
TIME && console.time("expandStates");
|
||||||
const {cells, states, cultures, burgs} = pack;
|
const {cells, states, cultures, burgs} = pack;
|
||||||
|
|
@ -368,8 +368,8 @@ window.BurgsAndStates = (function () {
|
||||||
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
||||||
const cost = [];
|
const cost = [];
|
||||||
|
|
||||||
const globalNeutralRate = byId("neutralInput")?.value || 1;
|
const globalNeutralRate = byId("neutralInput")?.valueAsNumber || 1;
|
||||||
const statesNeutralRate = byId("statesNeutral")?.value || 1;
|
const statesNeutralRate = byId("statesNeutral")?.valueAsNumber || 1;
|
||||||
const neutral = (cells.i.length / 2) * globalNeutralRate * statesNeutralRate; // limit cost for state growth
|
const neutral = (cells.i.length / 2) * globalNeutralRate * statesNeutralRate; // limit cost for state growth
|
||||||
|
|
||||||
// remove state from all cells except of locked
|
// remove state from all cells except of locked
|
||||||
|
|
|
||||||
|
|
@ -507,28 +507,37 @@ window.Cultures = (function () {
|
||||||
// expand cultures across the map (Dijkstra-like algorithm)
|
// expand cultures across the map (Dijkstra-like algorithm)
|
||||||
const expand = function () {
|
const expand = function () {
|
||||||
TIME && console.time("expandCultures");
|
TIME && console.time("expandCultures");
|
||||||
cells = pack.cells;
|
const {cells, cultures} = pack;
|
||||||
|
|
||||||
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
||||||
pack.cultures.forEach(function (c) {
|
|
||||||
if (!c.i || c.removed || c.lock) return;
|
|
||||||
queue.queue({e: c.center, p: 0, c: c.i});
|
|
||||||
});
|
|
||||||
|
|
||||||
const neutral = (cells.i.length / 5000) * 3000 * neutralInput.value; // limit cost for culture growth
|
|
||||||
const cost = [];
|
const cost = [];
|
||||||
|
|
||||||
|
const neutralRate = byId("neutralRate")?.valueAsNumber || 1;
|
||||||
|
const neutral = cells.i.length * 0.6 * neutralRate; // limit cost for culture growth
|
||||||
|
|
||||||
|
// remove culture from all cells except of locked
|
||||||
|
for (const cellId of cells.i) {
|
||||||
|
const culture = cultures[cells.culture[cellId]];
|
||||||
|
if (culture.lock) continue;
|
||||||
|
cells.culture[cellId] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const culture of cultures) {
|
||||||
|
if (!culture.i || culture.removed) continue;
|
||||||
|
queue.queue({e: culture.center, p: 0, c: culture.i});
|
||||||
|
}
|
||||||
|
|
||||||
while (queue.length) {
|
while (queue.length) {
|
||||||
const next = queue.dequeue(),
|
const {e, p, c} = queue.dequeue();
|
||||||
n = next.e,
|
const {type} = pack.cultures[c];
|
||||||
p = next.p,
|
|
||||||
c = next.c;
|
cells.c[e].forEach(e => {
|
||||||
const type = pack.cultures[c].type;
|
const culture = cells.culture[e];
|
||||||
cells.c[n].forEach(e => {
|
if (culture?.lock) return; // do not overwrite cell of locked culture
|
||||||
if (pack.cultures[cells.culture[e]]?.lock) return;
|
|
||||||
|
|
||||||
const biome = cells.biome[e];
|
const biome = cells.biome[e];
|
||||||
const biomeCost = getBiomeCost(c, biome, type);
|
const biomeCost = getBiomeCost(c, biome, type);
|
||||||
const biomeChangeCost = biome === cells.biome[n] ? 0 : 20; // penalty on biome change
|
const biomeChangeCost = biome === cells.biome[e] ? 0 : 20; // penalty on biome change
|
||||||
const heightCost = getHeightCost(e, cells.h[e], type);
|
const heightCost = getHeightCost(e, cells.h[e], type);
|
||||||
const riverCost = getRiverCost(cells.r[e], e, type);
|
const riverCost = getRiverCost(cells.r[e], e, type);
|
||||||
const typeCost = getTypeCost(cells.t[e], type);
|
const typeCost = getTypeCost(cells.t[e], type);
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@ addListeners();
|
||||||
|
|
||||||
export function open() {
|
export function open() {
|
||||||
closeDialogs("#religionsEditor, .stable");
|
closeDialogs("#religionsEditor, .stable");
|
||||||
if (!layerIsOn("toggleReligions")) toggleCultures();
|
|
||||||
if (layerIsOn("toggleStates")) toggleStates();
|
if (layerIsOn("toggleStates")) toggleStates();
|
||||||
if (layerIsOn("toggleBiomes")) toggleBiomes();
|
if (layerIsOn("toggleBiomes")) toggleBiomes();
|
||||||
if (layerIsOn("toggleCultures")) toggleReligions();
|
if (layerIsOn("toggleCultures")) toggleReligions();
|
||||||
if (layerIsOn("toggleProvinces")) toggleProvinces();
|
if (layerIsOn("toggleProvinces")) toggleProvinces();
|
||||||
|
if (!layerIsOn("toggleReligions")) toggleReligions();
|
||||||
|
|
||||||
refreshReligionsEditor();
|
refreshReligionsEditor();
|
||||||
drawReligionCenters();
|
drawReligionCenters();
|
||||||
|
|
@ -214,7 +214,7 @@ function religionsEditorAddLines() {
|
||||||
<div data-tip="${populationTip}" class="religionPopulation hide pointer">${si(population)}</div>
|
<div data-tip="${populationTip}" class="religionPopulation hide pointer">${si(population)}</div>
|
||||||
<span
|
<span
|
||||||
data-tip="Lock religion, will regenerate the origin folk and organized religion if they are not also locked"
|
data-tip="Lock religion, will regenerate the origin folk and organized religion if they are not also locked"
|
||||||
class="icon-lock${r.lock ? '' : '-open'} hide"
|
class="icon-lock${r.lock ? "" : "-open"} hide"
|
||||||
></span>
|
></span>
|
||||||
<span data-tip="Remove religion" class="icon-trash-empty hide"></span>
|
<span data-tip="Remove religion" class="icon-trash-empty hide"></span>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
|
||||||
|
|
@ -350,9 +350,8 @@ window.Religions = (function () {
|
||||||
const religions = [];
|
const religions = [];
|
||||||
|
|
||||||
// add folk religions
|
// add folk religions
|
||||||
pack.cultures.forEach(c => {
|
cultures.forEach(c => {
|
||||||
const newId = c.i;
|
if (!c.i) return religions.push({i: 0, name: "No religion"});
|
||||||
if (!newId) return religions.push({i: 0, name: "No religion"});
|
|
||||||
|
|
||||||
if (c.removed) {
|
if (c.removed) {
|
||||||
religions.push({
|
religions.push({
|
||||||
|
|
@ -364,6 +363,8 @@ window.Religions = (function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const newId = c.i;
|
||||||
|
|
||||||
if (pack.religions) {
|
if (pack.religions) {
|
||||||
const lockedFolkReligion = pack.religions.find(
|
const lockedFolkReligion = pack.religions.find(
|
||||||
r => r.culture === c.i && !r.removed && r.lock && r.type === "Folk"
|
r => r.culture === c.i && !r.removed && r.lock && r.type === "Folk"
|
||||||
|
|
@ -383,7 +384,7 @@ window.Religions = (function () {
|
||||||
const form = rw(forms.Folk);
|
const form = rw(forms.Folk);
|
||||||
const name = c.name + " " + rw(types[form]);
|
const name = c.name + " " + rw(types[form]);
|
||||||
const deity = form === "Animism" ? null : getDeityName(c.i);
|
const deity = form === "Animism" ? null : getDeityName(c.i);
|
||||||
const color = getMixedColor(c.color, 0.1, 0); // `url(#hatch${rand(8,13)})`;
|
const color = getMixedColor(c.color, 0.1, 0);
|
||||||
religions.push({
|
religions.push({
|
||||||
i: newId,
|
i: newId,
|
||||||
name,
|
name,
|
||||||
|
|
@ -713,14 +714,10 @@ window.Religions = (function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
function updateCultures() {
|
function updateCultures() {
|
||||||
TIME && console.time("updateCulturesForReligions");
|
|
||||||
pack.religions = pack.religions.map((religion, index) => {
|
pack.religions = pack.religions.map((religion, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) return religion;
|
||||||
return religion;
|
|
||||||
}
|
|
||||||
return {...religion, culture: pack.cells.culture[religion.center]};
|
return {...religion, culture: pack.cells.culture[religion.center]};
|
||||||
});
|
});
|
||||||
TIME && console.timeEnd("updateCulturesForReligions");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get supreme deity name
|
// get supreme deity name
|
||||||
|
|
|
||||||
|
|
@ -1188,6 +1188,6 @@ async function editCultures() {
|
||||||
|
|
||||||
async function editReligions() {
|
async function editReligions() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
const Editor = await import("../dynamic/editors/religions-editor.js?v=1.88.06");
|
const Editor = await import("../dynamic/editors/religions-editor.js?v=1.88.07");
|
||||||
Editor.open();
|
Editor.open();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// version and caching control
|
// version and caching control
|
||||||
const version = "1.89.06"; // generator version, update each time
|
const version = "1.89.07"; // generator version, update each time
|
||||||
|
|
||||||
{
|
{
|
||||||
document.title += " v" + version;
|
document.title += " v" + version;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue