Changed pack.cells.haven and pack.cells.harbor to use less memory

This commit is contained in:
Evolvedexperiment 2019-11-29 13:23:40 +00:00
parent 51c6704868
commit d50dcc0614

View file

@ -1021,8 +1021,8 @@ function reMarkFeatures() {
const cells = pack.cells, features = pack.features = [0]; const cells = pack.cells, features = pack.features = [0];
cells.f = new Uint16Array(cells.i.length); // cell feature number cells.f = new Uint16Array(cells.i.length); // cell feature number
cells.t = new Int16Array(cells.i.length); // cell type: 1 = land along coast; -1 = water along coast; cells.t = new Int16Array(cells.i.length); // cell type: 1 = land along coast; -1 = water along coast;
cells.haven = new Uint32Array(cells.i.length); // cell haven (opposite water cell); cells.haven = cells.i.length < 65535 ? new Uint16Array(cells.i.length) : new Uint32Array(cells.i.length);// cell haven (opposite water cell);
cells.harbor = new Uint16Array(cells.i.length); // cell harbor (number of adjacent water cells); cells.harbor = new Uint8Array(cells.i.length); // cell harbor (number of adjacent water cells);
for (let i=1, queue=[0]; queue[0] !== -1; i++) { for (let i=1, queue=[0]; queue[0] !== -1; i++) {
const start = queue[0]; // first cell const start = queue[0]; // first cell