rename some stuff and close some exploits

This commit is contained in:
Olivier Gagnon 2021-11-12 15:42:57 -05:00
parent 7059bdf08a
commit 6bd6b3061e
19 changed files with 128 additions and 80 deletions

18
dist/bitburner.d.ts vendored

@ -1699,6 +1699,8 @@ export declare interface NodeStats {
level: number;
/** Node's RAM */
ram: number;
/** Node's used RAM */
ramUsed: number;
/** Node's number of cores */
cores: number;
/** Cache level. Only applicable for Hacknet Servers */
@ -2875,7 +2877,7 @@ export declare interface NS extends Singularity {
/**
* Write data to a file.
* @remarks
* RAM cost: 1 GB
* RAM cost: 0 GB
*
* This function can be used to either write data to a text file (.txt).
*
@ -2895,7 +2897,7 @@ export declare interface NS extends Singularity {
/**
* Attempt to write to a port.
* @remarks
* RAM cost: 1 GB
* RAM cost: 0 GB
*
* Attempts to write data to the specified Netscript Port.
* If the port is full, the data will not be written.
@ -2905,12 +2907,12 @@ export declare interface NS extends Singularity {
* @param data - Data to write.
* @returns True if the data is successfully written to the port, and false otherwise.
*/
tryWrite(port: number, data: string[] | number): Promise<boolean>;
tryWritePort(port: number, data: string[] | number): Promise<boolean>;
/**
* Read content of a file.
* @remarks
* RAM cost: 1 GB
* RAM cost: 0 GB
*
* This function is used to read data from a port or from a text file (.txt).
*
@ -2925,7 +2927,7 @@ export declare interface NS extends Singularity {
/**
* Get a copy of the data from a port without popping it.
* @remarks
* RAM cost: 1 GB
* RAM cost: 0 GB
*
* This function is used to peek at the data from a port. It returns the
* first element in the specified port without removing that element. If
@ -2966,7 +2968,7 @@ export declare interface NS extends Singularity {
* Write data to that netscript port.
* @returns The data popped off the queue if it was full.
*/
writePort(port: number, data: any): Promise<any>;
writePort(port: number, data: string | number): Promise<any>;
/**
* Read data from a port.
* @remarks
@ -3370,7 +3372,7 @@ export declare interface NS extends Singularity {
* @public
*/
export declare interface Player {
hacking_skill: number;
hacking: number;
hp: number;
max_hp: number;
strength: number;
@ -4578,7 +4580,7 @@ export declare interface SleeveSkills {
/** current sync of the sleeve [0-100] */
sync: number;
/** current hacking skill of the sleeve */
hacking_skill: number;
hacking: number;
/** current strength of the sleeve */
strength: number;
/** current defense of the sleeve */

@ -11486,6 +11486,32 @@
"endIndex": 2
}
},
{
"kind": "PropertySignature",
"canonicalReference": "bitburner!NodeStats#ramUsed:member",
"docComment": "/**\n * Node's used RAM\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "ramUsed: "
},
{
"kind": "Content",
"text": "number"
},
{
"kind": "Content",
"text": ";"
}
],
"isOptional": false,
"releaseTag": "Public",
"name": "ramUsed",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
}
},
{
"kind": "PropertySignature",
"canonicalReference": "bitburner!NodeStats#timeOnline:member",
@ -14791,7 +14817,7 @@
{
"kind": "MethodSignature",
"canonicalReference": "bitburner!NS#peek:member(1)",
"docComment": "/**\n * Get a copy of the data from a port without popping it.\n *\n * @remarks\n *\n * RAM cost: 1 GB\n *\n * This function is used to peek at the data from a port. It returns the first element in the specified port without removing that element. If the port is empty, the string “NULL PORT DATA” will be returned.\n *\n * @param port - Port to peek. Must be an integer between 1 and 20.\n *\n * @returns Data in the specified port.\n */\n",
"docComment": "/**\n * Get a copy of the data from a port without popping it.\n *\n * @remarks\n *\n * RAM cost: 0 GB\n *\n * This function is used to peek at the data from a port. It returns the first element in the specified port without removing that element. If the port is empty, the string “NULL PORT DATA” will be returned.\n *\n * @param port - Port to peek. Must be an integer between 1 and 20.\n *\n * @returns Data in the specified port.\n */\n",
"excerptTokens": [
{
"kind": "Content",
@ -15036,7 +15062,7 @@
{
"kind": "MethodSignature",
"canonicalReference": "bitburner!NS#read:member(1)",
"docComment": "/**\n * Read content of a file.\n *\n * @remarks\n *\n * RAM cost: 1 GB\n *\n * This function is used to read data from a port or from a text file (.txt).\n *\n * This function will return the data in the specified text file. If the text file does not exist, an empty string will be returned.\n *\n * @param handle - Port or text file to read from.\n *\n * @returns Data in the specified text file or port.\n */\n",
"docComment": "/**\n * Read content of a file.\n *\n * @remarks\n *\n * RAM cost: 0 GB\n *\n * This function is used to read data from a port or from a text file (.txt).\n *\n * This function will return the data in the specified text file. If the text file does not exist, an empty string will be returned.\n *\n * @param handle - Port or text file to read from.\n *\n * @returns Data in the specified text file or port.\n */\n",
"excerptTokens": [
{
"kind": "Content",
@ -16160,12 +16186,12 @@
},
{
"kind": "MethodSignature",
"canonicalReference": "bitburner!NS#tryWrite:member(1)",
"docComment": "/**\n * Attempt to write to a port.\n *\n * @remarks\n *\n * RAM cost: 1 GB\n *\n * Attempts to write data to the specified Netscript Port. If the port is full, the data will not be written. Otherwise, the data will be written normally.\n *\n * @param port - Port or text file that will be written to.\n *\n * @param data - Data to write.\n *\n * @returns True if the data is successfully written to the port, and false otherwise.\n */\n",
"canonicalReference": "bitburner!NS#tryWritePort:member(1)",
"docComment": "/**\n * Attempt to write to a port.\n *\n * @remarks\n *\n * RAM cost: 0 GB\n *\n * Attempts to write data to the specified Netscript Port. If the port is full, the data will not be written. Otherwise, the data will be written normally.\n *\n * @param port - Port or text file that will be written to.\n *\n * @param data - Data to write.\n *\n * @returns True if the data is successfully written to the port, and false otherwise.\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "tryWrite(port: "
"text": "tryWritePort(port: "
},
{
"kind": "Content",
@ -16220,7 +16246,7 @@
}
}
],
"name": "tryWrite"
"name": "tryWritePort"
},
{
"kind": "MethodSignature",
@ -16487,7 +16513,7 @@
{
"kind": "MethodSignature",
"canonicalReference": "bitburner!NS#write:member(1)",
"docComment": "/**\n * Write data to a file.\n *\n * @remarks\n *\n * RAM cost: 1 GB\n *\n * This function can be used to either write data to a text file (.txt).\n *\n * This function will write data to that text file. If the specified text file does not exist, then it will be created. The third argument mode, defines how the data will be written to the text file. If *mode is set to “w”, then the data is written in “write” mode which means that it will overwrite all existing data on the text file. If mode is set to any other value then the data will be written in “append” mode which means that the data will be added at the end of the text file.\n *\n * @param handle - Port or text file that will be written to.\n *\n * @param data - Data to write.\n *\n * @param mode - Defines the write mode. Only valid when writing to text files.\n */\n",
"docComment": "/**\n * Write data to a file.\n *\n * @remarks\n *\n * RAM cost: 0 GB\n *\n * This function can be used to either write data to a text file (.txt).\n *\n * This function will write data to that text file. If the specified text file does not exist, then it will be created. The third argument mode, defines how the data will be written to the text file. If *mode is set to “w”, then the data is written in “write” mode which means that it will overwrite all existing data on the text file. If mode is set to any other value then the data will be written in “append” mode which means that the data will be added at the end of the text file.\n *\n * @param handle - Port or text file that will be written to.\n *\n * @param data - Data to write.\n *\n * @param mode - Defines the write mode. Only valid when writing to text files.\n */\n",
"excerptTokens": [
{
"kind": "Content",
@ -16582,7 +16608,7 @@
},
{
"kind": "Content",
"text": "any"
"text": "string | number"
},
{
"kind": "Content",
@ -17688,32 +17714,6 @@
"endIndex": 2
}
},
{
"kind": "PropertySignature",
"canonicalReference": "bitburner!Player#hacking_skill:member",
"docComment": "",
"excerptTokens": [
{
"kind": "Content",
"text": "hacking_skill: "
},
{
"kind": "Content",
"text": "number"
},
{
"kind": "Content",
"text": ";"
}
],
"isOptional": false,
"releaseTag": "Public",
"name": "hacking_skill",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
}
},
{
"kind": "PropertySignature",
"canonicalReference": "bitburner!Player#hacking_speed_mult:member",
@ -17740,6 +17740,32 @@
"endIndex": 2
}
},
{
"kind": "PropertySignature",
"canonicalReference": "bitburner!Player#hacking:member",
"docComment": "",
"excerptTokens": [
{
"kind": "Content",
"text": "hacking: "
},
{
"kind": "Content",
"text": "number"
},
{
"kind": "Content",
"text": ";"
}
],
"isOptional": false,
"releaseTag": "Public",
"name": "hacking",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
}
},
{
"kind": "PropertySignature",
"canonicalReference": "bitburner!Player#hacknet_node_core_cost_mult:member",
@ -23199,12 +23225,12 @@
},
{
"kind": "PropertySignature",
"canonicalReference": "bitburner!SleeveSkills#hacking_skill:member",
"canonicalReference": "bitburner!SleeveSkills#hacking:member",
"docComment": "/**\n * current hacking skill of the sleeve\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "hacking_skill: "
"text": "hacking: "
},
{
"kind": "Content",
@ -23217,7 +23243,7 @@
],
"isOptional": false,
"releaseTag": "Public",
"name": "hacking_skill",
"name": "hacking",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 2

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -23,6 +23,7 @@ export interface NodeStats
| [name](./bitburner.nodestats.name.md) | string | Node's name |
| [production](./bitburner.nodestats.production.md) | number | Node's production per second |
| [ram](./bitburner.nodestats.ram.md) | number | Node's RAM |
| [ramUsed](./bitburner.nodestats.ramused.md) | number | Node's used RAM |
| [timeOnline](./bitburner.nodestats.timeonline.md) | number | Number of seconds since Node has been purchased |
| [totalProduction](./bitburner.nodestats.totalproduction.md) | number | Total number of money Node has produced |

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NodeStats](./bitburner.nodestats.md) &gt; [ramUsed](./bitburner.nodestats.ramused.md)
## NodeStats.ramUsed property
Node's used RAM
<b>Signature:</b>
```typescript
ramUsed: number;
```

@ -120,7 +120,7 @@ export interface NS extends Singularity
| [toast(msg, variant)](./bitburner.ns.toast.md) | Queue a toast (bottom-right notification). |
| [tprint(msg)](./bitburner.ns.tprint.md) | Prints a value or a variable to the Terminal. |
| [tprintf(msg)](./bitburner.ns.tprintf.md) | Prints a raw value or a variable to the Terminal. |
| [tryWrite(port, data)](./bitburner.ns.trywrite.md) | Attempt to write to a port. |
| [tryWritePort(port, data)](./bitburner.ns.trywriteport.md) | Attempt to write to a port. |
| [vsprintf(format, args)](./bitburner.ns.vsprintf.md) | Format a string with an array of arguments. |
| [weaken(host, opts)](./bitburner.ns.weaken.md) | Reduce a server security level. |
| [weakenAnalyze(threads, cores)](./bitburner.ns.weakenanalyze.md) | Predict the effect of weaken. |

@ -26,7 +26,7 @@ Data in the specified port.
## Remarks
RAM cost: 1 GB
RAM cost: 0 GB
This function is used to peek at the data from a port. It returns the first element in the specified port without removing that element. If the port is empty, the string “NULL PORT DATA” will be returned.

@ -26,7 +26,7 @@ Data in the specified text file or port.
## Remarks
RAM cost: 1 GB
RAM cost: 0 GB
This function is used to read data from a port or from a text file (.txt).

@ -1,15 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [tryWrite](./bitburner.ns.trywrite.md)
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [tryWritePort](./bitburner.ns.trywriteport.md)
## NS.tryWrite() method
## NS.tryWritePort() method
Attempt to write to a port.
<b>Signature:</b>
```typescript
tryWrite(port: number, data: string[] | number): Promise<boolean>;
tryWritePort(port: number, data: string[] | number): Promise<boolean>;
```
## Parameters
@ -27,7 +27,7 @@ True if the data is successfully written to the port, and false otherwise.
## Remarks
RAM cost: 1 GB
RAM cost: 0 GB
Attempts to write data to the specified Netscript Port. If the port is full, the data will not be written. Otherwise, the data will be written normally.

@ -26,7 +26,7 @@ Promise&lt;void&gt;
## Remarks
RAM cost: 1 GB
RAM cost: 0 GB
This function can be used to either write data to a text file (.txt).

@ -9,7 +9,7 @@ Write data to a port.
<b>Signature:</b>
```typescript
writePort(port: number, data: any): Promise<any>;
writePort(port: number, data: string | number): Promise<any>;
```
## Parameters
@ -17,7 +17,7 @@ writePort(port: number, data: any): Promise<any>;
| Parameter | Type | Description |
| --- | --- | --- |
| port | number | |
| data | any | |
| data | string \| number | |
<b>Returns:</b>

@ -1,11 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Player](./bitburner.player.md) &gt; [hacking\_skill](./bitburner.player.hacking_skill.md)
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Player](./bitburner.player.md) &gt; [hacking](./bitburner.player.hacking.md)
## Player.hacking\_skill property
## Player.hacking property
<b>Signature:</b>
```typescript
hacking_skill: number;
hacking: number;
```

