From 37dc341bb70afe17458aed0c7ef840e5ab3667e1 Mon Sep 17 00:00:00 2001 From: Alain Bryden <2285037+alainbryden@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:28:44 -0300 Subject: [PATCH] Fix stats.js not properly filtering out hacknet servers once renamed from hacknet-node --- stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stats.js b/stats.js index 223a603e..1168be62 100644 --- a/stats.js +++ b/stats.js @@ -246,7 +246,7 @@ async function getHudData(ns, bitNode, dictSourceFiles, options) { const servers = await getAllServersInfo(ns); const rooted = servers.filter(s => s.hasAdminRights).length; const purchased = servers.filter(s => s.hostname != "home" && s.purchasedByPlayer).length; // "home" counts as purchased by the game - const likelyHacknet = servers.filter(s => s.hostname.startsWith("hacknet-node-")); + const likelyHacknet = servers.filter(s => s.hostname.startsWith("hacknet-server-") || s.hostname.startsWith("hacknet-node-")); // Add Server count. val1.push(true, `${servers.length}/${rooted}/${purchased}`, `The number of servers on the network (${servers.length}) / ` + `number rooted (${rooted}) / number purchased ` + (likelyHacknet.length > 0 ? @@ -258,7 +258,7 @@ async function getHudData(ns, bitNode, dictSourceFiles, options) { `${formatRam(home.ramUsed, true)} of ${formatRam(home.maxRam, true)} (${formatRam(home.maxRam - home.ramUsed, true)} free)`); // If the user has any scripts running on hacknet servers, assume they want them included in available RAM stats const includeHacknet = likelyHacknet.some(s => s.ramUsed > 0); - const [totalMax, totalUsed] = servers.filter(s => s.hasAdminRights && (includeHacknet || !s.hostname.startsWith("hacknet-node-"))) + const [totalMax, totalUsed] = servers.filter(s => s.hasAdminRights && (includeHacknet || !(s.hostname.startsWith("hacknet-server-") || s.hostname.startsWith("hacknet-node-")))) .reduce(([totalMax, totalUsed], s) => [totalMax + s.maxRam, totalUsed + s.ramUsed], [0, 0]); // Add Total Network RAM and Utilization val3.push(true, `${formatRam(totalMax)} ${(100 * totalUsed / totalMax).toFixed(1)}%`,