mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 01:32:55 +02:00
fix buying programs and writing them at the same time.
This commit is contained in:
@@ -248,6 +248,19 @@ export class BaseServer {
|
||||
this.ramUsed = ram;
|
||||
}
|
||||
|
||||
pushProgram(program: string): void {
|
||||
if (this.programs.includes(program)) return;
|
||||
|
||||
// Remove partially created program if there is one
|
||||
const existingPartialExeIndex = this.programs.findIndex((p) => p.startsWith(program));
|
||||
// findIndex returns -1 if there is no match, we only want to splice on a match
|
||||
if (existingPartialExeIndex > -1) {
|
||||
this.programs.splice(existingPartialExeIndex, 1);
|
||||
}
|
||||
|
||||
this.programs.push(program);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write to a script file
|
||||
* Overwrites existing files. Creates new files if the script does not eixst
|
||||
|
||||
Reference in New Issue
Block a user