@ -55,8 +55,8 @@ interface Player
| [hacking\_grow\_mult](./bitburner.player.hacking_grow_mult.md) | number | |
| [hacking\_money\_mult](./bitburner.player.hacking_money_mult.md) | number | |
| [hacking\_mult](./bitburner.player.hacking_mult.md) | number | |
| [hacking\_skill](./bitburner.player.hacking_skill.md) | number | |
| [hacking\_speed\_mult](./bitburner.player.hacking_speed_mult.md) | number | |
| [hacking](./bitburner.player.hacking.md) | number | |
| [hacknet\_node\_core\_cost\_mult](./bitburner.player.hacknet_node_core_cost_mult.md) | number | |
| [hacknet\_node\_level\_cost\_mult](./bitburner.player.hacknet_node_level_cost_mult.md) | number | |
| [hacknet\_node\_money\_mult](./bitburner.player.hacknet_node_money_mult.md) | number | |

@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [SleeveSkills](./bitburner.sleeveskills.md) &gt; [hacking\_skill](./bitburner.sleeveskills.hacking_skill.md)
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [SleeveSkills](./bitburner.sleeveskills.md) &gt; [hacking](./bitburner.sleeveskills.hacking.md)
## SleeveSkills.hacking\_skill property
## SleeveSkills.hacking property
current hacking skill of the sleeve
<b>Signature:</b>
```typescript
hacking_skill: number;
hacking: number;
```

