mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 05:05:47 +01:00
scp() command in scripts now overwrites scripts at destination. Fixed some bugs in Network creation
This commit is contained in:
parent
a3d45b3cc2
commit
f738034033
@ -801,36 +801,48 @@ function evaluate(exp, workerScript) {
|
|||||||
return;
|
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);
|
var currServ = getServer(workerScript.serverIp);
|
||||||
if (currServ == null) {
|
if (currServ == null) {
|
||||||
reject(makeRuntimeRejectMsg(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"));
|
reject(makeRuntimeRejectMsg(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sourceScript = null;
|
||||||
for (var i = 0; i < currServ.scripts.length; ++i) {
|
for (var i = 0; i < currServ.scripts.length; ++i) {
|
||||||
if (scriptname == currServ.scripts[i].filename) {
|
if (scriptname == currServ.scripts[i].filename) {
|
||||||
var newScript = new Script();
|
sourceScript = currServ.scripts[i];
|
||||||
newScript.filename = scriptname;
|
break;
|
||||||
newScript.code = currServ.scripts[i].code;
|
}
|
||||||
newScript.ramUsage = currServ.scripts[i].ramUsage;
|
}
|
||||||
newScript.server = destServer.ip;
|
if (sourceScript == null) {
|
||||||
destServer.scripts.push(newScript);
|
workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
|
||||||
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
|
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);
|
resolve(true);
|
||||||
return;
|
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) {
|
}, function(e) {
|
||||||
reject(e);
|
reject(e);
|
||||||
});
|
});
|
||||||
|
@ -33,6 +33,7 @@ function runScriptsLoop() {
|
|||||||
var ast = Parser(Tokenizer(InputStream(workerScripts[i].code)));
|
var ast = Parser(Tokenizer(InputStream(workerScripts[i].code)));
|
||||||
//console.log(ast);
|
//console.log(ast);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log("Error parsing script: " + workerScripts[i].name);
|
||||||
dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":<br>" + e);
|
dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":<br>" + e);
|
||||||
workerScripts[i].env.stopFlag = true;
|
workerScripts[i].env.stopFlag = true;
|
||||||
continue;
|
continue;
|
||||||
|
@ -573,9 +573,9 @@ initForeignServers = function() {
|
|||||||
var NetworkGroup3 = [OmegaSoftwareServer, PhantasyServer, SilverHelixServer, NeoNightclubServer];
|
var NetworkGroup3 = [OmegaSoftwareServer, PhantasyServer, SilverHelixServer, NeoNightclubServer];
|
||||||
var NetworkGroup4 = [CrushFitnessGymServer, NetLinkTechnologiesServer, CompuTekServer, TheHubServer, JohnsonOrthopedicsServer, NiteSecServer];
|
var NetworkGroup4 = [CrushFitnessGymServer, NetLinkTechnologiesServer, CompuTekServer, TheHubServer, JohnsonOrthopedicsServer, NiteSecServer];
|
||||||
var NetworkGroup5 = [CatalystVenturesServer, SysCoreSecuritiesServer, SummitUniversityServer, ZBInstituteOfTechnologyServer, RothmanUniversityServer, TheBlackHandServer];
|
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 NetworkGroup7 = [GlobalPharmaceuticalsServer, AeroCorpServer, GalacticCyberSystemsServer, SnapFitnessGymServer];
|
||||||
var NetworkGroup8 = [DeltaOneServer, UnitaLifeGroupServer, OmniaCybersystemsServer, BitRunnersServer];
|
var NetworkGroup8 = [DeltaOneServer, UnitaLifeGroupServer, OmniaCybersystemsServer];
|
||||||
var NetworkGroup9 = [ZeusMedicalServer, SolarisSpaceSystemsServer, UniversalEnergyServer, IcarusMicrosystemsServer, DefCommServer];
|
var NetworkGroup9 = [ZeusMedicalServer, SolarisSpaceSystemsServer, UniversalEnergyServer, IcarusMicrosystemsServer, DefCommServer];
|
||||||
var NetworkGroup10 = [NovaMedicalServer, ZBDefenseServer, TaiYangDigitalServer, InfoCommServer];
|
var NetworkGroup10 = [NovaMedicalServer, ZBDefenseServer, TaiYangDigitalServer, InfoCommServer];
|
||||||
var NetworkGroup11 = [AppliedEnergeticsServer, MicrodyneTechnologiesServer, TitanLabsServer, BitRunnersServer];
|
var NetworkGroup11 = [AppliedEnergeticsServer, MicrodyneTechnologiesServer, TitanLabsServer, BitRunnersServer];
|
||||||
|
@ -384,7 +384,6 @@ var Terminal = {
|
|||||||
|
|
||||||
//Process any aliases
|
//Process any aliases
|
||||||
command = substituteAliases(command);
|
command = substituteAliases(command);
|
||||||
console.log("command after alises: " + command);
|
|
||||||
|
|
||||||
//Only split the first space
|
//Only split the first space
|
||||||
var commandArray = command.split(" ");
|
var commandArray = command.split(" ");
|
||||||
|
Loading…
Reference in New Issue
Block a user