@@ -8051,7 +8052,7 @@
-
+
@@ -8076,13 +8077,13 @@
-
+
-
+
diff --git a/modules/dynamic/editors/cultures-editor.js b/modules/dynamic/editors/cultures-editor.js
index c6143dc2..b8e43608 100644
--- a/modules/dynamic/editors/cultures-editor.js
+++ b/modules/dynamic/editors/cultures-editor.js
@@ -266,6 +266,7 @@ function getTypeOptions(type) {
function getBaseOptions(base) {
let options = "";
nameBases.forEach((n, i) => (options += ``));
+ if (!nameBases[base]) options += ``; // in case namesbase was removed
return options;
}
diff --git a/modules/names-generator.js b/modules/names-generator.js
index 4e243f3c..c35afedc 100644
--- a/modules/names-generator.js
+++ b/modules/names-generator.js
@@ -48,18 +48,28 @@ window.Names = (function () {
return chain;
};
- // update chain for specific base
- const updateChain = i => (chains[i] = nameBases[i] || nameBases[i].b ? calculateChain(nameBases[i].b) : null);
+ const updateChain = i => {
+ chains[i] = nameBases[i]?.b ? calculateChain(nameBases[i].b) : null;
+ };
- // update chains for all used bases
- const clearChains = () => (chains = []);
+ const clearChains = () => {
+ chains = [];
+ };
// generate name using Markov's chain
const getBase = function (base, min, max, dupl) {
- if (base === undefined) {
- ERROR && console.error("Please define a base");
- return;
+ if (base === undefined) return ERROR && console.error("Please define a base");
+
+ if (nameBases[base] === undefined) {
+ if (nameBases[0]) {
+ WARN && console.warn("Namebase " + base + " is not found. First available namebase will be used");
+ base = 0;
+ } else {
+ ERROR && console.error("Namebase " + base + " is not found");
+ return "ERROR";
+ }
}
+
if (!chains[base]) updateChain(base);
const data = chains[base];
@@ -141,16 +151,8 @@ window.Names = (function () {
// generate short name for base
const getBaseShort = function (base) {
- if (nameBases[base] === undefined) {
- tip(
- `Namebase ${base} does not exist. Please upload custom namebases of change the base in Cultures Editor`,
- false,
- "error"
- );
- base = 1;
- }
- const min = nameBases[base].min - 1;
- const max = Math.max(nameBases[base].max - 2, min);
+ const min = nameBases[base] ? nameBases[base].min - 1 : null;
+ const max = min ? Math.max(nameBases[base].max - 2, min) : null;
return getBase(base, min, max, "", 0);
};
diff --git a/modules/ui/editors.js b/modules/ui/editors.js
index dd742aed..13380155 100644
--- a/modules/ui/editors.js
+++ b/modules/ui/editors.js
@@ -1255,7 +1255,7 @@ async function editStates() {
async function editCultures() {
if (customization) return;
- const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.104.0");
+ const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.105.11");
Editor.open();
}
diff --git a/modules/ui/namesbase-editor.js b/modules/ui/namesbase-editor.js
index edf472eb..ae3fc730 100644
--- a/modules/ui/namesbase-editor.js
+++ b/modules/ui/namesbase-editor.js
@@ -41,7 +41,7 @@ function editNamesbase() {
$("#namesbaseEditor").dialog({
title: "Namesbase Editor",
- width: "auto",
+ width: "60vw",
position: {my: "center", at: "center", of: "svg"}
});
@@ -66,7 +66,7 @@ function editNamesbase() {
function updateExamples() {
const base = +document.getElementById("namesbaseSelect").value;
let examples = "";
- for (let i = 0; i < 10; i++) {
+ for (let i = 0; i < 7; i++) {
const example = Names.getBase(base);
if (example === undefined) {
examples = "Cannot generate examples. Please verify the data";
@@ -250,7 +250,7 @@ function editNamesbase() {
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});
+ nameBases.push({name, min: +min, max: +max, d, m: +m, b: names});
});
createBasesList();
diff --git a/versioning.js b/versioning.js
index 04c9faf8..44eaf676 100644
--- a/versioning.js
+++ b/versioning.js
@@ -12,7 +12,7 @@
*
* Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2
*/
-const VERSION = "1.105.10";
+const VERSION = "1.105.11";
if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function");
{