recompile ns2 scripts if dependencies change

This commit is contained in:
James Aguilar
2019-06-02 15:21:08 -04:00
parent c485fdfa87
commit 65331ab22e
3 changed files with 67 additions and 11 deletions
+16 -2
View File
@@ -31,6 +31,14 @@ export class Script {
// This is only applicable for NetscriptJS
module: any = "";
// The timestamp when when the script was last updated.
updateTimestamp: number = 0;
// Only used with NS2 scripts; the list of dependency script filenames. This is constructed
// whenever the script is first evaluated, and therefore may be out of date if the script
// has been updated since it was last run.
dependencies: string[] = [];
// Amount of RAM this Script requres to run
ramUsage: number = 0;
@@ -85,11 +93,17 @@ export class Script {
}
this.filename = filenameElem!.value;
this.server = serverIp;
this.updateRamUsage(otherScripts);
this.module = "";
this.updateRamUsage(otherScripts);
this.markUpdated();
}
}
// Marks that this script has been updated. Causes recompilation of NS2 modules.
markUpdated() {
this.module = "";
this.updateTimestamp = Date.now();
}
/**
* Calculates and updates the script's RAM usage based on its code
* @param {Script[]} otherScripts - Other scripts on the server. Used to process imports