BUGFIX: Grow log shows invalid values in edge cases (#1872)

This commit is contained in:
catloversg
2025-01-09 09:48:45 +07:00
committed by GitHub
parent 5b6380a5c3
commit 8c19165323
4 changed files with 25 additions and 14 deletions
+11 -7
View File
@@ -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`);
}
}