mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 22:38:34 +02:00
remove last colon any for now
This commit is contained in:
@@ -15,52 +15,43 @@ import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||
import { AddRecentScript } from "./RecentScripts";
|
||||
import { Player } from "../Player";
|
||||
|
||||
export function killWorkerScript(runningScriptObj: RunningScript, hostname: string, rerenderUi?: boolean): boolean;
|
||||
export function killWorkerScript(workerScript: WorkerScript): boolean;
|
||||
export function killWorkerScript(pid: number): boolean;
|
||||
export function killWorkerScript(
|
||||
script: RunningScript | WorkerScript | number,
|
||||
hostname?: string,
|
||||
rerenderUi?: boolean,
|
||||
): boolean {
|
||||
if (rerenderUi == null || typeof rerenderUi !== "boolean") {
|
||||
rerenderUi = true;
|
||||
}
|
||||
export type killScriptParams = WorkerScript | number | { runningScript: RunningScript; hostname: string };
|
||||
|
||||
if (script instanceof WorkerScript) {
|
||||
stopAndCleanUpWorkerScript(script);
|
||||
export function killWorkerScript(params: killScriptParams): boolean {
|
||||
if (params instanceof WorkerScript) {
|
||||
stopAndCleanUpWorkerScript(params);
|
||||
|
||||
return true;
|
||||
} else if (script instanceof RunningScript && typeof hostname === "string") {
|
||||
} else if (typeof params === "number") {
|
||||
return killWorkerScriptByPid(params);
|
||||
} else {
|
||||
// Try to kill by PID
|
||||
const res = killWorkerScriptByPid(script.pid, rerenderUi);
|
||||
const res = killWorkerScriptByPid(params.runningScript.pid);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
// If for some reason that doesn't work, we'll try the old way
|
||||
for (const ws of workerScripts.values()) {
|
||||
if (ws.name == script.filename && ws.hostname == hostname && compareArrays(ws.args, script.args)) {
|
||||
stopAndCleanUpWorkerScript(ws, rerenderUi);
|
||||
if (
|
||||
ws.name == params.runningScript.filename &&
|
||||
ws.hostname == params.hostname &&
|
||||
compareArrays(ws.args, params.runningScript.args)
|
||||
) {
|
||||
stopAndCleanUpWorkerScript(ws);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if (typeof script === "number") {
|
||||
return killWorkerScriptByPid(script, rerenderUi);
|
||||
} else {
|
||||
console.error(`killWorkerScript() called with invalid argument:`);
|
||||
console.error(script);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function killWorkerScriptByPid(pid: number, rerenderUi = true): boolean {
|
||||
function killWorkerScriptByPid(pid: number): boolean {
|
||||
const ws = workerScripts.get(pid);
|
||||
if (ws instanceof WorkerScript) {
|
||||
stopAndCleanUpWorkerScript(ws, rerenderUi);
|
||||
stopAndCleanUpWorkerScript(ws);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -68,7 +59,7 @@ function killWorkerScriptByPid(pid: number, rerenderUi = true): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
function stopAndCleanUpWorkerScript(workerScript: WorkerScript, rerenderUi = true): void {
|
||||
function stopAndCleanUpWorkerScript(workerScript: WorkerScript): void {
|
||||
if (typeof workerScript.atExit === "function") {
|
||||
try {
|
||||
workerScript.atExit();
|
||||
@@ -83,7 +74,7 @@ function stopAndCleanUpWorkerScript(workerScript: WorkerScript, rerenderUi = tru
|
||||
}
|
||||
workerScript.env.stopFlag = true;
|
||||
killNetscriptDelay(workerScript);
|
||||
removeWorkerScript(workerScript, rerenderUi);
|
||||
removeWorkerScript(workerScript);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +84,7 @@ function stopAndCleanUpWorkerScript(workerScript: WorkerScript, rerenderUi = tru
|
||||
* @param {WorkerScript} - Identifier for WorkerScript. Either the object itself, or
|
||||
* its index in the global workerScripts array
|
||||
*/
|
||||
function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void {
|
||||
function removeWorkerScript(workerScript: WorkerScript): void {
|
||||
const ip = workerScript.hostname;
|
||||
const name = workerScript.name;
|
||||
|
||||
@@ -127,9 +118,7 @@ function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void
|
||||
// }
|
||||
AddRecentScript(workerScript);
|
||||
|
||||
if (rerenderUi) {
|
||||
WorkerScriptStartStopEventEmitter.emit();
|
||||
}
|
||||
WorkerScriptStartStopEventEmitter.emit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user