Fix script needlessly being recompiled (#932)

* Fix nsjs recompiling needlesly.
This commit is contained in:
hydroflame
2021-05-03 18:53:10 -04:00
committed by GitHub
parent 5613d371c9
commit 3cbf225c98
2 changed files with 10 additions and 2 deletions
+5
View File
@@ -1453,6 +1453,11 @@ function NetscriptFunctions(workerScript) {
if (scriptname == destServer.scripts[i].filename) {
workerScript.log("scp", `WARNING: File '${scriptname}' overwritten on '${destServer.hostname}'`);
const oldScript = destServer.scripts[i];
// If it's the exact same file don't actually perform the
// copy to avoid recompiling uselessly. Players tend to scp
// liberally.
if(oldScript.code === sourceScript.code)
return true;
oldScript.code = sourceScript.code;
oldScript.ramUsage = sourceScript.ramUsage;
oldScript.markUpdated();