Better error message for dynamic ram miscalculation

This commit is contained in:
Olivier Gagnon 2021-09-04 19:27:16 -04:00
parent a18bdd6afc
commit 05bab22807
2 changed files with 29 additions and 19 deletions

@ -243,15 +243,27 @@ function NetscriptFunctions(workerScript) {
if (workerScript.dynamicRamUsage > 1.01 * workerScript.ramUsage) { if (workerScript.dynamicRamUsage > 1.01 * workerScript.ramUsage) {
throw makeRuntimeRejectMsg( throw makeRuntimeRejectMsg(
workerScript, workerScript,
"Dynamic RAM usage calculated to be greater than initial RAM usage on fn: " + `Dynamic RAM usage calculated to be greater than initial RAM usage on fn: ${fnName}.
fnName + This is probably because you somehow circumvented the static RAM calculation.
". This is probably because you somehow circumvented the static RAM " +
"calculation.<br><br>Please don't do that :(<br><br>" + Dynamic RAM Usage: ${numeralWrapper.formatRAM(
"Dynamic RAM Usage: " + workerScript.dynamicRamUsage,
numeralWrapper.formatRAM(workerScript.dynamicRamUsage) + )}
"<br>" + Static RAM Usage: ${numeralWrapper.formatRAM(workerScript.ramUsage)}
"Static RAM Usage: " +
numeralWrapper.formatRAM(workerScript.ramUsage), One of these could be the reason:
* Using eval() to get a reference to a ns function
&nbsp;&nbsp;const scan = eval('ns.scan');
* Using map access to do the same
&nbsp;&nbsp;const scan = ns['scan'];
* Saving script in the improper order.
&nbsp;&nbsp;Increase the cost of an imported script, save it, then run the
&nbsp;&nbsp;parent. To fix this just re-open & save every script in order
&nbsp;&nbsp;from most imported to least imported (parent script).
Sorry :(`,
); );
} }
}; };

@ -2512,9 +2512,7 @@
a = this.matrix ? Q(a, this.matrix) : a; a = this.matrix ? Q(a, this.matrix) : a;
for (var s = 1; s < r + 1; s++) for (var s = 1; s < r + 1; s++)
n.push( n.push(
i i.path(a).attr({
.path(a)
.attr({
stroke: e.color, stroke: e.color,
fill: e.fill ? e.color : "none", fill: e.fill ? e.color : "none",
"stroke-linejoin": "round", "stroke-linejoin": "round",