scp() command in scripts now overwrites scripts at destination. Fixed some bugs in Network creation

This commit is contained in:
Daniel Xie 2017-06-02 14:46:14 -05:00
parent a3d45b3cc2
commit f738034033
4 changed files with 34 additions and 22 deletions

@ -801,36 +801,48 @@ function evaluate(exp, workerScript) {
return;
}
//Check that a script with this filename does not already exist
for (var i = 0; i < destServer.scripts.length; ++i) {
if (scriptname == destServer.scripts[i].filename) {
workerScript.scriptRef.log(destServer.hostname + " already contains a script named " + scriptname);
resolve(false);
return;
}
}
var currServ = getServer(workerScript.serverIp);
if (currServ == null) {
reject(makeRuntimeRejectMsg(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"));
return;
}
var sourceScript = null;
for (var i = 0; i < currServ.scripts.length; ++i) {
if (scriptname == currServ.scripts[i].filename) {
var newScript = new Script();
newScript.filename = scriptname;
newScript.code = currServ.scripts[i].code;
newScript.ramUsage = currServ.scripts[i].ramUsage;
newScript.server = destServer.ip;
destServer.scripts.push(newScript);
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
sourceScript = currServ.scripts[i];
break;
}
}
if (sourceScript == null) {
workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
resolve(false);
return;
}
//Overwrite script if it already exists
for (var i = 0; i < destServer.scripts.length; ++i) {
if (scriptname == destServer.scripts[i].filename) {
workerScript.scriptRef.log("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and it will be overwritten.");
workerScript.scriptRef.log(scriptname + " overwritten on " + destServer.hostname);
var oldScript = destServer.scripts[i];
oldScript.code = sourceScript.code;
oldScript.ramUsage = sourceScript.ramUsage;
resolve(true);
return;
}
}
workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
resolve(false);
//Create new script if it does not already exist
var newScript = new Script();
newScript.filename = scriptname;
newScript.code = sourceScript.code;
newScript.ramUsage = sourceScript.ramUsage;
newScript.server = destServer.ip;
destServer.scripts.push(newScript);
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
resolve(true);
return;
}, function(e) {
reject(e);
});

@ -33,6 +33,7 @@ function runScriptsLoop() {
var ast = Parser(Tokenizer(InputStream(workerScripts[i].code)));
//console.log(ast);
} catch (e) {
console.log("Error parsing script: " + workerScripts[i].name);
dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":<br>" + e);
workerScripts[i].env.stopFlag = true;
continue;

@ -573,9 +573,9 @@ initForeignServers = function() {
var NetworkGroup3 = [OmegaSoftwareServer, PhantasyServer, SilverHelixServer, NeoNightclubServer];
var NetworkGroup4 = [CrushFitnessGymServer, NetLinkTechnologiesServer, CompuTekServer, TheHubServer, JohnsonOrthopedicsServer, NiteSecServer];
var NetworkGroup5 = [CatalystVenturesServer, SysCoreSecuritiesServer, SummitUniversityServer, ZBInstituteOfTechnologyServer, RothmanUniversityServer, TheBlackHandServer];
var NetworkGroup6 = [LexoCorpServer, RhoConstructionServer, AlphaEnterprisesServer, AevumPoliceServer, MilleniumFitnessGymServer, CyberSecServer, NiteSecServer];
var NetworkGroup6 = [LexoCorpServer, RhoConstructionServer, AlphaEnterprisesServer, AevumPoliceServer, MilleniumFitnessGymServer];
var NetworkGroup7 = [GlobalPharmaceuticalsServer, AeroCorpServer, GalacticCyberSystemsServer, SnapFitnessGymServer];
var NetworkGroup8 = [DeltaOneServer, UnitaLifeGroupServer, OmniaCybersystemsServer, BitRunnersServer];
var NetworkGroup8 = [DeltaOneServer, UnitaLifeGroupServer, OmniaCybersystemsServer];
var NetworkGroup9 = [ZeusMedicalServer, SolarisSpaceSystemsServer, UniversalEnergyServer, IcarusMicrosystemsServer, DefCommServer];
var NetworkGroup10 = [NovaMedicalServer, ZBDefenseServer, TaiYangDigitalServer, InfoCommServer];
var NetworkGroup11 = [AppliedEnergeticsServer, MicrodyneTechnologiesServer, TitanLabsServer, BitRunnersServer];

@ -384,7 +384,6 @@ var Terminal = {
//Process any aliases
command = substituteAliases(command);
console.log("command after alises: " + command);
//Only split the first space
var commandArray = command.split(" ");