CODEBASE: Follow-up of #2344 (#2345)

This commit is contained in:
catloversg
2025-10-13 03:26:03 +07:00
committed by GitHub
parent 030be41df9
commit 2dfc2126df
2 changed files with 16 additions and 4 deletions
+6 -2
View File
@@ -548,13 +548,17 @@ function hack(ctx: NetscriptContext, hostname: string, manual: boolean, opts: un
let moneyDrained = server.moneyAvailable * percentHacked * threads;
// Over-the-top safety checks
if (moneyDrained <= 0) {
if (moneyDrained < 0) {
moneyDrained = 0;
expGainedOnSuccess = expGainedOnFailure;
}
if (moneyDrained > server.moneyAvailable) {
moneyDrained = server.moneyAvailable;
}
if (moneyDrained === 0) {
expGainedOnSuccess = expGainedOnFailure;
}
server.moneyAvailable -= moneyDrained;
if (server.moneyAvailable < 0) {
server.moneyAvailable = 0;