for (Integer i : uc) {
String name = String.format("Nation %2d", id);
if (id <= nationNames.length) {
name = nationNames[id-1];
}
Nation nation = new Nation();
nation.setProperty(Nation.KEY_NAME, name);
if (id <= nationColors.length) {
nation.setProperty(Nation.KEY_COLOR, nationColors[id-1]);
}
nmap.put(i, nation);
nations.addElement(nation);
id++;
}
// detect provinces
Set<Integer> up = new HashSet<>(1_000);
for (int i = 0; i < chunk; i++) {
if (terrain_underlay[i] != 5) {
up.add(provinces[i]);
}
}
updateStatus(String.format("contains %d provinces", up.size()));
// generate province names
Map<Integer, String> pmap = new HashMap<>(Np);
id = 1;
for (Integer i : up) {
// String name = String.format("Province %d", id);
String name = pnames[i];
pmap.put(i, name);
id++;
}
// add provinces to scenario
Map<Integer, Province> ppmap = new HashMap<>(1_000);
Set<Integer> processed = new HashSet<>(1_000);
for (int i = 0; i < chunk; i++) {
if (terrain_underlay[i] != 5) {
if (!processed.contains(provinces[i])) {
Nation nation = nmap.get(countries[i]);
String name = pmap.get(provinces[i]);
Province province = scenario.createProvince(name);
nation.addProvince(province);
ppmap.put(provinces[i], province);
processed.add(provinces[i]);
}
}
}