mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 17:53:00 +02:00
Refactored stock buying/selling code into its own file. Refactored WorkerScript & NetscriptEnvironment into their own Typescript classes. Refactored a ton of code to remove circular dependencies
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { AllServers } from "../Server/AllServers";
|
||||
import { RunningScript } from "./RunningScript";
|
||||
|
||||
export function getRamUsageFromRunningScript(script: RunningScript): number {
|
||||
if (script.ramUsage != null && script.ramUsage > 0) {
|
||||
return script.ramUsage; // Use cached value
|
||||
}
|
||||
|
||||
const server = AllServers[script.server];
|
||||
if (server == null) { return 0; }
|
||||
for (let i = 0; i < server.scripts.length; ++i) {
|
||||
if (server.scripts[i].filename === script.filename) {
|
||||
// Cache the ram usage for the next call
|
||||
script.ramUsage = server.scripts[i].ramUsage;
|
||||
return script.ramUsage;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user