FIxed bug with script errors in nested progs

This commit is contained in:
Daniel Xie 2017-06-07 16:18:21 -05:00
parent a99e9391f2
commit 598efda098
4 changed files with 14 additions and 3 deletions

@ -25,6 +25,7 @@ function Faction(name) {
this.isMember = false; //Whether player is member
this.isBanned = false; //Whether or not player is banned from joining this faction
this.playerReputation = 0; //"Reputation" within faction
this.alreadyInvited = false;
//Multipliers for unlocking and purchasing augmentations
this.augmentationPriceMult = 1;

@ -104,8 +104,14 @@ function evaluate(exp, workerScript) {
evaluateProgPromise.then(function(w) {
resolve(workerScript);
}, function(e) {
workerScript.errorMessage = e.toString();
reject(workerScript);
if (typeof e === 'string' || e instanceof String) {
workerScript.errorMessage = e;
reject(workerScript);
} else if (e instanceof WorkerScript) {
reject(e);
} else {
reject(workerScript);
}
});
break;
case "call":

@ -212,7 +212,7 @@ function netscriptRunProgram(exp, workerScript, programName) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
if (exp.args.length != 1) {
return Promise.reject(makeRuntimeRejectMsg(workerScript, "nuke() call has incorrect number of arguments. Takes 1 argument"));
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"));
}
var ipPromise = evaluate(exp.args[0], workerScript);
return ipPromise.then(function(ip) {

@ -37,6 +37,8 @@ function Server() {
//Parameters used in formulas that dictate how moneyAvailable and requiredHackingSkill change.
this.hackDifficulty = 1; //Affects hack success rate and how the requiredHackingSkill increases over time (1-100)
this.baseDifficulty = 1; //Starting difficulty
this.minDifficulty = 1;
this.serverGrowth = 0; //Affects how the moneyAvailable increases (0-100)
this.timesHacked = 0;
@ -80,6 +82,8 @@ Server.prototype.setHackingParameters = function(requiredHackingSkill, moneyAvai
this.moneyAvailable = moneyAvailable;
this.moneyMax = 50 * moneyAvailable;
this.hackDifficulty = hackDifficulty;
this.baseDifficulty = hackDifficulty;
this.minDifficulty = Math.max(1, hackDifficulty - 25);
this.serverGrowth = serverGrowth;
}