@ -20,7 +20,7 @@ export interface SleeveSkills
| [charisma](./bitburner.sleeveskills.charisma.md) | number | current charisma of the sleeve |
| [defense](./bitburner.sleeveskills.defense.md) | number | current defense of the sleeve |
| [dexterity](./bitburner.sleeveskills.dexterity.md) | number | current dexterity of the sleeve |
| [hacking\_skill](./bitburner.sleeveskills.hacking_skill.md) | number | current hacking skill of the sleeve |
| [hacking](./bitburner.sleeveskills.hacking.md) | number | current hacking skill of the sleeve |
| [shock](./bitburner.sleeveskills.shock.md) | number | current shock of the sleeve \[0-100\] |
| [strength](./bitburner.sleeveskills.strength.md) | number | current strength of the sleeve |
| [sync](./bitburner.sleeveskills.sync.md) | number | current sync of the sleeve \[0-100\] |

@ -161,7 +161,7 @@ export const RamCosts: IMap<any> = {
deleteServer: RamCostConstants.ScriptPurchaseServerRamCost,
getPurchasedServers: RamCostConstants.ScriptPurchaseServerRamCost,
write: 0,
tryWrite: 0,
tryWritePort: 0,
read: 0,
peek: 0,
clear: 0,

@ -63,7 +63,7 @@ import { NetscriptGang } from "./NetscriptFunctions/Gang";
import { NetscriptSleeve } from "./NetscriptFunctions/Sleeve";
import { NetscriptExtra } from "./NetscriptFunctions/Extra";
import { NetscriptHacknet } from "./NetscriptFunctions/Hacknet";
import { NS as INS } from "./ScriptEditor/NetscriptDefinitions";
import { NS as INS, Player as INetscriptPlayer } from "./ScriptEditor/NetscriptDefinitions";
import { NetscriptBladeburner } from "./NetscriptFunctions/Bladeburner";
import { NetscriptCodingContract } from "./NetscriptFunctions/CodingContract";
import { NetscriptCorporation } from "./NetscriptFunctions/Corporation";
@ -1635,6 +1635,12 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
writePort: function (port: any, data: any = ""): any {
// Write to port
// Port 1-10
if (typeof data !== "string" && typeof data !== "number") {
throw makeRuntimeErrorMsg(
"writePort",
`Trying to write invalid data to a port: only strings and numbers are valid.`,
);
}
port = Math.round(port);
if (port < 1 || port > CONSTANTS.NumNetscriptPorts) {
throw makeRuntimeErrorMsg(
@ -1701,23 +1707,23 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
throw makeRuntimeErrorMsg("write", `Invalid argument: ${port}`);
}
},
tryWrite: function (port: any, data: any = ""): any {
updateDynamicRam("tryWrite", getRamCost("tryWrite"));
tryWritePort: function (port: any, data: any = ""): any {
updateDynamicRam("tryWritePort", getRamCost("tryWritePort"));
if (!isNaN(port)) {
port = Math.round(port);
if (port < 1 || port > CONSTANTS.NumNetscriptPorts) {
throw makeRuntimeErrorMsg(
"tryWrite",
"tryWritePort",
`Invalid port: ${port}. Only ports 1-${CONSTANTS.NumNetscriptPorts} are valid.`,
);
}
const iport = NetscriptPorts[port - 1];
if (iport == null || !(iport instanceof Object)) {
throw makeRuntimeErrorMsg("tryWrite", `Could not find port: ${port}. This is a bug. Report to dev.`);
throw makeRuntimeErrorMsg("tryWritePort", `Could not find port: ${port}. This is a bug. Report to dev.`);
}
return Promise.resolve(iport.tryWrite(data));
} else {
throw makeRuntimeErrorMsg("tryWrite", `Invalid argument: ${port}`);
throw makeRuntimeErrorMsg("tryWritePort", `Invalid argument: ${port}`);
}
},
readPort: function (port: any): any {
@ -2088,7 +2094,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
return Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction);
},
getPlayer: function (): any {
getPlayer: function (): INetscriptPlayer {
helper.updateDynamicRam("getPlayer", getRamCost("getPlayer"));
const data = {

@ -4522,7 +4522,7 @@ export interface NS extends Singularity {
/**
* Write data to a file.
* @remarks
* RAM cost: 1 GB
* RAM cost: 0 GB
*
* This function can be used to either write data to a text file (.txt).
*
@ -4542,7 +4542,7 @@ export interface NS extends Singularity {
/**
* Attempt to write to a port.
* @remarks
* RAM cost: 1 GB
* RAM cost: 0 GB
*
* Attempts to write data to the specified Netscript Port.
* If the port is full, the data will not be written.
@ -4552,12 +4552,12 @@ export interface NS extends Singularity {
* @param data - Data to write.
* @returns True if the data is successfully written to the port, and false otherwise.
*/
tryWrite(port: number, data: string[] | number): Promise<boolean>;
tryWritePort(port: number, data: string[] | number): Promise<boolean>;
/**
* Read content of a file.
* @remarks
* RAM cost: 1 GB
* RAM cost: 0 GB
*
* This function is used to read data from a port or from a text file (.txt).
*
@ -4572,7 +4572,7 @@ export interface NS extends Singularity {
/**
* Get a copy of the data from a port without popping it.
* @remarks
* RAM cost: 1 GB
* RAM cost: 0 GB
*
* This function is used to peek at the data from a port. It returns the
* first element in the specified port without removing that element. If
@ -4613,7 +4613,7 @@ export interface NS extends Singularity {
* Write data to that netscript port.
* @returns The data popped off the queue if it was full.
*/
writePort(port: number, data: any): Promise<any>;
writePort(port: number, data: string | number): Promise<any>;
/**
* Read data from a port.
* @remarks