Merge pull request #4072 from Snarling/exitExits

NETSCRIPT: FIX #2376 ns.exit now exits immediately
This commit is contained in:
hydroflame 2022-09-23 00:57:15 -03:00 committed by GitHub
commit ed14f2a4d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

@ -79,6 +79,7 @@ import { CalculateShareMult, StartSharing } from "./NetworkShare/Share";
import { recentScripts } from "./Netscript/RecentScripts"; import { recentScripts } from "./Netscript/RecentScripts";
import { InternalAPI, NetscriptContext, wrapAPI } from "./Netscript/APIWrapper"; import { InternalAPI, NetscriptContext, wrapAPI } from "./Netscript/APIWrapper";
import { INetscriptExtra } from "./NetscriptFunctions/Extra"; import { INetscriptExtra } from "./NetscriptFunctions/Extra";
import { ScriptDeath } from "./Netscript/ScriptDeath";
export type NSFull = NS & INetscriptExtra; export type NSFull = NS & INetscriptExtra;
@ -833,12 +834,10 @@ const base: InternalAPI<NS> = {
return scriptsKilled > 0; return scriptsKilled > 0;
}, },
exit: (ctx: NetscriptContext) => (): void => { exit: (ctx: NetscriptContext) => (): never => {
if (killWorkerScript(ctx.workerScript)) {
helpers.log(ctx, () => "Exiting..."); helpers.log(ctx, () => "Exiting...");
} else { killWorkerScript(ctx.workerScript);
helpers.log(ctx, () => "Failed. This is a bug. Report to dev."); throw new ScriptDeath(ctx.workerScript);
}
}, },
scp: scp:
(ctx: NetscriptContext) => (ctx: NetscriptContext) =>

@ -5446,7 +5446,7 @@ export interface NS {
* @remarks * @remarks
* RAM cost: 0 GB * RAM cost: 0 GB
*/ */
exit(): void; exit(): never;
/** /**
* Copy file between servers. * Copy file between servers.