Skip to content

Commit

Permalink
Fix trying to use go.js cheats before we had SF 14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alainbryden committed Oct 3, 2024
1 parent 07b5599 commit 9bbe256
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions autopilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"] : []);
}
}

Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9bbe256

Please sign in to comment.