From 424e1f4d854afd656042e345662534f72d756d31 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 20 Apr 2022 12:14:16 +0500 Subject: [PATCH] fix rebels #779 --- main.js | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/main.js b/main.js index fc424222..7f6b451d 100644 --- a/main.js +++ b/main.js @@ -241,26 +241,27 @@ async function checkLoadParameters() { } // open latest map if option is active and map is stored - const loadLastMap = () => new Promise((resolve, reject) => { - ldb.get("lastMap", blob => { - if (blob) { - WARN && console.warn("Load last saved map"); - try { - uploadMap(blob); - resolve(); - } catch (error) { - reject(error); + const loadLastMap = () => + new Promise((resolve, reject) => { + ldb.get("lastMap", blob => { + if (blob) { + WARN && console.warn("Load last saved map"); + try { + uploadMap(blob); + resolve(); + } catch (error) { + reject(error); + } + } else { + reject("No map stored"); } - } else { - reject("No map stored"); - } - }) - }) + }); + }); if (onloadMap.value === "saved") { try { await loadLastMap(); - } catch(error) { + } catch (error) { ERROR && console.error(error); WARN && console.warn("Cannot load stored map, random map to be generated"); await generateMapOnLoad(); @@ -1625,10 +1626,11 @@ function addZones(number = 1) { const neib = ra(state.neighbors.filter(n => n && !states[n].removed)); if (!neib) return; const cell = cells.i.find(i => cells.state[i] === state.i && !state.removed && cells.c[i].some(c => cells.state[c] === neib)); - const cellsArray = [], - queue = [], - power = rand(10, 30); - if (cell) queue.push.cell; + const cellsArray = []; + const queue = []; + if (cell) queue.push(cell); + + const power = rand(10, 30); while (queue.length) { const q = queue.shift();