mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-08 08:37:48 +02:00
DARKNET: Darkweb Expansion Project & Bitnode (#2139)
This is BN15. It is a really big change; see the PR for all the details.
This commit is contained in:
committed by
GitHub
parent
a674633f6c
commit
6073964768
@@ -12,6 +12,7 @@ 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) {
|
||||
@@ -35,15 +36,30 @@ export function killWorkerScriptByPid(pid: number, killer?: WorkerScript): boole
|
||||
}
|
||||
|
||||
export const killAllScripts = () => {
|
||||
for (const server of GetAllServers()) {
|
||||
for (const byPid of server.runningScriptMap.values()) {
|
||||
for (const pid of byPid.keys()) {
|
||||
killWorkerScriptByPid(pid);
|
||||
}
|
||||
for (const server of GetAllServers(true)) {
|
||||
killServerScripts(server, "Script killed.");
|
||||
}
|
||||
};
|
||||
|
||||
export const killServerScripts = (server: BaseServer, message: string) => {
|
||||
const scripts = server.runningScriptMap.values();
|
||||
for (const byPid of scripts) {
|
||||
for (const runningScript of byPid.values()) {
|
||||
killWorkerScriptWithMessage(runningScript.pid, message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function killWorkerScriptWithMessage(pid: number, message: string): boolean {
|
||||
const ws = workerScripts.get(pid);
|
||||
if (ws) {
|
||||
ws.log("", () => message);
|
||||
stopAndCleanUpWorkerScript(ws);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function stopAndCleanUpWorkerScript(ws: WorkerScript): void {
|
||||
// Only clean up once.
|
||||
// Important: Only this function can set stopFlag!
|
||||
|
||||
Reference in New Issue
Block a user