From 9bbe256ffd0eb4f8fae2da634f7d330de06641dc Mon Sep 17 00:00:00 2001 From: Alain Bryden <2285037+alainbryden@users.noreply.github.com> Date: Thu, 3 Oct 2024 02:01:31 -0300 Subject: [PATCH] Fix trying to use go.js cheats before we had SF 14.2 --- autopilot.js | 5 +++-- helpers.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/autopilot.js b/autopilot.js index f5f8e866..16a34a63 100644 --- a/autopilot.js +++ b/autopilot.js @@ -433,9 +433,10 @@ async function checkOnRunningScripts(ns, player) { launchScriptHelper(ns, 'work-for-factions.js', rushGang ? rushGangsArgs : workForFactionsArgs); } + // Launch go.js const goplayer = findScript('go.js'); if (!options["disable-go"] && !goplayer && homeRam >= 75) { - launchScriptHelper(ns, 'go.js', 14 in unlockedSFs && unlockedSFs[14] >= 2 ? ["--cheats"] : []); + launchScriptHelper(ns, 'go.js', (14 in unlockedSFs) && (unlockedSFs[14] >= 2) ? ["--cheats"] : []); } } @@ -668,7 +669,7 @@ function launchScriptHelper(ns, baseScriptName, args = [], convertFileName = tru log(ns, `INFO: Launched ${baseScriptName} (pid: ${pid}) with args: [${args.join(", ")}]`, true); else log(ns, `ERROR: Failed to launch ${baseScriptName} with args: [${args.join(", ")}]` + - err ? `\nCaught: ` + (typeof err === 'string' ? err : err.message || JSON.stringify(err)) : '', true, 'error'); + err ? `\nCaught: ` + (typeof err === 'string' ? err : err?.toString() || JSON.stringify(err)) : '', true, 'error'); return pid; } diff --git a/helpers.js b/helpers.js index 2a65ed2a..8e2d6c55 100644 --- a/helpers.js +++ b/helpers.js @@ -437,10 +437,11 @@ export async function getActiveSourceFiles_Custom(ns, fnGetNsDataThroughFile, in '/Temp/owned-source-files.txt'); } catch { dictSourceFiles = {}; } // If this fails (e.g. low RAM), return an empty dictionary // If the user is currently in a given bitnode, they will have its features unlocked + // TODO: This is true of BN4, but not BN14.2, Check them all! if (includeLevelsFromCurrentBitnode) { try { const currentNode = (await fnGetNsDataThroughFile(ns, 'ns.getResetInfo()', '/Temp/reset-info.txt')).currentNode; - dictSourceFiles[currentNode] = Math.max(3, dictSourceFiles[currentNode] || 0); + dictSourceFiles[currentNode] = Math.max((currentNode == 4 ? 3 : 1), dictSourceFiles[currentNode] || 0); } catch { /* We are expected to be fault-tolerant in low-ram conditions */ } } return dictSourceFiles;