fix invalid feature number at burg.ports, option to disable regenerations

This commit is contained in:
Mészáros Gergely 2021-08-18 21:06:25 +02:00
parent 968a4725cc
commit 25575b8966
3 changed files with 22 additions and 4 deletions

View file

@ -172,6 +172,7 @@ window.Submap = (function () {
pack.states = parentMap.pack.states;
// keep valid states and neighbors only
pack.states.forEach((s, i) => {
if (s.removed) return;
if (!validStates.has(i)) s.removed=true;
s.neighbors = s.neighbors.filter(n => validStates.has(n));
});
@ -204,10 +205,10 @@ window.Submap = (function () {
Rivers.specify();
Lakes.generateName();
stage("Modelling military.");
Military.generate();
addMarkers();
addZones();
stage("Modelling military, markers and zones (if requested).");
if (options.addMilitary) Military.generate();
if (options.addMarkers) addMarkers();
if (options.addZones) addZones();
Names.getMapName();
stage("Submap done.");
@ -266,6 +267,7 @@ window.Submap = (function () {
}
const [water, coast] = res;
[b.x, b.y] = b.port? getMiddlePoint(coast, water): cells.p[coast];
if (b.port) b.port = cells.f[water];
b.cell = coast;
} if (b.port) {
// find coast for ports on land
@ -274,6 +276,7 @@ window.Submap = (function () {
if (res) {
const [coast, water] = res;
[b.x, b.y] = getMiddlePoint(coast, water);
b.port = cells.f[water]; // copy feature number
b.cell = coast;
} else {
WARN && console.warn(`Can't find water near port ${b.name}. :-/`);

View file

@ -24,6 +24,9 @@ const generateSubmap = debounce(async function () {
depressRivers: Boolean(document.getElementById("submapDepressRivers").checked),
copyBurgs: Boolean(document.getElementById("submapCopyBurgs").checked),
addLakesInDepressions: Boolean(document.getElementById("submapAddLakeInDepression").checked),
addMilitary: Boolean(document.getElementById("submapAddMilitary").checked),
addMarkers: Boolean(document.getElementById("submapAddMarkers").checked),
addZones: Boolean(document.getElementById("submapAddZones").checked),
}
// Create projection func from current zoom extents