From 424ae160ba082b23e8423cc67adc9bce6fc5e800 Mon Sep 17 00:00:00 2001 From: David Walker Date: Sun, 20 Oct 2024 00:52:57 -0700 Subject: [PATCH] NETSCRIPT: Fix dynamicRamUsage returned by getRunningScript() (#1704) Fixes #1700 --- src/NetscriptFunctions.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 21d4f2228..318acc0ae 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -1496,7 +1496,11 @@ export const ns: InternalAPI = { const ident = helpers.scriptIdentifier(ctx, fn, hostname, args); const runningScript = helpers.getRunningScript(ctx, ident); if (runningScript === null) return null; - return helpers.createPublicRunningScript(runningScript, ctx.workerScript); + // Need to look this up again, because we only have ident-based lookup + // for RunningScript. + const ws = workerScripts.get(runningScript.pid); + // We don't check for null, since it's fine to pass null as the 2nd arg. + return helpers.createPublicRunningScript(runningScript, ws); }, ramOverride: (ctx) => (_ram) => { const newRam = roundToTwo(helpers.number(ctx, "ram", _ram || 0));