diff --git a/public/modules/ui/tools.js b/public/modules/ui/tools.js
index eade993f..34c1cd12 100644
--- a/public/modules/ui/tools.js
+++ b/public/modules/ui/tools.js
@@ -101,14 +101,17 @@ function processFeatureRegeneration(event, button) {
async function openEmblemEditor() {
let type, id, el;
- if (pack.states[1]?.coa) {
+ const firstState = pack.states.find(s => s.i && !s.removed && s.coa);
+ const firstBurg = pack.burgs.find(b => b.i && !b.removed && b.coa);
+
+ if (firstState) {
type = "state";
- id = "stateCOA1";
- el = pack.states[1];
- } else if (pack.burgs[1]?.coa) {
+ id = `stateCOA${firstState.i}`;
+ el = firstState;
+ } else if (firstBurg) {
type = "burg";
- id = "burgCOA1";
- el = pack.burgs[1];
+ id = `burgCOA${firstBurg.i}`;
+ el = firstBurg;
} else {
tip("No emblems to edit, please generate states and burgs first", false, "error");
return;
diff --git a/src/index.html b/src/index.html
index 054f45ba..52d2c51e 100644
--- a/src/index.html
+++ b/src/index.html
@@ -8548,7 +8548,7 @@
-
+
diff --git a/src/modules/burgs-generator.ts b/src/modules/burgs-generator.ts
index 6fccd517..debdab69 100644
--- a/src/modules/burgs-generator.ts
+++ b/src/modules/burgs-generator.ts
@@ -676,6 +676,7 @@ class BurgModule {
};
this.definePopulation(burg);
this.defineEmblem(burg);
+ COArenderer.add("burg", burgId, burg.coa, x, y);
this.defineFeatures(burg);
const populations = pack.burgs