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);
|
||||
if (iport == null || !(iport instanceof Object)) {
|
||||
NetscriptPorts.set(port, NetscriptPort());
|
||||
if (!iport) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -45,9 +45,7 @@ export function prestigeWorkerScripts(): void {
|
||||
killWorkerScript(ws);
|
||||
}
|
||||
|
||||
for (const [__, port] of NetscriptPorts.entries()) {
|
||||
port.clear();
|
||||
}
|
||||
NetscriptPorts.clear();
|
||||
|
||||
WorkerScriptStartStopEventEmitter.emit();
|
||||
workerScripts.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user