Testing making the script runner NOT be a different web worker thread.

This commit is contained in:
Daniel Xie
2016-11-28 16:13:13 -06:00
parent 4687b80256
commit 1efee3b7d6
3 changed files with 16 additions and 5 deletions

View File

@ -931,6 +931,10 @@ function runScriptsLoop() {
if (workerScripts[i].running == false) {
var ast = Parser(Tokenizer(InputStream(workerScripts[i].code)));
console.log("Starting new script: " + workerScripts[i].name);
console.log("AST of new script:");
console.log(ast);
evaluate(ast, workerScripts[i]);
workerScripts[i].running = true;
}

View File

@ -430,11 +430,16 @@ var Terminal = {
//Check if the script exists and if it does run it
for (var i = 0; i < Player.currentServer.scripts.length; i++) {
if (Player.currentServer.scripts[i] == scriptName) {
if (Player.currentServer.scripts[i].filename == scriptName) {
if (Player.currentServer.hasAdminRights == false) {
post("Need root access to run script");
} else {
//TODO Run script here
var s = new WorkerScript();
s.name = Player.currentServer.scripts[i].filename;
s.code = Player.currentServer.scripts[i].code;
workerScripts.push(s);
console.log("Pushed script onto workerScripts");
}
}
}

View File

@ -167,7 +167,7 @@ var Engine = {
if (Engine._scriptUpdateStatusCounter >= 50) {
console.log("Updating Script Status");
Engine._scriptUpdateStatusCounter = 0;
Engine.updateScriptStatus();
//Engine.updateScriptStatus();
}
window.requestAnimationFrame(Engine.idleTimer);
@ -252,9 +252,9 @@ var Engine = {
CompanyPositions.init();
}
if (window.Worker) {
Engine._scriptWebWorker = new Worker("netscript/NetscriptWorker.js");
}
//if (window.Worker) {
// Engine._scriptWebWorker = new Worker("netscript/NetscriptWorker.js");
//}
//Load, save, and delete buttons
//Engine.Clickables.saveButton = document.getElementById("save");
@ -313,6 +313,8 @@ var Engine = {
//Run main loop
Engine.idleTimer();
runScriptsLoop();
}
};