From b87225665ebecce5a015ef3cc46418602b72185b Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 18:06:47 +0100 Subject: [PATCH] Fix: Military regiment notes not updated on regeneration with new era/year (#1329) * Initial plan * Fix: Military notes not updated on regiment or Era data change Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com> * Refactor: update existing regiment note in-place; remove all regiment notes in one pass Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com> * Bump version to 1.112.3 (patch: fix military notes not updated on regen) Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com> --- public/modules/military-generator.js | 14 +++++++++++++- public/versioning.js | 2 +- src/index.html | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/public/modules/military-generator.js b/public/modules/military-generator.js index 34c705d8..b16d84cb 100644 --- a/public/modules/military-generator.js +++ b/public/modules/military-generator.js @@ -246,6 +246,11 @@ window.Military = (function () { const expected = 3 * populationRate; // expected regiment size const mergeable = (n0, n1) => (!n0.s && !n1.s) || n0.u === n1.u; // check if regiments can be merged + // remove all existing regiment notes before regenerating + for (let i = notes.length - 1; i >= 0; i--) { + if (notes[i].id.startsWith("regiment")) notes.splice(i, 1); + } + // get regiments for each state valid.forEach(s => { s.military = createRegiments(s.temp.platoons, s); @@ -380,7 +385,14 @@ window.Military = (function () { : gauss(options.year - 100, 150, 1, options.year - 6); const conflict = campaign ? ` during the ${campaign.name}` : ""; const legend = `Regiment was formed in ${year} ${options.era}${conflict}. ${station}${troops}`; - notes.push({id: `regiment${s.i}-${r.i}`, name: r.name, legend}); + const id = `regiment${s.i}-${r.i}`; + const existing = notes.find(n => n.id === id); + if (existing) { + existing.name = r.name; + existing.legend = legend; + } else { + notes.push({id, name: r.name, legend}); + } }; return { diff --git a/public/versioning.js b/public/versioning.js index 056b30e2..99f6a730 100644 --- a/public/versioning.js +++ b/public/versioning.js @@ -13,7 +13,7 @@ * Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2 */ -const VERSION = "1.112.2"; +const VERSION = "1.112.3"; if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function"); { diff --git a/src/index.html b/src/index.html index ca605c87..8e73451d 100644 --- a/src/index.html +++ b/src/index.html @@ -8494,7 +8494,7 @@ - +