Added some TODOs

This commit is contained in:
Daniel Xie 2016-11-29 17:38:50 -06:00
parent 867ae191b5
commit 2d41a63707
4 changed files with 25 additions and 11 deletions

@ -1,10 +1,13 @@
/* Worker code, contains Netscript scripts that are actually running */ /* Worker code, contains Netscript scripts that are actually running */
//TODO Need some way to stop scripts. Idea: Put a flag in the environment, we can setActive
//this flag from outside. If the evaluate() function sees that flag it rejects the current
// Promise. We can catch that rejection and stop the script.
/* Actual Worker Code */ /* Actual Worker Code */
function WorkerScript() { function WorkerScript() {
this.name = ""; this.name = "";
this.running = false; this.running = false;
this.server = null; this.serverHostname = null;
this.code = ""; this.code = "";
this.env = new Environment(); this.env = new Environment();
this.timeout = null; this.timeout = null;
@ -23,8 +26,8 @@ function runScriptsLoop() {
console.log("AST of new script:"); console.log("AST of new script:");
console.log(ast); console.log(ast);
evaluate(ast, workerScripts[i]);
workerScripts[i].running = true; workerScripts[i].running = true;
evaluate(ast, workerScripts[i]);
} }
} }

@ -1,4 +1,6 @@
//Netburner Server class //Netburner Server class
//TODO Make a map of all IPS in the game so far so that we don't accidentally
// get duplicate IPs..however unlikely it is
function Server() { function Server() {
/* Properties */ /* Properties */
//Connection information //Connection information
@ -18,7 +20,7 @@ function Server() {
this.cpuSpeed = 1; //MHz this.cpuSpeed = 1; //MHz
this.scripts = []; this.scripts = [];
this.runningScripts = []; //Names of scripts currently being run this.runningScripts = []; //Names (and only names) of scripts being run
this.programs = []; this.programs = [];
/* Hacking information (only valid for "foreign" aka non-purchased servers) */ /* Hacking information (only valid for "foreign" aka non-purchased servers) */

@ -434,10 +434,16 @@ var Terminal = {
if (Player.currentServer.hasAdminRights == false) { if (Player.currentServer.hasAdminRights == false) {
post("Need root access to run script"); post("Need root access to run script");
} else { } else {
//TODO Run script here var filename = Player.currentServer.scripts[i].filename;
//Add to current server's runningScripts
Player.currentServer.runningScripts.push(filename)
//Create WorkerScript
var s = new WorkerScript(); var s = new WorkerScript();
s.name = Player.currentServer.scripts[i].filename; s.name = filename;
s.code = Player.currentServer.scripts[i].code; s.code = Player.currentServer.scripts[i].code;
s.hostname = Player.currentServer.hostname;
workerScripts.push(s); workerScripts.push(s);
console.log("Pushed script onto workerScripts"); console.log("Pushed script onto workerScripts");
return; return;

@ -1,3 +1,6 @@
//TODO Saving only works with stirngs.key value pairs. Think of a system to do saves
// And everything with all the things I have
//Replaces the character at an index with a new character //Replaces the character at an index with a new character
String.prototype.replaceAt=function(index, character) { String.prototype.replaceAt=function(index, character) {
return this.substr(0, index) + character + this.substr(index+character.length); return this.substr(0, index) + character + this.substr(index+character.length);