mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 22:22:26 +01:00
fix ram miscalc
This commit is contained in:
parent
4ce0b59310
commit
8ab9a27966
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -114,13 +114,14 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
threads = 1;
|
||||
}
|
||||
|
||||
workerScript.dynamicRamUsage += ramCost * threads;
|
||||
workerScript.dynamicRamUsage += ramCost;
|
||||
if (workerScript.dynamicRamUsage > 1.01 * workerScript.ramUsage) {
|
||||
throw makeRuntimeRejectMsg(
|
||||
workerScript,
|
||||
`Dynamic RAM usage calculated to be greater than initial RAM usage on fn: ${fnName}.
|
||||
This is probably because you somehow circumvented the static RAM calculation.
|
||||
|
||||
Threads: ${threads}
|
||||
Dynamic RAM Usage: ${numeralWrapper.formatRAM(workerScript.dynamicRamUsage)}
|
||||
Static RAM Usage: ${numeralWrapper.formatRAM(workerScript.ramUsage)}
|
||||
|
||||
|
@ -477,7 +477,8 @@ function createAndAddWorkerScript(runningScriptObj: RunningScript, server: BaseS
|
||||
} else {
|
||||
runningScriptObj.threads = 1;
|
||||
}
|
||||
const ramUsage = roundToTwo(getRamUsageFromRunningScript(runningScriptObj) * threads);
|
||||
const oneRamUsage = getRamUsageFromRunningScript(runningScriptObj);
|
||||
const ramUsage = roundToTwo(oneRamUsage * threads);
|
||||
const ramAvailable = server.maxRam - server.ramUsed;
|
||||
if (ramUsage > ramAvailable) {
|
||||
dialogBoxCreate(
|
||||
@ -502,7 +503,7 @@ function createAndAddWorkerScript(runningScriptObj: RunningScript, server: BaseS
|
||||
// Create the WorkerScript. NOTE: WorkerScript ctor will set the underlying
|
||||
// RunningScript's PID as well
|
||||
const s = new WorkerScript(runningScriptObj, pid, NetscriptFunctions);
|
||||
s.ramUsage = ramUsage;
|
||||
s.ramUsage = oneRamUsage;
|
||||
|
||||
// Add the WorkerScript to the global pool
|
||||
workerScripts.set(pid, s);
|
||||
|
Loading…
Reference in New Issue
Block a user