Merge pull request #1588 from danielyxie/dev

Fix static ram miscalc
This commit is contained in:
hydroflame 2021-10-27 16:17:19 -04:00 committed by GitHub
commit 3414eb8306
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 19 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -36,9 +36,9 @@ export function NetscriptExtra(player: IPlayer, workerScript: WorkerScript): INe
real_document.completely_unused_field = undefined; real_document.completely_unused_field = undefined;
}, },
alterReality: function (): void { alterReality: function (): void {
// eval so the code doesn't get optimized away.
const x = eval("false"); const x = eval("false");
console.warn("I am sure that this variable is false."); console.warn("I am sure that this variable is false.");
// add Math.random so webpack doesn't optimise the if away
if (x !== false) { if (x !== false) {
console.warn("Reality has been altered!"); console.warn("Reality has been altered!");
player.giveExploit(Exploit.RealityAlteration); player.giveExploit(Exploit.RealityAlteration);

@ -163,22 +163,9 @@ async function parseOnlyRamCalculate(
// If it is, then we need to get its RAM cost. // If it is, then we need to get its RAM cost.
try { try {
function applyFuncRam(func: any): number { function applyFuncRam(func: any): number {
if (typeof func === "function") { console.log(func);
try { if (typeof func === "number") {
let res; return func;
if (func.constructor.name === "AsyncFunction") {
res = 0; // Async functions will always be 0 RAM
} else {
res = func.apply(null, []);
}
if (typeof res === "number") {
return res;
}
return 0;
} catch (e) {
console.error(`Error applying function: ${e}`);
return 0;
}
} else { } else {
return 0; return 0;
} }