From 3e61780fadaa31ea4adfb5ce24f643c287858e79 Mon Sep 17 00:00:00 2001 From: Chris Rabe Date: Mon, 31 Jan 2022 08:14:10 +1000 Subject: [PATCH] fix: fixed hackAnalyzeThreads returning infinity --- src/NetscriptFunctions.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index ae6cd479e..b09ca099e 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -536,6 +536,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { const percentHacked = calculatePercentMoneyHacked(server, Player); + if (percentHacked === 0 || server.moneyAvailable === 0) { + return 0; // To prevent returning infinity below + } + return hackAmount / Math.floor(server.moneyAvailable * percentHacked); }, hackAnalyze: function (hostname: any): any {