mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-23 08:02:04 +02:00
MISC: Allow killing scripts during tutorial (#2797)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -675,18 +675,15 @@ export const ns: InternalAPI<NSFull> = {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user