This commit is contained in:
33333-33333 2026-05-29 22:00:42 +09:00
commit 6cef9a3abe
11 changed files with 1184 additions and 235 deletions

View file

@ -441,6 +441,7 @@ export function finishMapOutput({
let externalGateways = inputExternalGateways;
const outputProgress = (step) => options?.onProgress?.({ status: "output-step", key: "output", label: `Output: ${step}`, step });
const patchMode = options?.patchMode === true || options?.generationContext?.hasBoundaryWorld === true;
outputProgress("final packaging");
// Use all generated prefecture regions for human-geography masks, not only
// the focused prefecture. Population density itself is already generated in
@ -454,11 +455,19 @@ export function finishMapOutput({
// name features.
for (const city of modernCities) {
const cap = cityPopulationCap(city);
if (cap < INF && (city.population || 0) > cap) {
city.population = Math.round(cap / 1000) * 1000;
city.urbanRadius = clamp(5.0 + Math.sqrt(city.population) / 100, 6, 16);
city.coreRadius = clamp(1.8 + Math.sqrt(city.population) / 400, 2.2, 5.2);
city.urbanWeight = clamp(0.72 + Math.log10(Math.max(10000, city.population)) * 0.30, 1.0, 2.0);
let targetCap = cap;
if (patchMode) {
// Patch candidates should not regularly introduce a new top-center-scale
// metropolis. Existing cities in the world are preserved by mapPatch; this
// only affects newly generated candidate cities before they are merged.
const patchCap = city.isPrefecturalCapital ? 820000 : city.isRegionalCapital ? 680000 : 540000;
targetCap = Math.min(targetCap, patchCap);
}
if (targetCap < INF && (city.population || 0) > targetCap) {
city.population = Math.round(targetCap / 1000) * 1000;
city.urbanRadius = clamp(5.0 + Math.sqrt(city.population) / 100, 6, patchMode ? 14 : 16);
city.coreRadius = clamp(1.8 + Math.sqrt(city.population) / 400, 2.2, patchMode ? 4.8 : 5.2);
city.urbanWeight = clamp(0.72 + Math.log10(Math.max(10000, city.population)) * 0.30, 1.0, patchMode ? 1.86 : 2.0);
}
}