diff --git a/modules/coa-generator.js b/modules/coa-generator.js index 22265084..9c13378c 100644 --- a/modules/coa-generator.js +++ b/modules/coa-generator.js @@ -209,7 +209,11 @@ } const generate = function(parent, kinship, dominion, type) { - if (parent === "custom") parent = null; + if (!parent || parent === "custom") { + parent = null; + kinship = 0; + dominion = 0; + } let usedPattern = null, usedTinctures = []; const t1 = P(kinship) ? parent.t1 : getTincture("field"); diff --git a/modules/save-and-load.js b/modules/save-and-load.js index f725a6e8..f471e8f3 100644 --- a/modules/save-and-load.js +++ b/modules/save-and-load.js @@ -1144,6 +1144,13 @@ function parseLoadedData(data) { cells.i.filter(i => cells.burg[i] === b.i).forEach(i => cells.burg[i] = 0); cells.burg[b.cell] = b.i; }); + + pack.provinces.forEach(p => { + if (!p.i || p.removed) return; + if (pack.states[p.state] && !pack.states[p.state].removed) return; + ERROR && console.error("Data Integrity Check. Province", p.i, "is linked to removed state", p.state); + p.removed = true; // remove incorrect province + }); }() changeMapSize();