Bugfixes for Corporations. hacknetnodes now accounts for RAM usage. Start of v0.34.3

This commit is contained in:
danielyxie
2018-01-29 23:14:17 -06:00
parent be17cff29e
commit 470b66e304
5 changed files with 628 additions and 1661 deletions
+8 -2
View File
@@ -296,7 +296,6 @@ function calculateRamUsage(codeCopy) {
try {
var ast = parse(codeCopy);
} catch(e) {
console.log("returning -1 bc parsing error: " + e.toString());
return -1;
}
@@ -339,7 +338,9 @@ function calculateRamUsage(codeCopy) {
if (typeof func === "function") {
try {
var res = func.apply(null, []);
if (!isNaN(res)) {ramUsage += res;}
if (typeof res === "number") {
ramUsage += res;
}
} catch(e) {
console.log("ERROR applying function: " + e);
}
@@ -358,6 +359,11 @@ function calculateRamUsage(codeCopy) {
}
}
}
//Special case: hacknetnodes array
if (codeCopy.includes("hacknetnodes")) {
ramUsage += CONSTANTS.ScriptHacknetNodesRamCost;
}
return ramUsage;
}