mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 20:37:05 +02:00
BUGFIX: Grow log shows invalid values in edge cases (#1872)
This commit is contained in:
@@ -33,19 +33,23 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
||||
if (runningScript.dataMap[hostname][2] == 0 || runningScript.dataMap[hostname][2] == null) {
|
||||
continue;
|
||||
}
|
||||
const serv = GetServer(hostname);
|
||||
if (serv == null) {
|
||||
const server = GetServer(hostname);
|
||||
if (server == null) {
|
||||
continue;
|
||||
}
|
||||
const timesGrown = Math.round(
|
||||
((0.5 * runningScript.dataMap[hostname][2]) / runningScript.onlineRunningTime) * timePassed,
|
||||
);
|
||||
runningScript.log(`Called on ${serv.hostname} ${timesGrown} times while offline`);
|
||||
runningScript.log(`Called on ${server.hostname} ${timesGrown} times while offline`);
|
||||
const host = GetServer(runningScript.server);
|
||||
if (host === null) throw new Error("getServer of null key?");
|
||||
if (!(serv instanceof Server)) throw new Error("trying to grow a non-normal server");
|
||||
const growth = processSingleServerGrowth(serv, timesGrown, host.cpuCores);
|
||||
runningScript.log(`'${serv.hostname}' grown by ${formatPercent(growth - 1, 6)} while offline`);
|
||||
if (host === null) {
|
||||
throw new Error("getServer of null key?");
|
||||
}
|
||||
if (!(server instanceof Server)) {
|
||||
throw new Error("trying to grow a non-normal server");
|
||||
}
|
||||
const growth = processSingleServerGrowth(server, timesGrown, host.cpuCores);
|
||||
runningScript.log(`'${server.hostname}' grown by ${formatPercent(growth - 1, 6)} while offline`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user