mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 12:01:23 +01:00
refactor(#902): locked states cells to be assigned on start
This commit is contained in:
parent
e984c708d1
commit
aa29f69bbf
2 changed files with 8 additions and 6 deletions
|
|
@ -364,7 +364,7 @@ window.BurgsAndStates = (function () {
|
|||
TIME && console.time("expandStates");
|
||||
const {cells, states, cultures, burgs} = pack;
|
||||
|
||||
cells.state = new Uint16Array(cells.i.length);
|
||||
cells.state = cells.state || new Uint16Array(cells.i.length);
|
||||
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
||||
const cost = [];
|
||||
const neutral = (cells.i.length / 5000) * 2500 * neutralInput.value * statesNeutral; // limit cost for state growth
|
||||
|
|
|
|||
|
|
@ -238,11 +238,6 @@ function recreateStates() {
|
|||
// pack.provinces[id].should_restore = true;
|
||||
});
|
||||
|
||||
for (const i of pack.cells.i) {
|
||||
const stateId = pack.cells.state[i];
|
||||
if (stateId === s.i) pack.cells.state[i] = newId;
|
||||
}
|
||||
|
||||
const {x, y} = validBurgs[s.capital];
|
||||
capitalsTree.add([x, y]);
|
||||
|
||||
|
|
@ -250,6 +245,13 @@ function recreateStates() {
|
|||
newStates.push(s);
|
||||
});
|
||||
|
||||
for (const i of pack.cells.i) {
|
||||
const stateId = pack.cells.state[i];
|
||||
const lockedStateIndex = lockedStatesIds.indexOf(stateId) + 1;
|
||||
// lockedStateIndex is an index of locked state of 0 if state is not locked
|
||||
pack.cells.state[i] = lockedStateIndex;
|
||||
}
|
||||
|
||||
for (let i = newStates.length; i < count; i++) {
|
||||
let capital = null;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue