mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
use sequence numbers rather than timestamps for script expiration
This commit is contained in:
parent
2201dfc371
commit
d45689c7df
@ -74,7 +74,7 @@ function shouldCompile(script, scripts) {
|
||||
// compilation errors.
|
||||
if (!depScript) return true;
|
||||
|
||||
const depIsMoreRecent = depScript.updateTimestamp > script.updateTimestamp
|
||||
const depIsMoreRecent = depScript.moduleSequenceNumber > script.moduleSequenceNumber
|
||||
return depIsMoreRecent;
|
||||
});
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ import {
|
||||
} from "../../utils/JSONReviver";
|
||||
import { roundToTwo } from "../../utils/helpers/roundToTwo";
|
||||
|
||||
let globalModuleSequenceNumber = 0;
|
||||
|
||||
export class Script {
|
||||
// Initializes a Script Object from a JSON save state
|
||||
static fromJSON(value: any): Script {
|
||||
@ -32,7 +34,7 @@ export class Script {
|
||||
module: any = "";
|
||||
|
||||
// The timestamp when when the script was last updated.
|
||||
updateTimestamp: number = 0;
|
||||
moduleSequenceNumber: number;
|
||||
|
||||
// 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
|
||||
@ -51,6 +53,7 @@ export class Script {
|
||||
this.ramUsage = 0;
|
||||
this.server = server; // IP of server this script is on
|
||||
this.module = "";
|
||||
this.moduleSequenceNumber = ++globalModuleSequenceNumber;
|
||||
if (this.code !== "") { this.updateRamUsage(otherScripts); }
|
||||
};
|
||||
|
||||
@ -101,7 +104,7 @@ export class Script {
|
||||
// Marks that this script has been updated. Causes recompilation of NS2 modules.
|
||||
markUpdated() {
|
||||
this.module = "";
|
||||
this.updateTimestamp = Date.now();
|
||||
this.moduleSequenceNumber = ++globalModuleSequenceNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user