killWorkerScript() now takes an optional argument for whether to rerenderUI. This is used to batch UI updates on killall()

This commit is contained in:
danielyxie
2019-06-22 01:12:17 -07:00
committed by danielyxie
parent 4cc6437408
commit 3a374de210
3 changed files with 30 additions and 21 deletions
+7 -4
View File
@@ -2,6 +2,7 @@ const sprintf = require("sprintf-js").sprintf;
const vsprintf = require("sprintf-js").vsprintf;
import { getRamCost } from "./Netscript/RamCostGenerator";
import { WorkerScriptStartStopEventEmitter } from "./Netscript/WorkerScriptStartStopEventEmitter";
import { Augmentation } from "./Augmentation/Augmentation";
import { Augmentations } from "./Augmentation/Augmentations";
@@ -983,18 +984,20 @@ function NetscriptFunctions(workerScript) {
if (ip === undefined) {
throw makeRuntimeRejectMsg(workerScript, "killall() call has incorrect number of arguments. Takes 1 argument");
}
var server = getServer(ip);
const server = getServer(ip);
if (server == null) {
workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip);
throw makeRuntimeRejectMsg(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip);
}
var scriptsRunning = (server.runningScripts.length > 0);
for (var i = server.runningScripts.length-1; i >= 0; --i) {
killWorkerScript(server.runningScripts[i], server.ip);
const scriptsRunning = (server.runningScripts.length > 0);
for (let i = server.runningScripts.length-1; i >= 0; --i) {
killWorkerScript(server.runningScripts[i], server.ip, false);
}
WorkerScriptStartStopEventEmitter.emitEvent();
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.killall == null) {
workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die");
}
return scriptsRunning;
},
exit : function() {