mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-20 16:22:56 +02:00
Fixed bug where hacking special servers w/ no money would result in NaN because of a '0 / 0' in fortify() calculation
This commit is contained in:
@@ -298,7 +298,11 @@ function NetscriptFunctions(workerScript) {
|
||||
var expGainedOnFailure = (expGainedOnSuccess / 4);
|
||||
if (rand < hackChance) { //Success!
|
||||
const percentHacked = scriptCalculatePercentMoneyHacked(server);
|
||||
const maxThreadNeeded = Math.ceil(1/percentHacked*(server.moneyAvailable/server.moneyMax))
|
||||
let maxThreadNeeded = Math.ceil(1/percentHacked*(server.moneyAvailable/server.moneyMax));
|
||||
if (isNaN(maxThreadNeeded)) {
|
||||
maxThreadNeeded = 1e6; //Server has a 'max money' of 0 (probably)
|
||||
}
|
||||
|
||||
let moneyGained = Math.floor(server.moneyAvailable * percentHacked) * threads;
|
||||
|
||||
//Over-the-top safety checks
|
||||
|
||||
Reference in New Issue
Block a user