From 0e9732e6ced7578ef4f8c2447b8b1f6bf734569a Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sat, 10 Jul 2021 22:41:50 +0300 Subject: [PATCH] fix the issue with province that cannot be reassigned --- modules/ui/states-editor.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/ui/states-editor.js b/modules/ui/states-editor.js index 441b551e..45c74829 100644 --- a/modules/ui/states-editor.js +++ b/modules/ui/states-editor.js @@ -827,18 +827,15 @@ function editStates() { } function adjustProvinces(affectedProvinces) { - const cells = pack.cells, - provinces = pack.provinces, - states = pack.states; + const {cells, provinces, states} = pack; const form = {Zone: 1, Area: 1, Territory: 2, Province: 1}; affectedProvinces.forEach(p => { - // do nothing if neutral lands are captured - if (!p) return; + if (!p) return; // do nothing if neutral lands are captured + const old = provinces[p].state; // remove province from state provinces list - const old = provinces[p].state; - if (states[old].provinces.includes(p)) states[old].provinces.splice(states[old].provinces.indexOf(p), 1); + if (states[old]?.provinces?.includes(p)) states[old].provinces.splice(states[old].provinces.indexOf(p), 1); // find states owning at least 1 province cell const provCells = cells.i.filter(i => cells.province[i] === p);