From c2edda6a4a8a64a41fcf63320b725db765bf2f21 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 24 Feb 2021 14:26:41 +0300 Subject: [PATCH] v1.5.53 - fix for active provinces linked to removed state --- modules/coa-generator.js | 6 +++++- modules/save-and-load.js | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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();