DEVMENU: Reset hacknet server list properly when setting level of SF9 (#2177)

This commit is contained in:
catloversg
2025-07-12 02:57:38 +07:00
committed by GitHub
parent f182030385
commit 073dd43d94
3 changed files with 30 additions and 17 deletions

View File

@@ -383,7 +383,7 @@ function processAllHacknetNodeEarnings(numCycles: number): number {
let total = 0;
for (let i = 0; i < Player.hacknetNodes.length; ++i) {
const node = Player.hacknetNodes[i];
if (typeof node === "string") throw new Error("player node should not be ip string");
if (typeof node === "string") throw new Error("player node should not be hostname string");
node.updateMoneyGainRate(Player.mults.hacknet_node_money);
total += processSingleHacknetNodeEarnings(numCycles, node);
}
@@ -405,12 +405,12 @@ function processAllHacknetServerEarnings(numCycles: number): number {
let hashes = 0;
for (let i = 0; i < Player.hacknetNodes.length; ++i) {
// hacknetNodes array only contains the IP addresses of the servers.
// hacknetNodes array only contains the hostnames of the servers.
// Also, update the hash rate before processing
const ip = Player.hacknetNodes[i];
if (ip instanceof HacknetNode) throw new Error(`player nodes should not be HacknetNode`);
const hserver = GetServer(ip);
if (!(hserver instanceof HacknetServer)) throw new Error(`player nodes should not be Server`);
const hostname = Player.hacknetNodes[i];
if (hostname instanceof HacknetNode) throw new Error(`player nodes should not be HacknetNode`);
const hserver = GetServer(hostname);
if (!(hserver instanceof HacknetServer)) throw new Error(`player nodes must be HacknetServer`);
hserver.updateHashRate(Player.mults.hacknet_node_money);
const h = hserver.process(numCycles);
hashes += h;
@@ -449,9 +449,9 @@ export function updateHashManagerCapacity(): void {
Player.hashManager.updateCapacity(0);
return;
}
const ip = nodes[i];
if (ip instanceof HacknetNode) throw new Error(`player nodes should be string but isn't`);
const h = GetServer(ip);
const hostname = nodes[i];
if (hostname instanceof HacknetNode) throw new Error(`player nodes should not be HacknetNode`);
const h = GetServer(hostname);
if (!(h instanceof HacknetServer)) {
Player.hashManager.updateCapacity(0);
return;