mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-24 15:12:27 +01:00
Minor improvements to Netscript Port loading and unloading
This commit is contained in:
parent
0044761fd3
commit
2a0dd6b6f8
@ -493,15 +493,10 @@ function getValidPort(ctx: NetscriptContext, port: number): IPort {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
let iport = NetscriptPorts.get(port);
|
let iport = NetscriptPorts.get(port);
|
||||||
if (iport == null || !(iport instanceof Object)) {
|
if (!iport) {
|
||||||
NetscriptPorts.set(port, NetscriptPort());
|
iport = NetscriptPort();
|
||||||
|
NetscriptPorts.set(port, iport);
|
||||||
}
|
}
|
||||||
// Try again.
|
|
||||||
iport = NetscriptPorts.get(port);
|
|
||||||
if (iport == null || !(iport instanceof Object)) {
|
|
||||||
throw helpers.makeRuntimeErrorMsg(ctx, `Could not find port: ${port}. This is a bug. Report to dev.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return iport;
|
return iport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,9 +45,7 @@ export function prestigeWorkerScripts(): void {
|
|||||||
killWorkerScript(ws);
|
killWorkerScript(ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [__, port] of NetscriptPorts.entries()) {
|
NetscriptPorts.clear();
|
||||||
port.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkerScriptStartStopEventEmitter.emit();
|
WorkerScriptStartStopEventEmitter.emit();
|
||||||
workerScripts.clear();
|
workerScripts.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user