diff --git a/index.html b/index.html
index 0b817396..d648ecfd 100644
--- a/index.html
+++ b/index.html
@@ -1313,7 +1313,7 @@
-
+
@@ -3507,7 +3507,7 @@
Original map will be destroyed! Don't forget to save your work!
-
+
diff --git a/modules/submap.js b/modules/submap.js
index 7a529ab6..6f4cb421 100644
--- a/modules/submap.js
+++ b/modules/submap.js
@@ -50,7 +50,7 @@ window.Submap = (function () {
grid.cells.h[id] = gridCells.h[cid];
grid.cells.temp[id] = gridCells.temp[cid];
grid.cells.prec[id] = gridCells.prec[cid];
- id%50 || progress(id * 100.0 / grid.points.length)
+ id%50 || progress(id * 100.0 / grid.points.length);
})
// TODO: add smooth/noise function for h, temp, prec n times
@@ -112,32 +112,42 @@ window.Submap = (function () {
// Cultures.expand();
// TODO: update culture centers
- // transfer states and burgs. filter states without land
- const validStates = new Set(pack.cells.state)
- console.log(validStates);
- pack.states = baseState.pack.states;
- console.log(pack.states)
- pack.validStates = pack.states.filter(s => validStates.has(s.i))
+ // transfer states and burgs. mark states without land as removed.
+ const validStates = new Set(pack.cells.state);
+ pack.states = baseState.pack.states
+ pack.states.forEach(s => {
+ if (!validStates.has(s.i)) s.removed=true;
+ });
// BurgsAndStates.generate();
// Religions.generate();
// BurgsAndStates.defineStateForms();
- BurgsAndStates.generateProvinces();
// BurgsAndStates.defineBurgFeatures();
- // update burg list
- //const validBurgs = new Set(pack.cells.burgs);
+ // remove non-existent burgs
pack.burgs = baseState.pack.burgs
- // .filter(b => validBurgs.has(b.i))
+
+
+ const [[xmin, ymin], [xmax, ymax]] = getViewBoxExtent();
+ const inMap = (x,y) => x>xmin && xymin && y {
- [b.x, b.y] = projection(b.x, b.y);
+ [b.x,b.y] = projection(b.x, b.y);
+ if (!inMap(b.x,b.y)) {
+ // out-of-map (removed) burgs' cell will be undefined
+ console.log('burg is out of map:', b)
+ b.removed=true;
+ b.cell = undefined;
+ return;
+ }
b.cell = findCell(b.x, b.y);
pack.cells.burg[b.cell] = i;
// TODO: move port burgs to coast b.x, b.y,
});
+ BurgsAndStates.generateProvinces();
+
drawStates();
drawBorders();
BurgsAndStates.drawStateLabels();
@@ -155,5 +165,6 @@ window.Submap = (function () {
INFO && console.groupEnd("Generated Map " + seed);
}
+ // export
return { resample }
})();
diff --git a/modules/ui/submap.js b/modules/ui/submap.js
index 7dce33e5..108ffde8 100644
--- a/modules/ui/submap.js
+++ b/modules/ui/submap.js
@@ -27,8 +27,8 @@ const generateSubmap = debounce(function (x, y, w, h) {
progress: p => progressUI.innerHTML = p,
}
+ const [[x0, y0], [x1, y1]] = getViewBoxExtent();
const projection = (x, y) => {
- const [[x0, y0], [x1, y1]] = getViewBoxExtent();
return [x * (x1-x0) / graphWidth + x0, y * (y1-y0) / graphHeight + y0]
}