mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 09:33:49 +01:00
asdf
This commit is contained in:
parent
0c932dd4d1
commit
dc518e7032
@ -2354,7 +2354,7 @@ function NetscriptFunctions(workerScript) {
|
||||
);
|
||||
}
|
||||
var port = NetscriptPorts[port - 1];
|
||||
if (port == null || !(port instanceof NetscriptPort)) {
|
||||
if (port == null || !(port instanceof Object)) {
|
||||
throw makeRuntimeErrorMsg("write", `Could not find port: ${port}. This is a bug. Report to dev.`);
|
||||
}
|
||||
return port.write(data);
|
||||
@ -2421,7 +2421,7 @@ function NetscriptFunctions(workerScript) {
|
||||
);
|
||||
}
|
||||
var port = NetscriptPorts[port - 1];
|
||||
if (port == null || !(port instanceof NetscriptPort)) {
|
||||
if (port == null || !(port instanceof Object)) {
|
||||
throw makeRuntimeErrorMsg("tryWrite", `Could not find port: ${port}. This is a bug. Report to dev.`);
|
||||
}
|
||||
return port.tryWrite(data);
|
||||
@ -2442,7 +2442,7 @@ function NetscriptFunctions(workerScript) {
|
||||
);
|
||||
}
|
||||
var port = NetscriptPorts[port - 1];
|
||||
if (port == null || !(port instanceof NetscriptPort)) {
|
||||
if (port == null || !(port instanceof Object)) {
|
||||
throw makeRuntimeErrorMsg("read", `Could not find port: ${port}. This is a bug. Report to dev.`);
|
||||
}
|
||||
return port.read();
|
||||
@ -2489,7 +2489,7 @@ function NetscriptFunctions(workerScript) {
|
||||
);
|
||||
}
|
||||
var port = NetscriptPorts[port - 1];
|
||||
if (port == null || !(port instanceof NetscriptPort)) {
|
||||
if (port == null || !(port instanceof Object)) {
|
||||
throw makeRuntimeErrorMsg("peek", `Could not find port: ${port}. This is a bug. Report to dev.`);
|
||||
}
|
||||
return port.peek();
|
||||
@ -2506,7 +2506,7 @@ function NetscriptFunctions(workerScript) {
|
||||
);
|
||||
}
|
||||
var port = NetscriptPorts[port - 1];
|
||||
if (port == null || !(port instanceof NetscriptPort)) {
|
||||
if (port == null || !(port instanceof Object)) {
|
||||
throw makeRuntimeErrorMsg("clear", `Could not find port: ${port}. This is a bug. Report to dev.`);
|
||||
}
|
||||
return port.clear();
|
||||
@ -2542,7 +2542,7 @@ function NetscriptFunctions(workerScript) {
|
||||
);
|
||||
}
|
||||
var port = NetscriptPorts[port - 1];
|
||||
if (port == null || !(port instanceof NetscriptPort)) {
|
||||
if (port == null || !(port instanceof Object)) {
|
||||
throw makeRuntimeErrorMsg("getPortHandle", `Could not find port: ${port}. This is a bug. Report to dev.`);
|
||||
}
|
||||
return port;
|
||||
|
@ -1,51 +1,55 @@
|
||||
import { Settings } from "./Settings/Settings";
|
||||
|
||||
export class NetscriptPort {
|
||||
data: any[] = [];
|
||||
interface IPort {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
write(data: any): any {
|
||||
this.data.push(data);
|
||||
if (this.data.length > Settings.MaxPortCapacity) {
|
||||
return this.data.shift();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
export function NetscriptPort(): IPort {
|
||||
const data: any[] = [];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
tryWrite(data: any): boolean {
|
||||
if (this.data.length >= Settings.MaxPortCapacity) {
|
||||
return false;
|
||||
}
|
||||
this.data.push(data);
|
||||
return true;
|
||||
}
|
||||
return {
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
write: (value: any): any => {
|
||||
data.push(value);
|
||||
if (data.length > Settings.MaxPortCapacity) {
|
||||
return data.shift();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
read(): any {
|
||||
if (this.data.length === 0) {
|
||||
return "NULL PORT DATA";
|
||||
}
|
||||
return this.data.shift();
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
tryWrite: (value: any): boolean => {
|
||||
if (data.length >= Settings.MaxPortCapacity) {
|
||||
return false;
|
||||
}
|
||||
data.push(value);
|
||||
return true;
|
||||
},
|
||||
|
||||
peek(): any {
|
||||
if (this.data.length === 0) {
|
||||
return "NULL PORT DATA";
|
||||
} else {
|
||||
const foo = this.data.slice();
|
||||
return foo[0];
|
||||
}
|
||||
}
|
||||
read: (): any => {
|
||||
if (data.length === 0) {
|
||||
return "NULL PORT DATA";
|
||||
}
|
||||
return data.shift();
|
||||
},
|
||||
|
||||
full(): boolean {
|
||||
return this.data.length == Settings.MaxPortCapacity;
|
||||
}
|
||||
peek: (): any => {
|
||||
if (data.length === 0) {
|
||||
return "NULL PORT DATA";
|
||||
} else {
|
||||
const foo = data.slice();
|
||||
return foo[0];
|
||||
}
|
||||
},
|
||||
|
||||
empty(): boolean {
|
||||
return this.data.length === 0;
|
||||
}
|
||||
full: (): boolean => {
|
||||
return data.length == Settings.MaxPortCapacity;
|
||||
},
|
||||
|
||||
clear(): void {
|
||||
this.data.length = 0;
|
||||
}
|
||||
empty: (): boolean => {
|
||||
return data.length === 0;
|
||||
},
|
||||
|
||||
clear: (): void => {
|
||||
data.length = 0;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import { simple as walksimple } from "acorn-walk";
|
||||
// Netscript Ports are instantiated here
|
||||
export const NetscriptPorts = [];
|
||||
for (var i = 0; i < CONSTANTS.NumNetscriptPorts; ++i) {
|
||||
NetscriptPorts.push(new NetscriptPort());
|
||||
NetscriptPorts.push(NetscriptPort());
|
||||
}
|
||||
|
||||
export function prestigeWorkerScripts() {
|
||||
|
Loading…
Reference in New Issue
Block a user