From da5c0e94933e1d8497f783f36a9343275576788d Mon Sep 17 00:00:00 2001 From: Azgaar Date: Tue, 5 Dec 2023 02:24:36 +0400 Subject: [PATCH 1/4] fix: #1024, regenerate burgs - ignore removed states --- index.html | 2 +- modules/ui/tools.js | 6 +++--- versioning.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 8d0fd14a..8a342fa2 100644 --- a/index.html +++ b/index.html @@ -8005,7 +8005,7 @@ - + diff --git a/modules/ui/tools.js b/modules/ui/tools.js index e1d554da..5d9d0d40 100644 --- a/modules/ui/tools.js +++ b/modules/ui/tools.js @@ -361,10 +361,10 @@ function regenerateBurgs() { const score = new Int16Array(cells.s.map(s => s * Math.random())); // cell score for capitals placement const sorted = cells.i.filter(i => score[i] > 0 && cells.culture[i]).sort((a, b) => score[b] - score[a]); // filtered and sorted array of indexes + const existingStatesCount = states.filter(s => s.i && !s.removed).length; const burgsCount = - manorsInput.value === "1000" - ? rn(sorted.length / 5 / (grid.points.length / 10000) ** 0.8) + states.length - : +manorsInput.value + states.length; + (manorsInput.value === "1000" ? rn(sorted.length / 5 / (grid.points.length / 10000) ** 0.8) : +manorsInput.value) + + existingStatesCount; const spacing = (graphWidth + graphHeight) / 150 / (burgsCount ** 0.7 / 66); // base min distance between towns for (let i = 0; i < sorted.length && burgs.length < burgsCount; i++) { diff --git a/versioning.js b/versioning.js index 8d658c4f..27b2928c 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.95.00"; // generator version, update each time +const version = "1.95.01"; // generator version, update each time { document.title += " v" + version; From 9f348b70d6832dd57ce2b96fef572c127879b0d3 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Tue, 5 Dec 2023 02:31:38 +0400 Subject: [PATCH 2/4] fix: namesbase editor - sanitize base name on load --- index.html | 2 +- modules/ui/namesbase-editor.js | 8 +++++--- versioning.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 8a342fa2..f8e89f38 100644 --- a/index.html +++ b/index.html @@ -8010,7 +8010,7 @@ - + diff --git a/modules/ui/namesbase-editor.js b/modules/ui/namesbase-editor.js index 0dba088a..edf472eb 100644 --- a/modules/ui/namesbase-editor.js +++ b/modules/ui/namesbase-editor.js @@ -244,11 +244,13 @@ function editNamesbase() { Names.clearChains(); if (override) nameBases = []; + const unsafe = new RegExp(/[|/]/, "g"); data.forEach(base => { - const [name, min, max, d, m, names] = base.split("|"); - const secureNames = names.replace(/[/|]/g, ""); - nameBases.push({name, min, max, d, m, b: secureNames}); + const [rawName, min, max, d, m, rawNames] = base.split("|"); + const name = rawName.replace(unsafe, ""); + const names = rawNames.replace(unsafe, ""); + nameBases.push({name, min, max, d, m, b: names}); }); createBasesList(); diff --git a/versioning.js b/versioning.js index 27b2928c..26625d25 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.95.01"; // generator version, update each time +const version = "1.95.02"; // generator version, update each time { document.title += " v" + version; From c758e19e9069f8084e85622bbd11d6f9f929f26f Mon Sep 17 00:00:00 2001 From: Azgaar Date: Tue, 5 Dec 2023 02:38:37 +0400 Subject: [PATCH 3/4] chore: polyfill Array.at for old browsers --- index.html | 2 +- utils/polyfills.js | 9 +++++++++ versioning.js | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index f8e89f38..8a39f5b8 100644 --- a/index.html +++ b/index.html @@ -7966,7 +7966,7 @@ - + diff --git a/utils/polyfills.js b/utils/polyfills.js index 667d81ab..ffc10f74 100644 --- a/utils/polyfills.js +++ b/utils/polyfills.js @@ -15,6 +15,15 @@ if (Array.prototype.flat === undefined) { }; } +// at +if (Array.prototype.at === undefined) { + Array.prototype.at = function (index) { + if (index < 0) index += this.length; + if (index < 0 || index >= this.length) return undefined; + return this[index]; + }; +} + // readable stream iterator: https://bugs.chromium.org/p/chromium/issues/detail?id=929585#c10 if (ReadableStream.prototype[Symbol.asyncIterator] === undefined) { ReadableStream.prototype[Symbol.asyncIterator] = async function* () { diff --git a/versioning.js b/versioning.js index 26625d25..0d0d6f8a 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.95.02"; // generator version, update each time +const version = "1.95.03"; // generator version, update each time { document.title += " v" + version; From 52e30887633600f33ae33f12d815229c224763d1 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Tue, 5 Dec 2023 02:45:55 +0400 Subject: [PATCH 4/4] fix: cultures editor - don't overwrite border color on color change --- index.html | 2 +- modules/dynamic/editors/cultures-editor.js | 5 +---- modules/ui/editors.js | 2 +- versioning.js | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 8a39f5b8..7405ff94 100644 --- a/index.html +++ b/index.html @@ -8004,7 +8004,7 @@ - + diff --git a/modules/dynamic/editors/cultures-editor.js b/modules/dynamic/editors/cultures-editor.js index 053a177e..fac79955 100644 --- a/modules/dynamic/editors/cultures-editor.js +++ b/modules/dynamic/editors/cultures-editor.js @@ -341,10 +341,7 @@ function cultureChangeColor() { const callback = newFill => { $el.fill = newFill; pack.cultures[cultureId].color = newFill; - cults - .select("#culture" + cultureId) - .attr("fill", newFill) - .attr("stroke", newFill); + cults.select("#culture" + cultureId).attr("fill", newFill); debug.select("#cultureCenter" + cultureId).attr("fill", newFill); }; diff --git a/modules/ui/editors.js b/modules/ui/editors.js index f89cc9e0..d42e4a28 100644 --- a/modules/ui/editors.js +++ b/modules/ui/editors.js @@ -1182,7 +1182,7 @@ async function editStates() { async function editCultures() { if (customization) return; - const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.91.00"); + const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.95.04"); Editor.open(); } diff --git a/versioning.js b/versioning.js index 0d0d6f8a..4e4fb075 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.95.03"; // generator version, update each time +const version = "1.95.04"; // generator version, update each time { document.title += " v" + version;