From 0e39a5f6039eb9ea8eecaca21b92868e90b9ce23 Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Fri, 22 May 2026 07:57:06 +0700 Subject: [PATCH] MISC: Allow killing scripts during tutorial (#2797) --- src/Netscript/killWorkerScript.ts | 10 +--------- src/NetscriptFunctions.ts | 11 ++++------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/Netscript/killWorkerScript.ts b/src/Netscript/killWorkerScript.ts index 1a620f2a0..076a7528b 100644 --- a/src/Netscript/killWorkerScript.ts +++ b/src/Netscript/killWorkerScript.ts @@ -8,20 +8,12 @@ import { workerScripts } from "./WorkerScripts"; import { GetAllServers, GetServer } from "../Server/AllServers"; import { AddRecentScript } from "./RecentScripts"; -import { ITutorial } from "../InteractiveTutorial"; -import { AlertEvents } from "../ui/React/AlertManager"; import { handleUnknownError } from "../utils/ErrorHandler"; import { roundToTwo } from "../utils/helpers/roundToTwo"; import { BaseServer } from "../Server/BaseServer"; -export function killWorkerScript(ws: WorkerScript): boolean { - if (ITutorial.isRunning) { - AlertEvents.emit("Processes cannot be killed during the tutorial."); - return false; - } +export function killWorkerScript(ws: WorkerScript): void { stopAndCleanUpWorkerScript(ws); - - return true; } export function killWorkerScriptByPid(pid: number, killer?: WorkerScript): boolean { diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index b9cdb0ae6..5cbe10ebe 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -675,18 +675,15 @@ export const ns: InternalAPI = { } helpers.log(ctx, () => "About to exit..."); - const killed = killWorkerScript(ctx.workerScript); + killWorkerScript(ctx.workerScript); if (runOpts.spawnDelay === 0) { helpers.log(ctx, () => `Executing '${path}' immediately`); spawnCb(); } - - if (killed) { - // This prevents error messages about statements after the spawn() - // trying to be executed when the script is dead. - throw new ScriptDeath(ctx.workerScript); - } + // This prevents error messages about statements after the spawn() + // trying to be executed when the script is dead. + throw new ScriptDeath(ctx.workerScript); }, self: (ctx) => () => { const runningScript = helpers.getRunningScript(ctx, ctx.workerScript.pid);