mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-14 03:33:52 +01:00
Merge pull request #1433 from danielyxie/dev
Convert everything to hostname as primary
This commit is contained in:
commit
06b706beca
36
dist/vendor.bundle.js
vendored
36
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -6,11 +6,10 @@ import {
|
|||||||
} from "./CodingContracts";
|
} from "./CodingContracts";
|
||||||
import { Factions } from "./Faction/Factions";
|
import { Factions } from "./Faction/Factions";
|
||||||
import { Player } from "./Player";
|
import { Player } from "./Player";
|
||||||
import { AllServers } from "./Server/AllServers";
|
import { GetServer, GetAllServers } from "./Server/AllServers";
|
||||||
import { GetServerByHostname } from "./Server/ServerHelpers";
|
import { SpecialServers } from "./Server/data/SpecialServers";
|
||||||
import { SpecialServerNames } from "./Server/SpecialServerIps";
|
|
||||||
import { Server } from "./Server/Server";
|
import { Server } from "./Server/Server";
|
||||||
import { HacknetServer } from "./Hacknet/HacknetServer";
|
import { BaseServer } from "./Server/BaseServer";
|
||||||
|
|
||||||
import { getRandomInt } from "./utils/helpers/getRandomInt";
|
import { getRandomInt } from "./utils/helpers/getRandomInt";
|
||||||
|
|
||||||
@ -68,10 +67,7 @@ export function generateContract(params: IGenerateContractParams): void {
|
|||||||
// Server
|
// Server
|
||||||
let server;
|
let server;
|
||||||
if (params.server != null) {
|
if (params.server != null) {
|
||||||
server = GetServerByHostname(params.server);
|
server = GetServer(params.server);
|
||||||
if (server == null) {
|
|
||||||
server = AllServers[params.server];
|
|
||||||
}
|
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
server = getRandomServer();
|
server = getRandomServer();
|
||||||
}
|
}
|
||||||
@ -165,10 +161,10 @@ function getRandomReward(): ICodingContractReward {
|
|||||||
return reward;
|
return reward;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomServer(): Server | HacknetServer {
|
function getRandomServer(): BaseServer {
|
||||||
const servers = Object.keys(AllServers);
|
const servers = GetAllServers();
|
||||||
let randIndex = getRandomInt(0, servers.length - 1);
|
let randIndex = getRandomInt(0, servers.length - 1);
|
||||||
let randServer = AllServers[servers[randIndex]];
|
let randServer = servers[randIndex];
|
||||||
|
|
||||||
// An infinite loop shouldn't ever happen, but to be safe we'll use
|
// An infinite loop shouldn't ever happen, but to be safe we'll use
|
||||||
// a for loop with a limited number of tries
|
// a for loop with a limited number of tries
|
||||||
@ -176,18 +172,18 @@ function getRandomServer(): Server | HacknetServer {
|
|||||||
if (
|
if (
|
||||||
randServer instanceof Server &&
|
randServer instanceof Server &&
|
||||||
!randServer.purchasedByPlayer &&
|
!randServer.purchasedByPlayer &&
|
||||||
randServer.hostname !== SpecialServerNames.WorldDaemon
|
randServer.hostname !== SpecialServers.WorldDaemon
|
||||||
) {
|
) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
randIndex = getRandomInt(0, servers.length - 1);
|
randIndex = getRandomInt(0, servers.length - 1);
|
||||||
randServer = AllServers[servers[randIndex]];
|
randServer = servers[randIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
return randServer;
|
return randServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomFilename(server: Server | HacknetServer, reward: ICodingContractReward): string {
|
function getRandomFilename(server: BaseServer, reward: ICodingContractReward): string {
|
||||||
let contractFn = `contract-${getRandomInt(0, 1e6)}`;
|
let contractFn = `contract-${getRandomInt(0, 1e6)}`;
|
||||||
|
|
||||||
for (let i = 0; i < 1000; ++i) {
|
for (let i = 0; i < 1000; ++i) {
|
||||||
|
@ -2,26 +2,18 @@ import { DarkWebItems } from "./DarkWebItems";
|
|||||||
|
|
||||||
import { Player } from "../Player";
|
import { Player } from "../Player";
|
||||||
import { Terminal } from "../Terminal";
|
import { Terminal } from "../Terminal";
|
||||||
import { SpecialServerIps } from "../Server/SpecialServerIps";
|
import { SpecialServers } from "../Server/data/SpecialServers";
|
||||||
import { numeralWrapper } from "../ui/numeralFormat";
|
import { numeralWrapper } from "../ui/numeralFormat";
|
||||||
|
|
||||||
import { isValidIPAddress } from "../utils/helpers/isValidIPAddress";
|
|
||||||
|
|
||||||
//Posts a "help" message if connected to DarkWeb
|
//Posts a "help" message if connected to DarkWeb
|
||||||
export function checkIfConnectedToDarkweb(): void {
|
export function checkIfConnectedToDarkweb(): void {
|
||||||
if (SpecialServerIps.hasOwnProperty("Darkweb Server")) {
|
const server = Player.getCurrentServer();
|
||||||
const darkwebIp = SpecialServerIps.getIp("Darkweb Server");
|
if (server !== null && SpecialServers.DarkWeb == server.hostname) {
|
||||||
if (!isValidIPAddress(darkwebIp)) {
|
Terminal.print(
|
||||||
return;
|
"You are now connected to the dark web. From the dark web you can purchase illegal items. " +
|
||||||
}
|
"Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " +
|
||||||
const server = Player.getCurrentServer();
|
"to purchase an item.",
|
||||||
if (server !== null && darkwebIp == server.ip) {
|
);
|
||||||
Terminal.print(
|
|
||||||
"You are now connected to the dark web. From the dark web you can purchase illegal items. " +
|
|
||||||
"Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " +
|
|
||||||
"to purchase an item.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,8 @@ import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Select, { SelectChangeEvent } from "@mui/material/Select";
|
import Select, { SelectChangeEvent } from "@mui/material/Select";
|
||||||
import { AllServers } from "../../Server/AllServers";
|
import { GetServer, GetAllServers } from "../../Server/AllServers";
|
||||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
import { Server } from "../../Server/Server";
|
||||||
import { GetServerByHostname } from "../../Server/ServerHelpers";
|
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
|
|
||||||
export function Servers(): React.ReactElement {
|
export function Servers(): React.ReactElement {
|
||||||
@ -19,9 +18,9 @@ export function Servers(): React.ReactElement {
|
|||||||
setServer(event.target.value as string);
|
setServer(event.target.value as string);
|
||||||
}
|
}
|
||||||
function rootServer(): void {
|
function rootServer(): void {
|
||||||
const s = GetServerByHostname(server);
|
const s = GetServer(server);
|
||||||
if (s === null) return;
|
if (s === null) return;
|
||||||
if (s instanceof HacknetServer) return;
|
if (!(s instanceof Server)) return;
|
||||||
s.hasAdminRights = true;
|
s.hasAdminRights = true;
|
||||||
s.sshPortOpen = true;
|
s.sshPortOpen = true;
|
||||||
s.ftpPortOpen = true;
|
s.ftpPortOpen = true;
|
||||||
@ -32,9 +31,8 @@ export function Servers(): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function rootAllServers(): void {
|
function rootAllServers(): void {
|
||||||
for (const i in AllServers) {
|
for (const s of GetAllServers()) {
|
||||||
const s = AllServers[i];
|
if (!(s instanceof Server)) return;
|
||||||
if (s instanceof HacknetServer) return;
|
|
||||||
s.hasAdminRights = true;
|
s.hasAdminRights = true;
|
||||||
s.sshPortOpen = true;
|
s.sshPortOpen = true;
|
||||||
s.ftpPortOpen = true;
|
s.ftpPortOpen = true;
|
||||||
@ -46,32 +44,30 @@ export function Servers(): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function minSecurity(): void {
|
function minSecurity(): void {
|
||||||
const s = GetServerByHostname(server);
|
const s = GetServer(server);
|
||||||
if (s === null) return;
|
if (s === null) return;
|
||||||
if (s instanceof HacknetServer) return;
|
if (!(s instanceof Server)) return;
|
||||||
s.hackDifficulty = s.minDifficulty;
|
s.hackDifficulty = s.minDifficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
function minAllSecurity(): void {
|
function minAllSecurity(): void {
|
||||||
for (const i in AllServers) {
|
for (const s of GetAllServers()) {
|
||||||
const server = AllServers[i];
|
if (!(s instanceof Server)) return;
|
||||||
if (server instanceof HacknetServer) continue;
|
s.hackDifficulty = s.minDifficulty;
|
||||||
server.hackDifficulty = server.minDifficulty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function maxMoney(): void {
|
function maxMoney(): void {
|
||||||
const s = GetServerByHostname(server);
|
const s = GetServer(server);
|
||||||
if (s === null) return;
|
if (s === null) return;
|
||||||
if (s instanceof HacknetServer) return;
|
if (!(s instanceof Server)) return;
|
||||||
s.moneyAvailable = s.moneyMax;
|
s.moneyAvailable = s.moneyMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
function maxAllMoney(): void {
|
function maxAllMoney(): void {
|
||||||
for (const i in AllServers) {
|
for (const s of GetAllServers()) {
|
||||||
const server = AllServers[i];
|
if (!(s instanceof Server)) return;
|
||||||
if (server instanceof HacknetServer) continue;
|
s.moneyAvailable = s.moneyMax;
|
||||||
server.moneyAvailable = server.moneyMax;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +85,7 @@ export function Servers(): React.ReactElement {
|
|||||||
</td>
|
</td>
|
||||||
<td colSpan={2}>
|
<td colSpan={2}>
|
||||||
<Select id="dev-servers-dropdown" onChange={setServerDropdown} value={server}>
|
<Select id="dev-servers-dropdown" onChange={setServerDropdown} value={server}>
|
||||||
{Object.values(AllServers).map((server) => (
|
{GetAllServers().map((server) => (
|
||||||
<MenuItem key={server.hostname} value={server.hostname}>
|
<MenuItem key={server.hostname} value={server.hostname}>
|
||||||
{server.hostname}
|
{server.hostname}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { AllServers } from "../Server/AllServers";
|
import { GetServer, GetAllServers } from "../Server/AllServers";
|
||||||
import { Modal } from "../ui/React/Modal";
|
import { Modal } from "../ui/React/Modal";
|
||||||
import { numeralWrapper } from "../ui/numeralFormat";
|
import { numeralWrapper } from "../ui/numeralFormat";
|
||||||
|
|
||||||
@ -17,11 +17,12 @@ import AccordionDetails from "@mui/material/AccordionDetails";
|
|||||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||||
|
|
||||||
interface IServerProps {
|
interface IServerProps {
|
||||||
ip: string;
|
hostname: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ServerAccordion(props: IServerProps): React.ReactElement {
|
function ServerAccordion(props: IServerProps): React.ReactElement {
|
||||||
const server = AllServers[props.ip];
|
const server = GetServer(props.hostname);
|
||||||
|
if (server === null) throw new Error("server should not be null");
|
||||||
let totalSize = 0;
|
let totalSize = 0;
|
||||||
for (const f of server.scripts) {
|
for (const f of server.scripts) {
|
||||||
totalSize += f.code.length;
|
totalSize += f.code.length;
|
||||||
@ -98,9 +99,9 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function FileDiagnosticModal(props: IProps): React.ReactElement {
|
export function FileDiagnosticModal(props: IProps): React.ReactElement {
|
||||||
const ips: string[] = [];
|
const keys: string[] = [];
|
||||||
for (const ip of Object.keys(AllServers)) {
|
for (const key in GetAllServers()) {
|
||||||
ips.push(ip);
|
keys.push(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -110,8 +111,8 @@ export function FileDiagnosticModal(props: IProps): React.ReactElement {
|
|||||||
Welcome to the file diagnostic! If your save file is really big it's likely because you have too many
|
Welcome to the file diagnostic! If your save file is really big it's likely because you have too many
|
||||||
text/scripts. This tool can help you narrow down where they are.
|
text/scripts. This tool can help you narrow down where they are.
|
||||||
</Typography>
|
</Typography>
|
||||||
{ips.map((ip: string) => (
|
{keys.map((hostname: string) => (
|
||||||
<ServerAccordion key={ip} ip={ip} />
|
<ServerAccordion key={hostname} hostname={hostname} />
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
@ -19,8 +19,7 @@ import { HashUpgrades } from "./HashUpgrades";
|
|||||||
import { generateRandomContract } from "../CodingContractGenerator";
|
import { generateRandomContract } from "../CodingContractGenerator";
|
||||||
import { iTutorialSteps, iTutorialNextStep, ITutorial } from "../InteractiveTutorial";
|
import { iTutorialSteps, iTutorialNextStep, ITutorial } from "../InteractiveTutorial";
|
||||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
import { AllServers } from "../Server/AllServers";
|
import { GetServer } from "../Server/AllServers";
|
||||||
import { GetServerByHostname } from "../Server/ServerHelpers";
|
|
||||||
import { Server } from "../Server/Server";
|
import { Server } from "../Server/Server";
|
||||||
import { SourceFileFlags } from "../SourceFile/SourceFileFlags";
|
import { SourceFileFlags } from "../SourceFile/SourceFileFlags";
|
||||||
|
|
||||||
@ -416,8 +415,8 @@ function processAllHacknetServerEarnings(player: IPlayer, numCycles: number): nu
|
|||||||
// Also, update the hash rate before processing
|
// Also, update the hash rate before processing
|
||||||
const ip = player.hacknetNodes[i];
|
const ip = player.hacknetNodes[i];
|
||||||
if (ip instanceof HacknetNode) throw new Error(`player nodes should not be HacketNode`);
|
if (ip instanceof HacknetNode) throw new Error(`player nodes should not be HacketNode`);
|
||||||
const hserver = AllServers[ip];
|
const hserver = GetServer(ip);
|
||||||
if (hserver instanceof Server) throw new Error(`player nodes shoud not be Server`);
|
if (!(hserver instanceof HacknetServer)) throw new Error(`player nodes shoud not be Server`);
|
||||||
hserver.updateHashRate(player.hacknet_node_money_mult);
|
hserver.updateHashRate(player.hacknet_node_money_mult);
|
||||||
const h = hserver.process(numCycles);
|
const h = hserver.process(numCycles);
|
||||||
hashes += h;
|
hashes += h;
|
||||||
@ -448,7 +447,7 @@ export function updateHashManagerCapacity(player: IPlayer): void {
|
|||||||
}
|
}
|
||||||
const ip = nodes[i];
|
const ip = nodes[i];
|
||||||
if (ip instanceof HacknetNode) throw new Error(`player nodes should be string but isn't`);
|
if (ip instanceof HacknetNode) throw new Error(`player nodes should be string but isn't`);
|
||||||
const h = AllServers[ip];
|
const h = GetServer(ip);
|
||||||
if (!(h instanceof HacknetServer)) {
|
if (!(h instanceof HacknetServer)) {
|
||||||
player.hashManager.updateCapacity(0);
|
player.hashManager.updateCapacity(0);
|
||||||
return;
|
return;
|
||||||
@ -488,7 +487,7 @@ export function purchaseHashUpgrade(player: IPlayer, upgName: string, upgTarget:
|
|||||||
}
|
}
|
||||||
case "Reduce Minimum Security": {
|
case "Reduce Minimum Security": {
|
||||||
try {
|
try {
|
||||||
const target = GetServerByHostname(upgTarget);
|
const target = GetServer(upgTarget);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
console.error(`Invalid target specified in purchaseHashUpgrade(): ${upgTarget}`);
|
console.error(`Invalid target specified in purchaseHashUpgrade(): ${upgTarget}`);
|
||||||
return false;
|
return false;
|
||||||
@ -504,7 +503,7 @@ export function purchaseHashUpgrade(player: IPlayer, upgName: string, upgTarget:
|
|||||||
}
|
}
|
||||||
case "Increase Maximum Money": {
|
case "Increase Maximum Money": {
|
||||||
try {
|
try {
|
||||||
const target = GetServerByHostname(upgTarget);
|
const target = GetServer(upgTarget);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
console.error(`Invalid target specified in purchaseHashUpgrade(): ${upgTarget}`);
|
console.error(`Invalid target specified in purchaseHashUpgrade(): ${upgTarget}`);
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,6 +7,7 @@ import { GeneralInfo } from "./GeneralInfo";
|
|||||||
import { HacknetNodeElem } from "./HacknetNodeElem";
|
import { HacknetNodeElem } from "./HacknetNodeElem";
|
||||||
import { HacknetServerElem } from "./HacknetServerElem";
|
import { HacknetServerElem } from "./HacknetServerElem";
|
||||||
import { HacknetNode } from "../HacknetNode";
|
import { HacknetNode } from "../HacknetNode";
|
||||||
|
import { HacknetServer } from "../HacknetServer";
|
||||||
import { HashUpgradeModal } from "./HashUpgradeModal";
|
import { HashUpgradeModal } from "./HashUpgradeModal";
|
||||||
import { MultiplierButtons } from "./MultiplierButtons";
|
import { MultiplierButtons } from "./MultiplierButtons";
|
||||||
import { PlayerInfo } from "./PlayerInfo";
|
import { PlayerInfo } from "./PlayerInfo";
|
||||||
@ -21,8 +22,7 @@ import {
|
|||||||
} from "../HacknetHelpers";
|
} from "../HacknetHelpers";
|
||||||
|
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { AllServers } from "../../Server/AllServers";
|
import { GetServer } from "../../Server/AllServers";
|
||||||
import { Server } from "../../Server/Server";
|
|
||||||
|
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import Grid from "@mui/material/Grid";
|
import Grid from "@mui/material/Grid";
|
||||||
@ -50,8 +50,8 @@ export function HacknetRoot(props: IProps): React.ReactElement {
|
|||||||
const node = props.player.hacknetNodes[i];
|
const node = props.player.hacknetNodes[i];
|
||||||
if (hasHacknetServers(props.player)) {
|
if (hasHacknetServers(props.player)) {
|
||||||
if (node instanceof HacknetNode) throw new Error("node was hacknet node"); // should never happen
|
if (node instanceof HacknetNode) throw new Error("node was hacknet node"); // should never happen
|
||||||
const hserver = AllServers[node];
|
const hserver = GetServer(node);
|
||||||
if (hserver instanceof Server) throw new Error("node was a normal server"); // should never happen
|
if (!(hserver instanceof HacknetServer)) throw new Error("node was not hacknet server"); // should never happen
|
||||||
if (hserver) {
|
if (hserver) {
|
||||||
totalProduction += hserver.hashRate;
|
totalProduction += hserver.hashRate;
|
||||||
} else {
|
} else {
|
||||||
@ -88,11 +88,11 @@ export function HacknetRoot(props: IProps): React.ReactElement {
|
|||||||
const nodes = props.player.hacknetNodes.map((node: string | HacknetNode) => {
|
const nodes = props.player.hacknetNodes.map((node: string | HacknetNode) => {
|
||||||
if (hasHacknetServers(props.player)) {
|
if (hasHacknetServers(props.player)) {
|
||||||
if (node instanceof HacknetNode) throw new Error("node was hacknet node"); // should never happen
|
if (node instanceof HacknetNode) throw new Error("node was hacknet node"); // should never happen
|
||||||
const hserver = AllServers[node];
|
const hserver = GetServer(node);
|
||||||
if (hserver == null) {
|
if (hserver == null) {
|
||||||
throw new Error(`Could not find Hacknet Server object in AllServers map for IP: ${node}`);
|
throw new Error(`Could not find Hacknet Server object in AllServers map for IP: ${node}`);
|
||||||
}
|
}
|
||||||
if (hserver instanceof Server) throw new Error("node was normal server"); // should never happen
|
if (!(hserver instanceof HacknetServer)) throw new Error("node was not hacknet server"); // should never happen
|
||||||
return (
|
return (
|
||||||
<HacknetServerElem
|
<HacknetServerElem
|
||||||
player={props.player}
|
player={props.player}
|
||||||
|
@ -7,7 +7,6 @@ import { CONSTANTS } from "../Constants";
|
|||||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
import { AddToAllServers, createUniqueRandomIp } from "../Server/AllServers";
|
import { AddToAllServers, createUniqueRandomIp } from "../Server/AllServers";
|
||||||
import { safetlyCreateUniqueServer } from "../Server/ServerHelpers";
|
import { safetlyCreateUniqueServer } from "../Server/ServerHelpers";
|
||||||
import { SpecialServerIps } from "../Server/SpecialServerIps";
|
|
||||||
|
|
||||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||||
|
|
||||||
@ -36,10 +35,9 @@ export function purchaseTorRouter(p: IPlayer): void {
|
|||||||
maxRam: 1,
|
maxRam: 1,
|
||||||
});
|
});
|
||||||
AddToAllServers(darkweb);
|
AddToAllServers(darkweb);
|
||||||
SpecialServerIps.addIp("Darkweb Server", darkweb.ip);
|
|
||||||
|
|
||||||
p.getHomeComputer().serversOnNetwork.push(darkweb.ip);
|
p.getHomeComputer().serversOnNetwork.push(darkweb.hostname);
|
||||||
darkweb.serversOnNetwork.push(p.getHomeComputer().ip);
|
darkweb.serversOnNetwork.push(p.getHomeComputer().hostname);
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
"You have purchased a TOR router!<br>" +
|
"You have purchased a TOR router!<br>" +
|
||||||
"You now have access to the dark web from your home computer.<br>" +
|
"You now have access to the dark web from your home computer.<br>" +
|
||||||
|
@ -23,8 +23,8 @@ import { LocationType } from "../LocationTypeEnum";
|
|||||||
|
|
||||||
import { Settings } from "../../Settings/Settings";
|
import { Settings } from "../../Settings/Settings";
|
||||||
|
|
||||||
import { SpecialServerIps } from "../../Server/SpecialServerIps";
|
import { isBackdoorInstalled } from "../../Server/ServerHelpers";
|
||||||
import { getServer, isBackdoorInstalled } from "../../Server/ServerHelpers";
|
import { GetServer } from "../../Server/AllServers";
|
||||||
|
|
||||||
import { CorruptableText } from "../../ui/React/CorruptableText";
|
import { CorruptableText } from "../../ui/React/CorruptableText";
|
||||||
import { use } from "../../ui/Context";
|
import { use } from "../../ui/Context";
|
||||||
@ -83,8 +83,7 @@ export function GenericLocation({ loc }: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const locContent: React.ReactNode[] = getLocationSpecificContent();
|
const locContent: React.ReactNode[] = getLocationSpecificContent();
|
||||||
const ip = SpecialServerIps.getIp(loc.name);
|
const server = GetServer(loc.name);
|
||||||
const server = getServer(ip);
|
|
||||||
const backdoorInstalled = server !== null && isBackdoorInstalled(server);
|
const backdoorInstalled = server !== null && isBackdoorInstalled(server);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -10,9 +10,8 @@ import { Location } from "../Location";
|
|||||||
|
|
||||||
import { CONSTANTS } from "../../Constants";
|
import { CONSTANTS } from "../../Constants";
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { getServer } from "../../Server/ServerHelpers";
|
import { GetServer } from "../../Server/AllServers";
|
||||||
import { Server } from "../../Server/Server";
|
import { Server } from "../../Server/Server";
|
||||||
import { SpecialServerIps } from "../../Server/SpecialServerIps";
|
|
||||||
|
|
||||||
import { Money } from "../../ui/React/Money";
|
import { Money } from "../../ui/React/Money";
|
||||||
import { IRouter } from "../../ui/Router";
|
import { IRouter } from "../../ui/Router";
|
||||||
@ -25,8 +24,7 @@ type IProps = {
|
|||||||
|
|
||||||
export function GymLocation(props: IProps): React.ReactElement {
|
export function GymLocation(props: IProps): React.ReactElement {
|
||||||
function calculateCost(): number {
|
function calculateCost(): number {
|
||||||
const ip = SpecialServerIps.getIp(props.loc.name);
|
const server = GetServer(props.loc.name);
|
||||||
const server = getServer(ip);
|
|
||||||
if (server == null || !server.hasOwnProperty("backdoorInstalled")) return props.loc.costMult;
|
if (server == null || !server.hasOwnProperty("backdoorInstalled")) return props.loc.costMult;
|
||||||
const discount = (server as Server).backdoorInstalled ? 0.9 : 1;
|
const discount = (server as Server).backdoorInstalled ? 0.9 : 1;
|
||||||
return props.loc.costMult * discount;
|
return props.loc.costMult * discount;
|
||||||
|
@ -10,9 +10,8 @@ import Button from "@mui/material/Button";
|
|||||||
import { Location } from "../Location";
|
import { Location } from "../Location";
|
||||||
|
|
||||||
import { CONSTANTS } from "../../Constants";
|
import { CONSTANTS } from "../../Constants";
|
||||||
import { getServer } from "../../Server/ServerHelpers";
|
import { GetServer } from "../../Server/AllServers";
|
||||||
import { Server } from "../../Server/Server";
|
import { Server } from "../../Server/Server";
|
||||||
import { SpecialServerIps } from "../../Server/SpecialServerIps";
|
|
||||||
|
|
||||||
import { Money } from "../../ui/React/Money";
|
import { Money } from "../../ui/React/Money";
|
||||||
import { use } from "../../ui/Context";
|
import { use } from "../../ui/Context";
|
||||||
@ -26,8 +25,7 @@ export function UniversityLocation(props: IProps): React.ReactElement {
|
|||||||
const router = use.Router();
|
const router = use.Router();
|
||||||
|
|
||||||
function calculateCost(): number {
|
function calculateCost(): number {
|
||||||
const ip = SpecialServerIps.getIp(props.loc.name);
|
const server = GetServer(props.loc.name);
|
||||||
const server = getServer(ip);
|
|
||||||
if (server == null || !server.hasOwnProperty("backdoorInstalled")) return props.loc.costMult;
|
if (server == null || !server.hasOwnProperty("backdoorInstalled")) return props.loc.costMult;
|
||||||
const discount = (server as Server).backdoorInstalled ? 0.9 : 1;
|
const discount = (server as Server).backdoorInstalled ? 0.9 : 1;
|
||||||
return props.loc.costMult * discount;
|
return props.loc.costMult * discount;
|
||||||
|
@ -4,7 +4,7 @@ import { AugmentationNames } from "../Augmentation/data/AugmentationNames";
|
|||||||
import { Programs } from "../Programs/Programs";
|
import { Programs } from "../Programs/Programs";
|
||||||
import { Player } from "../Player";
|
import { Player } from "../Player";
|
||||||
import { redPillFlag } from "../RedPill";
|
import { redPillFlag } from "../RedPill";
|
||||||
import { GetServerByHostname } from "../Server/ServerHelpers";
|
import { GetServer } from "../Server/AllServers";
|
||||||
import { Settings } from "../Settings/Settings";
|
import { Settings } from "../Settings/Settings";
|
||||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||||
import { Reviver } from "../utils/JSONReviver";
|
import { Reviver } from "../utils/JSONReviver";
|
||||||
@ -32,7 +32,7 @@ function showMessage(msg: Message): void {
|
|||||||
|
|
||||||
//Adds a message to a server
|
//Adds a message to a server
|
||||||
function addMessageToServer(msg: Message, serverHostname: string): void {
|
function addMessageToServer(msg: Message, serverHostname: string): void {
|
||||||
const server = GetServerByHostname(serverHostname);
|
const server = GetServer(serverHostname);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
console.warn(`Could not find server ${serverHostname}`);
|
console.warn(`Could not find server ${serverHostname}`);
|
||||||
return;
|
return;
|
||||||
|
@ -2,7 +2,7 @@ import { Milestone } from "./Milestone";
|
|||||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
import { Factions } from "../Faction/Factions";
|
import { Factions } from "../Faction/Factions";
|
||||||
import { Faction } from "../Faction/Faction";
|
import { Faction } from "../Faction/Faction";
|
||||||
import { GetServerByHostname } from "../Server/ServerHelpers";
|
import { GetServer } from "../Server/AllServers";
|
||||||
|
|
||||||
function allFactionAugs(p: IPlayer, f: Faction): boolean {
|
function allFactionAugs(p: IPlayer, f: Faction): boolean {
|
||||||
const factionAugs = f.augmentations.slice().filter((aug) => aug !== "NeuroFlux Governor");
|
const factionAugs = f.augmentations.slice().filter((aug) => aug !== "NeuroFlux Governor");
|
||||||
@ -21,7 +21,7 @@ export const Milestones: Milestone[] = [
|
|||||||
{
|
{
|
||||||
title: "Gain root access on CSEC",
|
title: "Gain root access on CSEC",
|
||||||
fulfilled: (): boolean => {
|
fulfilled: (): boolean => {
|
||||||
const server = GetServerByHostname("CSEC");
|
const server = GetServer("CSEC");
|
||||||
if (!server || !server.hasOwnProperty("hasAdminRights")) return false;
|
if (!server || !server.hasOwnProperty("hasAdminRights")) return false;
|
||||||
return (server as any).hasAdminRights;
|
return (server as any).hasAdminRights;
|
||||||
},
|
},
|
||||||
@ -29,7 +29,7 @@ export const Milestones: Milestone[] = [
|
|||||||
{
|
{
|
||||||
title: "Install the backdoor on CSEC",
|
title: "Install the backdoor on CSEC",
|
||||||
fulfilled: (): boolean => {
|
fulfilled: (): boolean => {
|
||||||
const server = GetServerByHostname("CSEC");
|
const server = GetServer("CSEC");
|
||||||
if (!server || !server.hasOwnProperty("backdoorInstalled")) return false;
|
if (!server || !server.hasOwnProperty("backdoorInstalled")) return false;
|
||||||
return (server as any).backdoorInstalled;
|
return (server as any).backdoorInstalled;
|
||||||
},
|
},
|
||||||
|
@ -11,7 +11,7 @@ import { RamCostConstants } from "./RamCostGenerator";
|
|||||||
|
|
||||||
import { RunningScript } from "../Script/RunningScript";
|
import { RunningScript } from "../Script/RunningScript";
|
||||||
import { Script } from "../Script/Script";
|
import { Script } from "../Script/Script";
|
||||||
import { AllServers } from "../Server/AllServers";
|
import { GetServer } from "../Server/AllServers";
|
||||||
import { BaseServer } from "../Server/BaseServer";
|
import { BaseServer } from "../Server/BaseServer";
|
||||||
import { IMap } from "../types";
|
import { IMap } from "../types";
|
||||||
|
|
||||||
@ -104,11 +104,11 @@ export class WorkerScript {
|
|||||||
/**
|
/**
|
||||||
* IP Address on which this script is running
|
* IP Address on which this script is running
|
||||||
*/
|
*/
|
||||||
serverIp: string;
|
hostname: string;
|
||||||
|
|
||||||
constructor(runningScriptObj: RunningScript, pid: number, nsFuncsGenerator?: (ws: WorkerScript) => any) {
|
constructor(runningScriptObj: RunningScript, pid: number, nsFuncsGenerator?: (ws: WorkerScript) => any) {
|
||||||
this.name = runningScriptObj.filename;
|
this.name = runningScriptObj.filename;
|
||||||
this.serverIp = runningScriptObj.server;
|
this.hostname = runningScriptObj.server;
|
||||||
|
|
||||||
const sanitizedPid = Math.round(pid);
|
const sanitizedPid = Math.round(pid);
|
||||||
if (typeof sanitizedPid !== "number" || isNaN(sanitizedPid)) {
|
if (typeof sanitizedPid !== "number" || isNaN(sanitizedPid)) {
|
||||||
@ -118,9 +118,9 @@ export class WorkerScript {
|
|||||||
runningScriptObj.pid = sanitizedPid;
|
runningScriptObj.pid = sanitizedPid;
|
||||||
|
|
||||||
// Get the underlying script's code
|
// Get the underlying script's code
|
||||||
const server = AllServers[this.serverIp];
|
const server = GetServer(this.hostname);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw new Error(`WorkerScript constructed with invalid server ip: ${this.serverIp}`);
|
throw new Error(`WorkerScript constructed with invalid server ip: ${this.hostname}`);
|
||||||
}
|
}
|
||||||
let found = false;
|
let found = false;
|
||||||
for (let i = 0; i < server.scripts.length; ++i) {
|
for (let i = 0; i < server.scripts.length; ++i) {
|
||||||
@ -147,7 +147,7 @@ export class WorkerScript {
|
|||||||
* Returns the Server on which this script is running
|
* Returns the Server on which this script is running
|
||||||
*/
|
*/
|
||||||
getServer(): BaseServer {
|
getServer(): BaseServer {
|
||||||
const server = AllServers[this.serverIp];
|
const server = GetServer(this.hostname);
|
||||||
if (server == null) throw new Error(`Script ${this.name} pid ${this.pid} is running on non-existent server?`);
|
if (server == null) throw new Error(`Script ${this.name} pid ${this.pid} is running on non-existent server?`);
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,17 @@ import { workerScripts } from "./WorkerScripts";
|
|||||||
import { WorkerScriptStartStopEventEmitter } from "./WorkerScriptStartStopEventEmitter";
|
import { WorkerScriptStartStopEventEmitter } from "./WorkerScriptStartStopEventEmitter";
|
||||||
|
|
||||||
import { RunningScript } from "../Script/RunningScript";
|
import { RunningScript } from "../Script/RunningScript";
|
||||||
import { AllServers } from "../Server/AllServers";
|
import { GetServer } from "../Server/AllServers";
|
||||||
|
|
||||||
import { compareArrays } from "../utils/helpers/compareArrays";
|
import { compareArrays } from "../utils/helpers/compareArrays";
|
||||||
import { roundToTwo } from "../utils/helpers/roundToTwo";
|
import { roundToTwo } from "../utils/helpers/roundToTwo";
|
||||||
|
|
||||||
export function killWorkerScript(runningScriptObj: RunningScript, serverIp: string, rerenderUi?: boolean): boolean;
|
export function killWorkerScript(runningScriptObj: RunningScript, hostname: string, rerenderUi?: boolean): boolean;
|
||||||
export function killWorkerScript(workerScript: WorkerScript): boolean;
|
export function killWorkerScript(workerScript: WorkerScript): boolean;
|
||||||
export function killWorkerScript(pid: number): boolean;
|
export function killWorkerScript(pid: number): boolean;
|
||||||
export function killWorkerScript(
|
export function killWorkerScript(
|
||||||
script: RunningScript | WorkerScript | number,
|
script: RunningScript | WorkerScript | number,
|
||||||
serverIp?: string,
|
hostname?: string,
|
||||||
rerenderUi?: boolean,
|
rerenderUi?: boolean,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (rerenderUi == null || typeof rerenderUi !== "boolean") {
|
if (rerenderUi == null || typeof rerenderUi !== "boolean") {
|
||||||
@ -28,7 +28,7 @@ export function killWorkerScript(
|
|||||||
stopAndCleanUpWorkerScript(script);
|
stopAndCleanUpWorkerScript(script);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (script instanceof RunningScript && typeof serverIp === "string") {
|
} else if (script instanceof RunningScript && typeof hostname === "string") {
|
||||||
// Try to kill by PID
|
// Try to kill by PID
|
||||||
const res = killWorkerScriptByPid(script.pid, rerenderUi);
|
const res = killWorkerScriptByPid(script.pid, rerenderUi);
|
||||||
if (res) {
|
if (res) {
|
||||||
@ -37,7 +37,7 @@ export function killWorkerScript(
|
|||||||
|
|
||||||
// If for some reason that doesn't work, we'll try the old way
|
// If for some reason that doesn't work, we'll try the old way
|
||||||
for (const ws of workerScripts.values()) {
|
for (const ws of workerScripts.values()) {
|
||||||
if (ws.name == script.filename && ws.serverIp == serverIp && compareArrays(ws.args, script.args)) {
|
if (ws.name == script.filename && ws.hostname == hostname && compareArrays(ws.args, script.args)) {
|
||||||
stopAndCleanUpWorkerScript(ws, rerenderUi);
|
stopAndCleanUpWorkerScript(ws, rerenderUi);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -80,11 +80,11 @@ function stopAndCleanUpWorkerScript(workerScript: WorkerScript, rerenderUi = tru
|
|||||||
*/
|
*/
|
||||||
function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void {
|
function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void {
|
||||||
if (workerScript instanceof WorkerScript) {
|
if (workerScript instanceof WorkerScript) {
|
||||||
const ip = workerScript.serverIp;
|
const ip = workerScript.hostname;
|
||||||
const name = workerScript.name;
|
const name = workerScript.name;
|
||||||
|
|
||||||
// Get the server on which the script runs
|
// Get the server on which the script runs
|
||||||
const server = AllServers[ip];
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
console.error(`Could not find server on which this script is running: ${ip}`);
|
console.error(`Could not find server on which this script is running: ${ip}`);
|
||||||
return;
|
return;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { isString } from "./utils/helpers/isString";
|
import { isString } from "./utils/helpers/isString";
|
||||||
import { AllServers } from "./Server/AllServers";
|
import { GetServer } from "./Server/AllServers";
|
||||||
import { WorkerScript } from "./Netscript/WorkerScript";
|
import { WorkerScript } from "./Netscript/WorkerScript";
|
||||||
|
|
||||||
export function netscriptDelay(time: number, workerScript: WorkerScript): Promise<void> {
|
export function netscriptDelay(time: number, workerScript: WorkerScript): Promise<void> {
|
||||||
@ -14,9 +14,9 @@ export function netscriptDelay(time: number, workerScript: WorkerScript): Promis
|
|||||||
|
|
||||||
export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): string {
|
export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): string {
|
||||||
const lineNum = "";
|
const lineNum = "";
|
||||||
const server = AllServers[workerScript.serverIp];
|
const server = GetServer(workerScript.hostname);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.serverIp}`);
|
throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "|" + server.hostname + "|" + workerScript.name + "|" + msg + lineNum;
|
return "|" + server.hostname + "|" + workerScript.name + "|" + msg + lineNum;
|
||||||
|
@ -59,18 +59,6 @@ import { Factions, factionExists } from "./Faction/Factions";
|
|||||||
import { joinFaction, purchaseAugmentation } from "./Faction/FactionHelpers";
|
import { joinFaction, purchaseAugmentation } from "./Faction/FactionHelpers";
|
||||||
import { netscriptCanGrow, netscriptCanHack, netscriptCanWeaken } from "./Hacking/netscriptCanHack";
|
import { netscriptCanGrow, netscriptCanHack, netscriptCanWeaken } from "./Hacking/netscriptCanHack";
|
||||||
|
|
||||||
import {
|
|
||||||
getCostOfNextHacknetNode,
|
|
||||||
getCostOfNextHacknetServer,
|
|
||||||
hasHacknetServers,
|
|
||||||
purchaseHacknet,
|
|
||||||
purchaseLevelUpgrade,
|
|
||||||
purchaseRamUpgrade,
|
|
||||||
purchaseCoreUpgrade,
|
|
||||||
purchaseCacheUpgrade,
|
|
||||||
purchaseHashUpgrade,
|
|
||||||
updateHashManagerCapacity,
|
|
||||||
} from "./Hacknet/HacknetHelpers";
|
|
||||||
import {
|
import {
|
||||||
calculateMoneyGainRate,
|
calculateMoneyGainRate,
|
||||||
calculateLevelUpgradeCost,
|
calculateLevelUpgradeCost,
|
||||||
@ -101,11 +89,9 @@ import { findRunningScript, findRunningScriptByPid } from "./Script/ScriptHelper
|
|||||||
import { isScriptFilename } from "./Script/isScriptFilename";
|
import { isScriptFilename } from "./Script/isScriptFilename";
|
||||||
import { PromptEvent } from "./ui/React/PromptManager";
|
import { PromptEvent } from "./ui/React/PromptManager";
|
||||||
|
|
||||||
import { AllServers, AddToAllServers, createUniqueRandomIp } from "./Server/AllServers";
|
import { GetServer, GetAllServers, DeleteServer, AddToAllServers, createUniqueRandomIp } from "./Server/AllServers";
|
||||||
import { RunningScript } from "./Script/RunningScript";
|
import { RunningScript } from "./Script/RunningScript";
|
||||||
import {
|
import {
|
||||||
GetServerByHostname,
|
|
||||||
getServer,
|
|
||||||
getServerOnNetwork,
|
getServerOnNetwork,
|
||||||
numCycleForGrowth,
|
numCycleForGrowth,
|
||||||
processSingleServerGrowth,
|
processSingleServerGrowth,
|
||||||
@ -113,7 +99,6 @@ import {
|
|||||||
} from "./Server/ServerHelpers";
|
} from "./Server/ServerHelpers";
|
||||||
import { getPurchaseServerCost, getPurchaseServerLimit, getPurchaseServerMaxRam } from "./Server/ServerPurchases";
|
import { getPurchaseServerCost, getPurchaseServerLimit, getPurchaseServerMaxRam } from "./Server/ServerPurchases";
|
||||||
import { Server } from "./Server/Server";
|
import { Server } from "./Server/Server";
|
||||||
import { SpecialServerIps } from "./Server/SpecialServerIps";
|
|
||||||
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
|
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||||
import { buyStock, sellStock, shortStock, sellShort } from "./StockMarket/BuyingAndSelling";
|
import { buyStock, sellStock, shortStock, sellShort } from "./StockMarket/BuyingAndSelling";
|
||||||
import { influenceStockThroughServerHack, influenceStockThroughServerGrow } from "./StockMarket/PlayerInfluencing";
|
import { influenceStockThroughServerHack, influenceStockThroughServerGrow } from "./StockMarket/PlayerInfluencing";
|
||||||
@ -151,7 +136,6 @@ import { IIndustry } from "./Corporation/IIndustry";
|
|||||||
|
|
||||||
import { Faction } from "./Faction/Faction";
|
import { Faction } from "./Faction/Faction";
|
||||||
import { Augmentation } from "./Augmentation/Augmentation";
|
import { Augmentation } from "./Augmentation/Augmentation";
|
||||||
import { HacknetNode } from "./Hacknet/HacknetNode";
|
|
||||||
|
|
||||||
import { CodingContract } from "./CodingContracts";
|
import { CodingContract } from "./CodingContracts";
|
||||||
import { Stock } from "./StockMarket/Stock";
|
import { Stock } from "./StockMarket/Stock";
|
||||||
@ -212,7 +196,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
|
|
||||||
let threads = workerScript.scriptRef.threads;
|
let threads = workerScript.scriptRef.threads;
|
||||||
if (typeof threads !== "number") {
|
if (typeof threads !== "number") {
|
||||||
console.warn(`WorkerScript detected NaN for threadcount for ${workerScript.name} on ${workerScript.serverIp}`);
|
console.warn(`WorkerScript detected NaN for threadcount for ${workerScript.name} on ${workerScript.hostname}`);
|
||||||
threads = 1;
|
threads = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +235,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
* @returns {Server} The specified Server
|
* @returns {Server} The specified Server
|
||||||
*/
|
*/
|
||||||
const safeGetServer = function (ip: any, callingFnName: any = ""): BaseServer {
|
const safeGetServer = function (ip: any, callingFnName: any = ""): BaseServer {
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg(callingFnName, `Invalid IP/hostname: ${ip}`);
|
throw makeRuntimeErrorMsg(callingFnName, `Invalid IP/hostname: ${ip}`);
|
||||||
}
|
}
|
||||||
@ -285,7 +269,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (fn != null && typeof fn === "string") {
|
if (fn != null && typeof fn === "string") {
|
||||||
// Get Logs of another script
|
// Get Logs of another script
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
ip = workerScript.serverIp;
|
ip = workerScript.hostname;
|
||||||
}
|
}
|
||||||
const server = safeGetServer(ip, callingFnName);
|
const server = safeGetServer(ip, callingFnName);
|
||||||
|
|
||||||
@ -301,8 +285,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
callingFnName = "getRunningScriptgetRunningScriptByPid";
|
callingFnName = "getRunningScriptgetRunningScriptByPid";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const name of Object.keys(AllServers)) {
|
for (const server of GetAllServers()) {
|
||||||
const server = AllServers[name];
|
|
||||||
const runningScript = findRunningScriptByPid(pid, server);
|
const runningScript = findRunningScriptByPid(pid, server);
|
||||||
if (runningScript) return runningScript;
|
if (runningScript) return runningScript;
|
||||||
}
|
}
|
||||||
@ -600,7 +583,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
throw makeRuntimeErrorMsg("hack", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("hack", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
const threads = resolveNetscriptRequestedThreads(workerScript, "hack", requestedThreads);
|
const threads = resolveNetscriptRequestedThreads(workerScript, "hack", requestedThreads);
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
throw makeRuntimeErrorMsg("hack", `Invalid IP/hostname: ${ip}.`);
|
throw makeRuntimeErrorMsg("hack", `Invalid IP/hostname: ${ip}.`);
|
||||||
}
|
}
|
||||||
@ -664,7 +647,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
workerScript.scriptRef.onlineMoneyMade += moneyGained;
|
workerScript.scriptRef.onlineMoneyMade += moneyGained;
|
||||||
Player.scriptProdSinceLastAug += moneyGained;
|
Player.scriptProdSinceLastAug += moneyGained;
|
||||||
Player.recordMoneySource(moneyGained, "hacking");
|
Player.recordMoneySource(moneyGained, "hacking");
|
||||||
workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
|
workerScript.scriptRef.recordHack(server.hostname, moneyGained, threads);
|
||||||
Player.gainHackingExp(expGainedOnSuccess);
|
Player.gainHackingExp(expGainedOnSuccess);
|
||||||
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
|
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
@ -737,9 +720,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
hacknet: hacknet,
|
hacknet: hacknet,
|
||||||
sprintf: sprintf,
|
sprintf: sprintf,
|
||||||
vsprintf: vsprintf,
|
vsprintf: vsprintf,
|
||||||
scan: function (ip: any = workerScript.serverIp, hostnames: any = true): any {
|
scan: function (ip: any = workerScript.hostname, hostnames: any = true): any {
|
||||||
updateDynamicRam("scan", getRamCost("scan"));
|
updateDynamicRam("scan", getRamCost("scan"));
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("scan", `Invalid IP/hostname: ${ip}.`);
|
throw makeRuntimeErrorMsg("scan", `Invalid IP/hostname: ${ip}.`);
|
||||||
}
|
}
|
||||||
@ -751,7 +734,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (hostnames) {
|
if (hostnames) {
|
||||||
entry = s.hostname;
|
entry = s.hostname;
|
||||||
} else {
|
} else {
|
||||||
entry = s.ip;
|
entry = s.hostname;
|
||||||
}
|
}
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -826,7 +809,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("grow", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("grow", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("grow", "Cannot be executed on this server.");
|
workerScript.log("grow", "Cannot be executed on this server.");
|
||||||
return false;
|
return false;
|
||||||
@ -835,7 +818,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
throw makeRuntimeErrorMsg("grow", `Invalid IP/hostname: ${ip}.`);
|
throw makeRuntimeErrorMsg("grow", `Invalid IP/hostname: ${ip}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const host = getServer(workerScript.serverIp);
|
const host = GetServer(workerScript.hostname);
|
||||||
if (host === null) {
|
if (host === null) {
|
||||||
throw new Error("Workerscript host is null");
|
throw new Error("Workerscript host is null");
|
||||||
}
|
}
|
||||||
@ -861,7 +844,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
const moneyBefore = server.moneyAvailable <= 0 ? 1 : server.moneyAvailable;
|
const moneyBefore = server.moneyAvailable <= 0 ? 1 : server.moneyAvailable;
|
||||||
processSingleServerGrowth(server, threads, Player, host.cpuCores);
|
processSingleServerGrowth(server, threads, Player, host.cpuCores);
|
||||||
const moneyAfter = server.moneyAvailable;
|
const moneyAfter = server.moneyAvailable;
|
||||||
workerScript.scriptRef.recordGrow(server.ip, threads);
|
workerScript.scriptRef.recordGrow(server.hostname, threads);
|
||||||
const expGain = calculateHackingExpGain(server, Player) * threads;
|
const expGain = calculateHackingExpGain(server, Player) * threads;
|
||||||
const logGrowPercent = moneyAfter / moneyBefore - 1;
|
const logGrowPercent = moneyAfter / moneyBefore - 1;
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
@ -900,7 +883,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("weaken", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("weaken", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("weaken", "Cannot be executed on this server.");
|
workerScript.log("weaken", "Cannot be executed on this server.");
|
||||||
return false;
|
return false;
|
||||||
@ -925,14 +908,14 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
);
|
);
|
||||||
return netscriptDelay(weakenTime * 1000, workerScript).then(function () {
|
return netscriptDelay(weakenTime * 1000, workerScript).then(function () {
|
||||||
if (workerScript.env.stopFlag) return Promise.reject(workerScript);
|
if (workerScript.env.stopFlag) return Promise.reject(workerScript);
|
||||||
const host = getServer(workerScript.serverIp);
|
const host = GetServer(workerScript.hostname);
|
||||||
if (host === null) {
|
if (host === null) {
|
||||||
workerScript.log("weaken", "Server is null, did it die?");
|
workerScript.log("weaken", "Server is null, did it die?");
|
||||||
return Promise.resolve(0);
|
return Promise.resolve(0);
|
||||||
}
|
}
|
||||||
const coreBonus = 1 + (host.cpuCores - 1) / 16;
|
const coreBonus = 1 + (host.cpuCores - 1) / 16;
|
||||||
server.weaken(CONSTANTS.ServerWeakenAmount * threads * coreBonus);
|
server.weaken(CONSTANTS.ServerWeakenAmount * threads * coreBonus);
|
||||||
workerScript.scriptRef.recordWeaken(server.ip, threads);
|
workerScript.scriptRef.recordWeaken(server.hostname, threads);
|
||||||
const expGain = calculateHackingExpGain(server, Player) * threads;
|
const expGain = calculateHackingExpGain(server, Player) * threads;
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
"weaken",
|
"weaken",
|
||||||
@ -998,7 +981,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
|
|
||||||
return runningScriptObj.logs.slice();
|
return runningScriptObj.logs.slice();
|
||||||
},
|
},
|
||||||
tail: function (fn: any, ip: any = workerScript.serverIp, ...scriptArgs: any): any {
|
tail: function (fn: any, ip: any = workerScript.hostname, ...scriptArgs: any): any {
|
||||||
let runningScriptObj;
|
let runningScriptObj;
|
||||||
if (arguments.length === 0) {
|
if (arguments.length === 0) {
|
||||||
runningScriptObj = workerScript.scriptRef;
|
runningScriptObj = workerScript.scriptRef;
|
||||||
@ -1019,7 +1002,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("nuke", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("nuke", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("nuke", "Cannot be executed on this server.");
|
workerScript.log("nuke", "Cannot be executed on this server.");
|
||||||
return false;
|
return false;
|
||||||
@ -1046,7 +1029,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("brutessh", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("brutessh", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("brutessh", "Cannot be executed on this server.");
|
workerScript.log("brutessh", "Cannot be executed on this server.");
|
||||||
return false;
|
return false;
|
||||||
@ -1071,7 +1054,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("ftpcrack", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("ftpcrack", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("ftpcrack", "Cannot be executed on this server.");
|
workerScript.log("ftpcrack", "Cannot be executed on this server.");
|
||||||
return false;
|
return false;
|
||||||
@ -1096,7 +1079,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("relaysmtp", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("relaysmtp", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("relaysmtp", "Cannot be executed on this server.");
|
workerScript.log("relaysmtp", "Cannot be executed on this server.");
|
||||||
return false;
|
return false;
|
||||||
@ -1121,7 +1104,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("httpworm", "Takes 1 argument");
|
throw makeRuntimeErrorMsg("httpworm", "Takes 1 argument");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("httpworm", "Cannot be executed on this server.");
|
workerScript.log("httpworm", "Cannot be executed on this server.");
|
||||||
return false;
|
return false;
|
||||||
@ -1146,7 +1129,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("sqlinject", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("sqlinject", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("sqlinject", "Cannot be executed on this server.");
|
workerScript.log("sqlinject", "Cannot be executed on this server.");
|
||||||
return false;
|
return false;
|
||||||
@ -1174,7 +1157,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (isNaN(threads) || threads <= 0) {
|
if (isNaN(threads) || threads <= 0) {
|
||||||
throw makeRuntimeErrorMsg("run", `Invalid thread count. Must be numeric and > 0, is ${threads}`);
|
throw makeRuntimeErrorMsg("run", `Invalid thread count. Must be numeric and > 0, is ${threads}`);
|
||||||
}
|
}
|
||||||
const scriptServer = getServer(workerScript.serverIp);
|
const scriptServer = GetServer(workerScript.hostname);
|
||||||
if (scriptServer == null) {
|
if (scriptServer == null) {
|
||||||
throw makeRuntimeErrorMsg("run", "Could not find server. This is a bug. Report to dev.");
|
throw makeRuntimeErrorMsg("run", "Could not find server. This is a bug. Report to dev.");
|
||||||
}
|
}
|
||||||
@ -1189,7 +1172,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (isNaN(threads) || threads <= 0) {
|
if (isNaN(threads) || threads <= 0) {
|
||||||
throw makeRuntimeErrorMsg("exec", `Invalid thread count. Must be numeric and > 0, is ${threads}`);
|
throw makeRuntimeErrorMsg("exec", `Invalid thread count. Must be numeric and > 0, is ${threads}`);
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("exec", `Invalid IP/hostname: ${ip}`);
|
throw makeRuntimeErrorMsg("exec", `Invalid IP/hostname: ${ip}`);
|
||||||
}
|
}
|
||||||
@ -1206,7 +1189,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (isNaN(threads) || threads <= 0) {
|
if (isNaN(threads) || threads <= 0) {
|
||||||
throw makeRuntimeErrorMsg("spawn", `Invalid thread count. Must be numeric and > 0, is ${threads}`);
|
throw makeRuntimeErrorMsg("spawn", `Invalid thread count. Must be numeric and > 0, is ${threads}`);
|
||||||
}
|
}
|
||||||
const scriptServer = getServer(workerScript.serverIp);
|
const scriptServer = GetServer(workerScript.hostname);
|
||||||
if (scriptServer == null) {
|
if (scriptServer == null) {
|
||||||
throw makeRuntimeErrorMsg("spawn", "Could not find server. This is a bug. Report to dev");
|
throw makeRuntimeErrorMsg("spawn", "Could not find server. This is a bug. Report to dev");
|
||||||
}
|
}
|
||||||
@ -1242,7 +1225,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = killWorkerScript(runningScriptObj, server.ip);
|
res = killWorkerScript(runningScriptObj, server.hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
@ -1261,18 +1244,18 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
killall: function (ip: any = workerScript.serverIp): any {
|
killall: function (ip: any = workerScript.hostname): any {
|
||||||
updateDynamicRam("killall", getRamCost("killall"));
|
updateDynamicRam("killall", getRamCost("killall"));
|
||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("killall", "Takes 1 argument");
|
throw makeRuntimeErrorMsg("killall", "Takes 1 argument");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("killall", `Invalid IP/hostname: ${ip}`);
|
throw makeRuntimeErrorMsg("killall", `Invalid IP/hostname: ${ip}`);
|
||||||
}
|
}
|
||||||
const scriptsRunning = server.runningScripts.length > 0;
|
const scriptsRunning = server.runningScripts.length > 0;
|
||||||
for (let i = server.runningScripts.length - 1; i >= 0; --i) {
|
for (let i = server.runningScripts.length - 1; i >= 0; --i) {
|
||||||
killWorkerScript(server.runningScripts[i], server.ip, false);
|
killWorkerScript(server.runningScripts[i], server.hostname, false);
|
||||||
}
|
}
|
||||||
WorkerScriptStartStopEventEmitter.emit();
|
WorkerScriptStartStopEventEmitter.emit();
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
@ -1323,12 +1306,12 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (scriptname === undefined || ip1 === undefined || ip2 === undefined) {
|
if (scriptname === undefined || ip1 === undefined || ip2 === undefined) {
|
||||||
throw makeRuntimeErrorMsg("scp", "Takes 2 or 3 arguments");
|
throw makeRuntimeErrorMsg("scp", "Takes 2 or 3 arguments");
|
||||||
}
|
}
|
||||||
destServer = getServer(ip2);
|
destServer = GetServer(ip2);
|
||||||
if (destServer == null) {
|
if (destServer == null) {
|
||||||
throw makeRuntimeErrorMsg("scp", `Invalid IP/hostname: ${ip2}`);
|
throw makeRuntimeErrorMsg("scp", `Invalid IP/hostname: ${ip2}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
currServ = getServer(ip1);
|
currServ = GetServer(ip1);
|
||||||
if (currServ == null) {
|
if (currServ == null) {
|
||||||
throw makeRuntimeErrorMsg("scp", `Invalid IP/hostname: ${ip1}`);
|
throw makeRuntimeErrorMsg("scp", `Invalid IP/hostname: ${ip1}`);
|
||||||
}
|
}
|
||||||
@ -1337,12 +1320,12 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (scriptname === undefined || ip1 === undefined) {
|
if (scriptname === undefined || ip1 === undefined) {
|
||||||
throw makeRuntimeErrorMsg("scp", "Takes 2 or 3 arguments");
|
throw makeRuntimeErrorMsg("scp", "Takes 2 or 3 arguments");
|
||||||
}
|
}
|
||||||
destServer = getServer(ip1);
|
destServer = GetServer(ip1);
|
||||||
if (destServer == null) {
|
if (destServer == null) {
|
||||||
throw makeRuntimeErrorMsg("scp", `Invalid IP/hostname: ${ip1}`);
|
throw makeRuntimeErrorMsg("scp", `Invalid IP/hostname: ${ip1}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
currServ = getServer(workerScript.serverIp);
|
currServ = GetServer(workerScript.hostname);
|
||||||
if (currServ == null) {
|
if (currServ == null) {
|
||||||
throw makeRuntimeErrorMsg("scp", "Could not find server ip for this script. This is a bug. Report to dev.");
|
throw makeRuntimeErrorMsg("scp", "Could not find server ip for this script. This is a bug. Report to dev.");
|
||||||
}
|
}
|
||||||
@ -1437,7 +1420,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
const newScript = new Script(scriptname);
|
const newScript = new Script(scriptname);
|
||||||
newScript.code = sourceScript.code;
|
newScript.code = sourceScript.code;
|
||||||
newScript.ramUsage = sourceScript.ramUsage;
|
newScript.ramUsage = sourceScript.ramUsage;
|
||||||
newScript.server = destServer.ip;
|
newScript.server = destServer.hostname;
|
||||||
destServer.scripts.push(newScript);
|
destServer.scripts.push(newScript);
|
||||||
workerScript.log("scp", `File '${scriptname}' copied over to '${destServer.hostname}'.`);
|
workerScript.log("scp", `File '${scriptname}' copied over to '${destServer.hostname}'.`);
|
||||||
return true;
|
return true;
|
||||||
@ -1447,7 +1430,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("ls", "Usage: ls(ip/hostname, [grep filter])");
|
throw makeRuntimeErrorMsg("ls", "Usage: ls(ip/hostname, [grep filter])");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("ls", `Invalid IP/hostname: ${ip}`);
|
throw makeRuntimeErrorMsg("ls", `Invalid IP/hostname: ${ip}`);
|
||||||
}
|
}
|
||||||
@ -1521,9 +1504,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
allFiles.sort();
|
allFiles.sort();
|
||||||
return allFiles;
|
return allFiles;
|
||||||
},
|
},
|
||||||
ps: function (ip: any = workerScript.serverIp): any {
|
ps: function (ip: any = workerScript.hostname): any {
|
||||||
updateDynamicRam("ps", getRamCost("ps"));
|
updateDynamicRam("ps", getRamCost("ps"));
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("ps", `Invalid IP/hostname: ${ip}`);
|
throw makeRuntimeErrorMsg("ps", `Invalid IP/hostname: ${ip}`);
|
||||||
}
|
}
|
||||||
@ -1544,7 +1527,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (ip === undefined) {
|
if (ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("hasRootAccess", "Takes 1 argument");
|
throw makeRuntimeErrorMsg("hasRootAccess", "Takes 1 argument");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("hasRootAccess", `Invalid IP/hostname: ${ip}`);
|
throw makeRuntimeErrorMsg("hasRootAccess", `Invalid IP/hostname: ${ip}`);
|
||||||
}
|
}
|
||||||
@ -1552,15 +1535,15 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
},
|
},
|
||||||
getIp: function (): any {
|
getIp: function (): any {
|
||||||
updateDynamicRam("getIp", getRamCost("getIp"));
|
updateDynamicRam("getIp", getRamCost("getIp"));
|
||||||
const scriptServer = getServer(workerScript.serverIp);
|
const scriptServer = GetServer(workerScript.hostname);
|
||||||
if (scriptServer == null) {
|
if (scriptServer == null) {
|
||||||
throw makeRuntimeErrorMsg("getIp", "Could not find server. This is a bug. Report to dev.");
|
throw makeRuntimeErrorMsg("getIp", "Could not find server. This is a bug. Report to dev.");
|
||||||
}
|
}
|
||||||
return scriptServer.ip;
|
return scriptServer.hostname;
|
||||||
},
|
},
|
||||||
getHostname: function (): any {
|
getHostname: function (): any {
|
||||||
updateDynamicRam("getHostname", getRamCost("getHostname"));
|
updateDynamicRam("getHostname", getRamCost("getHostname"));
|
||||||
const scriptServer = getServer(workerScript.serverIp);
|
const scriptServer = GetServer(workerScript.hostname);
|
||||||
if (scriptServer == null) {
|
if (scriptServer == null) {
|
||||||
throw makeRuntimeErrorMsg("getHostname", "Could not find server. This is a bug. Report to dev.");
|
throw makeRuntimeErrorMsg("getHostname", "Could not find server. This is a bug. Report to dev.");
|
||||||
}
|
}
|
||||||
@ -1769,14 +1752,14 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
},
|
},
|
||||||
serverExists: function (ip: any): any {
|
serverExists: function (ip: any): any {
|
||||||
updateDynamicRam("serverExists", getRamCost("serverExists"));
|
updateDynamicRam("serverExists", getRamCost("serverExists"));
|
||||||
return getServer(ip) !== null;
|
return GetServer(ip) !== null;
|
||||||
},
|
},
|
||||||
fileExists: function (filename: any, ip: any = workerScript.serverIp): any {
|
fileExists: function (filename: any, ip: any = workerScript.hostname): any {
|
||||||
updateDynamicRam("fileExists", getRamCost("fileExists"));
|
updateDynamicRam("fileExists", getRamCost("fileExists"));
|
||||||
if (filename === undefined) {
|
if (filename === undefined) {
|
||||||
throw makeRuntimeErrorMsg("fileExists", "Usage: fileExists(scriptname, [server])");
|
throw makeRuntimeErrorMsg("fileExists", "Usage: fileExists(scriptname, [server])");
|
||||||
}
|
}
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("fileExists", `Invalid IP/hostname: ${ip}`);
|
throw makeRuntimeErrorMsg("fileExists", `Invalid IP/hostname: ${ip}`);
|
||||||
}
|
}
|
||||||
@ -1801,7 +1784,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
isRunning: function (fn: any, ip: any = workerScript.serverIp, ...scriptArgs: any): any {
|
isRunning: function (fn: any, ip: any = workerScript.hostname, ...scriptArgs: any): any {
|
||||||
updateDynamicRam("isRunning", getRamCost("isRunning"));
|
updateDynamicRam("isRunning", getRamCost("isRunning"));
|
||||||
if (fn === undefined || ip === undefined) {
|
if (fn === undefined || ip === undefined) {
|
||||||
throw makeRuntimeErrorMsg("isRunning", "Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
|
throw makeRuntimeErrorMsg("isRunning", "Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
|
||||||
@ -2185,10 +2168,10 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
});
|
});
|
||||||
AddToAllServers(newServ);
|
AddToAllServers(newServ);
|
||||||
|
|
||||||
Player.purchasedServers.push(newServ.ip);
|
Player.purchasedServers.push(newServ.hostname);
|
||||||
const homeComputer = Player.getHomeComputer();
|
const homeComputer = Player.getHomeComputer();
|
||||||
homeComputer.serversOnNetwork.push(newServ.ip);
|
homeComputer.serversOnNetwork.push(newServ.hostname);
|
||||||
newServ.serversOnNetwork.push(homeComputer.ip);
|
newServ.serversOnNetwork.push(homeComputer.hostname);
|
||||||
Player.loseMoney(cost);
|
Player.loseMoney(cost);
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
"purchaseServer",
|
"purchaseServer",
|
||||||
@ -2200,7 +2183,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
updateDynamicRam("deleteServer", getRamCost("deleteServer"));
|
updateDynamicRam("deleteServer", getRamCost("deleteServer"));
|
||||||
let hostnameStr = String(hostname);
|
let hostnameStr = String(hostname);
|
||||||
hostnameStr = hostnameStr.replace(/\s\s+/g, "");
|
hostnameStr = hostnameStr.replace(/\s\s+/g, "");
|
||||||
const server = GetServerByHostname(hostnameStr);
|
const server = GetServer(hostnameStr);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("deleteServer", `Invalid argument: hostname='${hostnameStr}'`);
|
workerScript.log("deleteServer", `Invalid argument: hostname='${hostnameStr}'`);
|
||||||
return false;
|
return false;
|
||||||
@ -2215,7 +2198,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ip = server.ip;
|
const ip = server.hostname;
|
||||||
|
|
||||||
// Can't delete server you're currently connected to
|
// Can't delete server you're currently connected to
|
||||||
if (server.isConnectedTo) {
|
if (server.isConnectedTo) {
|
||||||
@ -2224,7 +2207,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A server cannot delete itself
|
// A server cannot delete itself
|
||||||
if (ip === workerScript.serverIp) {
|
if (ip === workerScript.hostname) {
|
||||||
workerScript.log("deleteServer", "Cannot delete the server this script is running on.");
|
workerScript.log("deleteServer", "Cannot delete the server this script is running on.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2257,7 +2240,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete from all servers
|
// Delete from all servers
|
||||||
delete AllServers[ip];
|
DeleteServer(ip);
|
||||||
|
|
||||||
// Delete from home computer
|
// Delete from home computer
|
||||||
found = false;
|
found = false;
|
||||||
@ -2281,7 +2264,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
const res: string[] = [];
|
const res: string[] = [];
|
||||||
Player.purchasedServers.forEach(function (ip) {
|
Player.purchasedServers.forEach(function (ip) {
|
||||||
if (hostname) {
|
if (hostname) {
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("getPurchasedServers", "Could not find server. This is a bug. Report to dev.");
|
throw makeRuntimeErrorMsg("getPurchasedServers", "Could not find server. This is a bug. Report to dev.");
|
||||||
}
|
}
|
||||||
@ -2336,7 +2319,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
let script = workerScript.getScriptOnServer(fn, server);
|
let script = workerScript.getScriptOnServer(fn, server);
|
||||||
if (script == null) {
|
if (script == null) {
|
||||||
// Create a new script
|
// Create a new script
|
||||||
script = new Script(fn, data, server.ip, server.scripts);
|
script = new Script(fn, data, server.hostname, server.scripts);
|
||||||
server.scripts.push(script);
|
server.scripts.push(script);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2402,7 +2385,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
} else if (isString(port)) {
|
} else if (isString(port)) {
|
||||||
// Read from script or text file
|
// Read from script or text file
|
||||||
const fn = port;
|
const fn = port;
|
||||||
const server = getServer(workerScript.serverIp);
|
const server = GetServer(workerScript.hostname);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("read", "Error getting Server. This is a bug. Report to dev.");
|
throw makeRuntimeErrorMsg("read", "Error getting Server. This is a bug. Report to dev.");
|
||||||
}
|
}
|
||||||
@ -2468,7 +2451,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
} else if (isString(port)) {
|
} else if (isString(port)) {
|
||||||
// Clear text file
|
// Clear text file
|
||||||
const fn = port;
|
const fn = port;
|
||||||
const server = getServer(workerScript.serverIp);
|
const server = GetServer(workerScript.hostname);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("clear", "Error getting Server. This is a bug. Report to dev.");
|
throw makeRuntimeErrorMsg("clear", "Error getting Server. This is a bug. Report to dev.");
|
||||||
}
|
}
|
||||||
@ -2506,7 +2489,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
updateDynamicRam("rm", getRamCost("rm"));
|
updateDynamicRam("rm", getRamCost("rm"));
|
||||||
|
|
||||||
if (ip == null || ip === "") {
|
if (ip == null || ip === "") {
|
||||||
ip = workerScript.serverIp;
|
ip = workerScript.hostname;
|
||||||
}
|
}
|
||||||
const s = safeGetServer(ip, "rm");
|
const s = safeGetServer(ip, "rm");
|
||||||
|
|
||||||
@ -2519,7 +2502,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
},
|
},
|
||||||
scriptRunning: function (scriptname: any, ip: any): any {
|
scriptRunning: function (scriptname: any, ip: any): any {
|
||||||
updateDynamicRam("scriptRunning", getRamCost("scriptRunning"));
|
updateDynamicRam("scriptRunning", getRamCost("scriptRunning"));
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("scriptRunning", `Invalid IP/hostname: ${ip}`);
|
throw makeRuntimeErrorMsg("scriptRunning", `Invalid IP/hostname: ${ip}`);
|
||||||
}
|
}
|
||||||
@ -2532,14 +2515,14 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
},
|
},
|
||||||
scriptKill: function (scriptname: any, ip: any): any {
|
scriptKill: function (scriptname: any, ip: any): any {
|
||||||
updateDynamicRam("scriptKill", getRamCost("scriptKill"));
|
updateDynamicRam("scriptKill", getRamCost("scriptKill"));
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("scriptKill", `Invalid IP/hostname: ${ip}`);
|
throw makeRuntimeErrorMsg("scriptKill", `Invalid IP/hostname: ${ip}`);
|
||||||
}
|
}
|
||||||
let suc = false;
|
let suc = false;
|
||||||
for (let i = 0; i < server.runningScripts.length; ++i) {
|
for (let i = 0; i < server.runningScripts.length; ++i) {
|
||||||
if (server.runningScripts[i].filename == scriptname) {
|
if (server.runningScripts[i].filename == scriptname) {
|
||||||
killWorkerScript(server.runningScripts[i], server.ip);
|
killWorkerScript(server.runningScripts[i], server.hostname);
|
||||||
suc = true;
|
suc = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2548,9 +2531,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
getScriptName: function (): any {
|
getScriptName: function (): any {
|
||||||
return workerScript.name;
|
return workerScript.name;
|
||||||
},
|
},
|
||||||
getScriptRam: function (scriptname: any, ip: any = workerScript.serverIp): any {
|
getScriptRam: function (scriptname: any, ip: any = workerScript.hostname): any {
|
||||||
updateDynamicRam("getScriptRam", getRamCost("getScriptRam"));
|
updateDynamicRam("getScriptRam", getRamCost("getScriptRam"));
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("getScriptRam", `Invalid IP/hostname: ${ip}`);
|
throw makeRuntimeErrorMsg("getScriptRam", `Invalid IP/hostname: ${ip}`);
|
||||||
}
|
}
|
||||||
@ -2649,7 +2632,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
// Get income for a particular script
|
// Get income for a particular script
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("getScriptIncome", `Invalid IP/hostnamed: ${ip}`);
|
throw makeRuntimeErrorMsg("getScriptIncome", `Invalid IP/hostnamed: ${ip}`);
|
||||||
}
|
}
|
||||||
@ -2674,7 +2657,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return total;
|
return total;
|
||||||
} else {
|
} else {
|
||||||
// Get income for a particular script
|
// Get income for a particular script
|
||||||
const server = getServer(ip);
|
const server = GetServer(ip);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw makeRuntimeErrorMsg("getScriptExpGain", `Invalid IP/hostnamed: ${ip}`);
|
throw makeRuntimeErrorMsg("getScriptExpGain", `Invalid IP/hostnamed: ${ip}`);
|
||||||
}
|
}
|
||||||
@ -2715,7 +2698,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
wget: async function (url: any, target: any, ip: any = workerScript.serverIp): Promise<boolean> {
|
wget: async function (url: any, target: any, ip: any = workerScript.hostname): Promise<boolean> {
|
||||||
if (!isScriptFilename(target) && !target.endsWith(".txt")) {
|
if (!isScriptFilename(target) && !target.endsWith(".txt")) {
|
||||||
workerScript.log("wget", `Invalid target file: '${target}'. Must be a script or text file.`);
|
workerScript.log("wget", `Invalid target file: '${target}'. Must be a script or text file.`);
|
||||||
return Promise.resolve(false);
|
return Promise.resolve(false);
|
||||||
@ -2953,7 +2936,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
updateDynamicRam("purchaseTor", getRamCost("purchaseTor"));
|
updateDynamicRam("purchaseTor", getRamCost("purchaseTor"));
|
||||||
checkSingularityAccess("purchaseTor", 1);
|
checkSingularityAccess("purchaseTor", 1);
|
||||||
|
|
||||||
if (SpecialServerIps["Darkweb Server"] != null) {
|
if (Player.hasTorRouter()) {
|
||||||
workerScript.log("purchaseTor", "You already have a TOR router!");
|
workerScript.log("purchaseTor", "You already have a TOR router!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2974,10 +2957,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
maxRam: 1,
|
maxRam: 1,
|
||||||
});
|
});
|
||||||
AddToAllServers(darkweb);
|
AddToAllServers(darkweb);
|
||||||
SpecialServerIps.addIp("Darkweb Server", darkweb.ip);
|
|
||||||
|
|
||||||
Player.getHomeComputer().serversOnNetwork.push(darkweb.ip);
|
Player.getHomeComputer().serversOnNetwork.push(darkweb.hostname);
|
||||||
darkweb.serversOnNetwork.push(Player.getHomeComputer().ip);
|
darkweb.serversOnNetwork.push(Player.getHomeComputer().hostname);
|
||||||
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||||
workerScript.log("purchaseTor", "You have purchased a Tor router!");
|
workerScript.log("purchaseTor", "You have purchased a Tor router!");
|
||||||
return true;
|
return true;
|
||||||
@ -2986,7 +2968,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
updateDynamicRam("purchaseProgram", getRamCost("purchaseProgram"));
|
updateDynamicRam("purchaseProgram", getRamCost("purchaseProgram"));
|
||||||
checkSingularityAccess("purchaseProgram", 1);
|
checkSingularityAccess("purchaseProgram", 1);
|
||||||
|
|
||||||
if (SpecialServerIps["Darkweb Server"] == null) {
|
if (!Player.hasTorRouter()) {
|
||||||
workerScript.log("purchaseProgram", "You do not have the TOR router.");
|
workerScript.log("purchaseProgram", "You do not have the TOR router.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3039,7 +3021,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
throw makeRuntimeErrorMsg("connect", `Invalid hostname: '${hostname}'`);
|
throw makeRuntimeErrorMsg("connect", `Invalid hostname: '${hostname}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const target = getServer(hostname);
|
const target = GetServer(hostname);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
throw makeRuntimeErrorMsg("connect", `Invalid hostname: '${hostname}'`);
|
throw makeRuntimeErrorMsg("connect", `Invalid hostname: '${hostname}'`);
|
||||||
return;
|
return;
|
||||||
@ -3047,7 +3029,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
|
|
||||||
if (hostname === "home") {
|
if (hostname === "home") {
|
||||||
Player.getCurrentServer().isConnectedTo = false;
|
Player.getCurrentServer().isConnectedTo = false;
|
||||||
Player.currentServer = Player.getHomeComputer().ip;
|
Player.currentServer = Player.getHomeComputer().hostname;
|
||||||
Player.getCurrentServer().isConnectedTo = true;
|
Player.getCurrentServer().isConnectedTo = true;
|
||||||
Terminal.setcwd("/");
|
Terminal.setcwd("/");
|
||||||
return true;
|
return true;
|
||||||
@ -3057,9 +3039,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
for (let i = 0; i < server.serversOnNetwork.length; i++) {
|
for (let i = 0; i < server.serversOnNetwork.length; i++) {
|
||||||
const other = getServerOnNetwork(server, i);
|
const other = getServerOnNetwork(server, i);
|
||||||
if (other === null) continue;
|
if (other === null) continue;
|
||||||
if (other.ip == hostname || other.hostname == hostname) {
|
if (other.hostname == hostname) {
|
||||||
Player.getCurrentServer().isConnectedTo = false;
|
Player.getCurrentServer().isConnectedTo = false;
|
||||||
Player.currentServer = target.ip;
|
Player.currentServer = target.hostname;
|
||||||
Player.getCurrentServer().isConnectedTo = true;
|
Player.getCurrentServer().isConnectedTo = true;
|
||||||
Terminal.setcwd("/");
|
Terminal.setcwd("/");
|
||||||
return true;
|
return true;
|
||||||
@ -3152,7 +3134,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
workMoney: Player.work_money_mult,
|
workMoney: Player.work_money_mult,
|
||||||
},
|
},
|
||||||
timeWorked: Player.timeWorked,
|
timeWorked: Player.timeWorked,
|
||||||
tor: SpecialServerIps.hasOwnProperty("Darkweb Server"),
|
tor: Player.hasTorRouter(),
|
||||||
workHackExpGain: Player.workHackExpGained,
|
workHackExpGain: Player.workHackExpGained,
|
||||||
workStrExpGain: Player.workStrExpGained,
|
workStrExpGain: Player.workStrExpGained,
|
||||||
workDefExpGain: Player.workDefExpGained,
|
workDefExpGain: Player.workDefExpGained,
|
||||||
@ -3258,7 +3240,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
playtimeSinceLastBitnode: Player.playtimeSinceLastBitnode,
|
playtimeSinceLastBitnode: Player.playtimeSinceLastBitnode,
|
||||||
jobs: {},
|
jobs: {},
|
||||||
factions: Player.factions.slice(),
|
factions: Player.factions.slice(),
|
||||||
tor: SpecialServerIps.hasOwnProperty("Darkweb Server"),
|
tor: Player.hasTorRouter(),
|
||||||
};
|
};
|
||||||
Object.assign(data.jobs, Player.jobs);
|
Object.assign(data.jobs, Player.jobs);
|
||||||
return data;
|
return data;
|
||||||
@ -4413,7 +4395,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
|
|
||||||
// Coding Contract API
|
// Coding Contract API
|
||||||
codingcontract: {
|
codingcontract: {
|
||||||
attempt: function (answer: any, fn: any, ip: any = workerScript.serverIp, { returnReward }: any = {}): any {
|
attempt: function (answer: any, fn: any, ip: any = workerScript.hostname, { returnReward }: any = {}): any {
|
||||||
updateDynamicRam("attempt", getRamCost("codingcontract", "attempt"));
|
updateDynamicRam("attempt", getRamCost("codingcontract", "attempt"));
|
||||||
const contract = getCodingContract("attempt", ip, fn);
|
const contract = getCodingContract("attempt", ip, fn);
|
||||||
|
|
||||||
@ -4456,12 +4438,12 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return returnReward ? "" : false;
|
return returnReward ? "" : false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getContractType: function (fn: any, ip: any = workerScript.serverIp): any {
|
getContractType: function (fn: any, ip: any = workerScript.hostname): any {
|
||||||
updateDynamicRam("getContractType", getRamCost("codingcontract", "getContractType"));
|
updateDynamicRam("getContractType", getRamCost("codingcontract", "getContractType"));
|
||||||
const contract = getCodingContract("getContractType", ip, fn);
|
const contract = getCodingContract("getContractType", ip, fn);
|
||||||
return contract.getType();
|
return contract.getType();
|
||||||
},
|
},
|
||||||
getData: function (fn: any, ip: any = workerScript.serverIp): any {
|
getData: function (fn: any, ip: any = workerScript.hostname): any {
|
||||||
updateDynamicRam("getData", getRamCost("codingcontract", "getData"));
|
updateDynamicRam("getData", getRamCost("codingcontract", "getData"));
|
||||||
const contract = getCodingContract("getData", ip, fn);
|
const contract = getCodingContract("getData", ip, fn);
|
||||||
const data = contract.getData();
|
const data = contract.getData();
|
||||||
@ -4481,12 +4463,12 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getDescription: function (fn: any, ip: any = workerScript.serverIp): any {
|
getDescription: function (fn: any, ip: any = workerScript.hostname): any {
|
||||||
updateDynamicRam("getDescription", getRamCost("codingcontract", "getDescription"));
|
updateDynamicRam("getDescription", getRamCost("codingcontract", "getDescription"));
|
||||||
const contract = getCodingContract("getDescription", ip, fn);
|
const contract = getCodingContract("getDescription", ip, fn);
|
||||||
return contract.getDescription();
|
return contract.getDescription();
|
||||||
},
|
},
|
||||||
getNumTriesRemaining: function (fn: any, ip: any = workerScript.serverIp): any {
|
getNumTriesRemaining: function (fn: any, ip: any = workerScript.hostname): any {
|
||||||
updateDynamicRam("getNumTriesRemaining", getRamCost("codingcontract", "getNumTriesRemaining"));
|
updateDynamicRam("getNumTriesRemaining", getRamCost("codingcontract", "getNumTriesRemaining"));
|
||||||
const contract = getCodingContract("getNumTriesRemaining", ip, fn);
|
const contract = getCodingContract("getNumTriesRemaining", ip, fn);
|
||||||
return contract.getMaxNumTries() - contract.tries;
|
return contract.getMaxNumTries() - contract.tries;
|
||||||
|
@ -16,7 +16,7 @@ import {
|
|||||||
} from "../Hacknet/HacknetHelpers";
|
} from "../Hacknet/HacknetHelpers";
|
||||||
import { HacknetServer } from "../Hacknet/HacknetServer";
|
import { HacknetServer } from "../Hacknet/HacknetServer";
|
||||||
import { HacknetNode } from "../Hacknet/HacknetNode";
|
import { HacknetNode } from "../Hacknet/HacknetNode";
|
||||||
import { AllServers } from "../Server/AllServers";
|
import { GetServer } from "../Server/AllServers";
|
||||||
|
|
||||||
export interface INetscriptHacknet {
|
export interface INetscriptHacknet {
|
||||||
numNodes(): number;
|
numNodes(): number;
|
||||||
@ -58,7 +58,7 @@ export function NetscriptHacknet(
|
|||||||
if (hasHacknetServers(player)) {
|
if (hasHacknetServers(player)) {
|
||||||
const hi = player.hacknetNodes[i];
|
const hi = player.hacknetNodes[i];
|
||||||
if (typeof hi !== "string") throw new Error("hacknet node was not a string");
|
if (typeof hi !== "string") throw new Error("hacknet node was not a string");
|
||||||
const hserver = AllServers[hi];
|
const hserver = GetServer(hi);
|
||||||
if (!(hserver instanceof HacknetServer)) throw new Error("hacknet server was not actually hacknet server");
|
if (!(hserver instanceof HacknetServer)) throw new Error("hacknet server was not actually hacknet server");
|
||||||
if (hserver == null) {
|
if (hserver == null) {
|
||||||
throw helper.makeRuntimeErrorMsg(
|
throw helper.makeRuntimeErrorMsg(
|
||||||
|
@ -4,7 +4,6 @@ import { getRamCost } from "../Netscript/RamCostGenerator";
|
|||||||
import { FactionWorkType } from "../Faction/FactionWorkTypeEnum";
|
import { FactionWorkType } from "../Faction/FactionWorkTypeEnum";
|
||||||
import { SourceFileFlags } from "../SourceFile/SourceFileFlags";
|
import { SourceFileFlags } from "../SourceFile/SourceFileFlags";
|
||||||
import { SleeveTaskType } from "../PersonObjects/Sleeve/SleeveTaskTypesEnum";
|
import { SleeveTaskType } from "../PersonObjects/Sleeve/SleeveTaskTypesEnum";
|
||||||
import { SpecialServerIps } from "../Server/SpecialServerIps";
|
|
||||||
import { WorkerScript } from "../Netscript/WorkerScript";
|
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||||
import { findSleevePurchasableAugs } from "../PersonObjects/Sleeve/SleeveHelpers";
|
import { findSleevePurchasableAugs } from "../PersonObjects/Sleeve/SleeveHelpers";
|
||||||
import { Augmentations } from "../Augmentation/Augmentations";
|
import { Augmentations } from "../Augmentation/Augmentations";
|
||||||
@ -231,7 +230,6 @@ export function NetscriptSleeve(
|
|||||||
jobs: Object.keys(player.jobs), // technically sleeves have the same jobs as the player.
|
jobs: Object.keys(player.jobs), // technically sleeves have the same jobs as the player.
|
||||||
jobTitle: Object.values(player.jobs),
|
jobTitle: Object.values(player.jobs),
|
||||||
maxHp: sl.max_hp,
|
maxHp: sl.max_hp,
|
||||||
tor: SpecialServerIps.hasOwnProperty("Darkweb Server"), // There's no reason not to give that infomation here as well. Worst case scenario it isn't used.
|
|
||||||
|
|
||||||
mult: {
|
mult: {
|
||||||
agility: sl.agility_mult,
|
agility: sl.agility_mult,
|
||||||
|
@ -18,7 +18,7 @@ import { RunningScript } from "./Script/RunningScript";
|
|||||||
import { getRamUsageFromRunningScript } from "./Script/RunningScriptHelpers";
|
import { getRamUsageFromRunningScript } from "./Script/RunningScriptHelpers";
|
||||||
import { scriptCalculateOfflineProduction } from "./Script/ScriptHelpers";
|
import { scriptCalculateOfflineProduction } from "./Script/ScriptHelpers";
|
||||||
import { Script } from "./Script/Script";
|
import { Script } from "./Script/Script";
|
||||||
import { AllServers } from "./Server/AllServers";
|
import { GetAllServers } from "./Server/AllServers";
|
||||||
import { BaseServer } from "./Server/BaseServer";
|
import { BaseServer } from "./Server/BaseServer";
|
||||||
import { Settings } from "./Settings/Settings";
|
import { Settings } from "./Settings/Settings";
|
||||||
|
|
||||||
@ -544,11 +544,11 @@ export function createAndAddWorkerScript(
|
|||||||
console.error("Error text: " + w.errorMessage);
|
console.error("Error text: " + w.errorMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const serverIp = errorTextArray[1];
|
const hostname = errorTextArray[1];
|
||||||
const scriptName = errorTextArray[2];
|
const scriptName = errorTextArray[2];
|
||||||
const errorMsg = errorTextArray[3];
|
const errorMsg = errorTextArray[3];
|
||||||
|
|
||||||
let msg = `RUNTIME ERROR<br>${scriptName}@${serverIp}<br>`;
|
let msg = `RUNTIME ERROR<br>${scriptName}@${hostname}<br>`;
|
||||||
if (w.args.length > 0) {
|
if (w.args.length > 0) {
|
||||||
msg += `Args: ${arrayToString(w.args)}<br>`;
|
msg += `Args: ${arrayToString(w.args)}<br>`;
|
||||||
}
|
}
|
||||||
@ -600,28 +600,24 @@ export function loadAllRunningScripts(): void {
|
|||||||
if (skipScriptLoad) {
|
if (skipScriptLoad) {
|
||||||
console.info("Skipping the load of any scripts during startup");
|
console.info("Skipping the load of any scripts during startup");
|
||||||
}
|
}
|
||||||
for (const property in AllServers) {
|
for (const server of GetAllServers()) {
|
||||||
if (AllServers.hasOwnProperty(property)) {
|
// Reset each server's RAM usage to 0
|
||||||
const server = AllServers[property];
|
server.ramUsed = 0;
|
||||||
|
|
||||||
// Reset each server's RAM usage to 0
|
// Reset modules on all scripts
|
||||||
server.ramUsed = 0;
|
for (let i = 0; i < server.scripts.length; ++i) {
|
||||||
|
server.scripts[i].markUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
// Reset modules on all scripts
|
if (skipScriptLoad) {
|
||||||
for (let i = 0; i < server.scripts.length; ++i) {
|
// Start game with no scripts
|
||||||
server.scripts[i].markUpdated();
|
server.runningScripts.length = 0;
|
||||||
}
|
} else {
|
||||||
|
for (let j = 0; j < server.runningScripts.length; ++j) {
|
||||||
|
createAndAddWorkerScript(server.runningScripts[j], server);
|
||||||
|
|
||||||
if (skipScriptLoad) {
|
// Offline production
|
||||||
// Start game with no scripts
|
scriptCalculateOfflineProduction(server.runningScripts[j]);
|
||||||
server.runningScripts.length = 0;
|
|
||||||
} else {
|
|
||||||
for (let j = 0; j < server.runningScripts.length; ++j) {
|
|
||||||
createAndAddWorkerScript(server.runningScripts[j], server);
|
|
||||||
|
|
||||||
// Offline production
|
|
||||||
scriptCalculateOfflineProduction(server.runningScripts[j]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import { HashManager } from "../Hacknet/HashManager";
|
|||||||
import { HacknetNode } from "../Hacknet/HacknetNode";
|
import { HacknetNode } from "../Hacknet/HacknetNode";
|
||||||
import { LocationName } from "../Locations/data/LocationNames";
|
import { LocationName } from "../Locations/data/LocationNames";
|
||||||
import { Server } from "../Server/Server";
|
import { Server } from "../Server/Server";
|
||||||
|
import { BaseServer } from "../Server/BaseServer";
|
||||||
import { IPlayerOwnedSourceFile } from "../SourceFile/PlayerOwnedSourceFile";
|
import { IPlayerOwnedSourceFile } from "../SourceFile/PlayerOwnedSourceFile";
|
||||||
import { MoneySourceTracker } from "../utils/MoneySourceTracker";
|
import { MoneySourceTracker } from "../utils/MoneySourceTracker";
|
||||||
import { Exploit } from "../Exploits/Exploit";
|
import { Exploit } from "../Exploits/Exploit";
|
||||||
@ -47,7 +48,6 @@ export interface IPlayer {
|
|||||||
hashManager: HashManager;
|
hashManager: HashManager;
|
||||||
hasTixApiAccess: boolean;
|
hasTixApiAccess: boolean;
|
||||||
hasWseAccount: boolean;
|
hasWseAccount: boolean;
|
||||||
homeComputer: string;
|
|
||||||
hp: number;
|
hp: number;
|
||||||
jobs: IMap<string>;
|
jobs: IMap<string>;
|
||||||
init: () => void;
|
init: () => void;
|
||||||
@ -185,7 +185,7 @@ export interface IPlayer {
|
|||||||
gainCharismaExp(exp: number): void;
|
gainCharismaExp(exp: number): void;
|
||||||
gainIntelligenceExp(exp: number): void;
|
gainIntelligenceExp(exp: number): void;
|
||||||
gainMoney(money: number): void;
|
gainMoney(money: number): void;
|
||||||
getCurrentServer(): Server | HacknetServer;
|
getCurrentServer(): BaseServer;
|
||||||
getGangFaction(): Faction;
|
getGangFaction(): Faction;
|
||||||
getGangName(): string;
|
getGangName(): string;
|
||||||
getHomeComputer(): Server;
|
getHomeComputer(): Server;
|
||||||
|
@ -13,6 +13,7 @@ import { Exploit } from "../../Exploits/Exploit";
|
|||||||
import { WorkerScript } from "../../Netscript/WorkerScript";
|
import { WorkerScript } from "../../Netscript/WorkerScript";
|
||||||
import { CompanyPosition } from "../../Company/CompanyPosition";
|
import { CompanyPosition } from "../../Company/CompanyPosition";
|
||||||
import { Server } from "../../Server/Server";
|
import { Server } from "../../Server/Server";
|
||||||
|
import { BaseServer } from "../../Server/BaseServer";
|
||||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
||||||
import { Faction } from "../../Faction/Faction";
|
import { Faction } from "../../Faction/Faction";
|
||||||
import { Company } from "../../Company/Company";
|
import { Company } from "../../Company/Company";
|
||||||
@ -54,7 +55,6 @@ export class PlayerObject implements IPlayer {
|
|||||||
hashManager: HashManager;
|
hashManager: HashManager;
|
||||||
hasTixApiAccess: boolean;
|
hasTixApiAccess: boolean;
|
||||||
hasWseAccount: boolean;
|
hasWseAccount: boolean;
|
||||||
homeComputer: string;
|
|
||||||
hp: number;
|
hp: number;
|
||||||
jobs: IMap<string>;
|
jobs: IMap<string>;
|
||||||
init: () => void;
|
init: () => void;
|
||||||
@ -192,7 +192,7 @@ export class PlayerObject implements IPlayer {
|
|||||||
gainCharismaExp: (exp: number) => void;
|
gainCharismaExp: (exp: number) => void;
|
||||||
gainIntelligenceExp: (exp: number) => void;
|
gainIntelligenceExp: (exp: number) => void;
|
||||||
gainMoney: (money: number) => void;
|
gainMoney: (money: number) => void;
|
||||||
getCurrentServer: () => Server | HacknetServer;
|
getCurrentServer: () => BaseServer;
|
||||||
getGangFaction: () => Faction;
|
getGangFaction: () => Faction;
|
||||||
getGangName: () => string;
|
getGangName: () => string;
|
||||||
getHomeComputer: () => Server;
|
getHomeComputer: () => Server;
|
||||||
@ -335,9 +335,6 @@ export class PlayerObject implements IPlayer {
|
|||||||
//Money
|
//Money
|
||||||
this.money = new Decimal(1000);
|
this.money = new Decimal(1000);
|
||||||
|
|
||||||
//IP Address of Starting (home) computer
|
|
||||||
this.homeComputer = "";
|
|
||||||
|
|
||||||
//Location information
|
//Location information
|
||||||
this.city = CityName.Sector12;
|
this.city = CityName.Sector12;
|
||||||
this.location = LocationName.TravelAgency;
|
this.location = LocationName.TravelAgency;
|
||||||
|
@ -32,11 +32,11 @@ import {
|
|||||||
getFactionSecurityWorkRepGain,
|
getFactionSecurityWorkRepGain,
|
||||||
getFactionFieldWorkRepGain,
|
getFactionFieldWorkRepGain,
|
||||||
} from "../formulas/reputation";
|
} from "../formulas/reputation";
|
||||||
import { AllServers, AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers";
|
import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers";
|
||||||
import { Server } from "../../Server/Server";
|
import { Server } from "../../Server/Server";
|
||||||
import { safetlyCreateUniqueServer } from "../../Server/ServerHelpers";
|
import { safetlyCreateUniqueServer } from "../../Server/ServerHelpers";
|
||||||
import { Settings } from "../../Settings/Settings";
|
import { Settings } from "../../Settings/Settings";
|
||||||
import { SpecialServerIps, SpecialServerNames } from "../../Server/SpecialServerIps";
|
import { SpecialServers } from "../../Server/data/SpecialServers";
|
||||||
import { applySourceFile } from "../../SourceFile/applySourceFile";
|
import { applySourceFile } from "../../SourceFile/applySourceFile";
|
||||||
import { applyExploit } from "../../Exploits/applyExploits";
|
import { applyExploit } from "../../Exploits/applyExploits";
|
||||||
import { SourceFiles } from "../../SourceFile/SourceFiles";
|
import { SourceFiles } from "../../SourceFile/SourceFiles";
|
||||||
@ -44,6 +44,7 @@ import { SourceFileFlags } from "../../SourceFile/SourceFileFlags";
|
|||||||
import { influenceStockThroughCompanyWork } from "../../StockMarket/PlayerInfluencing";
|
import { influenceStockThroughCompanyWork } from "../../StockMarket/PlayerInfluencing";
|
||||||
import { getHospitalizationCost } from "../../Hospital/Hospital";
|
import { getHospitalizationCost } from "../../Hospital/Hospital";
|
||||||
import { WorkerScript } from "../../Netscript/WorkerScript";
|
import { WorkerScript } from "../../Netscript/WorkerScript";
|
||||||
|
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
||||||
|
|
||||||
import Decimal from "decimal.js";
|
import Decimal from "decimal.js";
|
||||||
|
|
||||||
@ -69,8 +70,7 @@ export function init(this: IPlayer): void {
|
|||||||
organizationName: "Home PC",
|
organizationName: "Home PC",
|
||||||
purchasedByPlayer: true,
|
purchasedByPlayer: true,
|
||||||
});
|
});
|
||||||
this.homeComputer = t_homeComp.ip;
|
this.currentServer = SpecialServers.Home;
|
||||||
this.currentServer = t_homeComp.ip;
|
|
||||||
AddToAllServers(t_homeComp);
|
AddToAllServers(t_homeComp);
|
||||||
|
|
||||||
this.getHomeComputer().programs.push(Programs.NukeProgram.name);
|
this.getHomeComputer().programs.push(Programs.NukeProgram.name);
|
||||||
@ -78,8 +78,7 @@ export function init(this: IPlayer): void {
|
|||||||
|
|
||||||
export function prestigeAugmentation(this: IPlayer): void {
|
export function prestigeAugmentation(this: IPlayer): void {
|
||||||
const homeComp = this.getHomeComputer();
|
const homeComp = this.getHomeComputer();
|
||||||
this.currentServer = homeComp.ip;
|
this.currentServer = SpecialServers.Home;
|
||||||
this.homeComputer = homeComp.ip;
|
|
||||||
|
|
||||||
this.numPeopleKilled = 0;
|
this.numPeopleKilled = 0;
|
||||||
this.karma = 0;
|
this.karma = 0;
|
||||||
@ -576,13 +575,11 @@ export function startWork(this: IPlayer, router: IRouter, companyName: string):
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function cancelationPenalty(this: IPlayer): number {
|
export function cancelationPenalty(this: IPlayer): number {
|
||||||
const specialIp = SpecialServerIps[this.companyName];
|
const server = GetServer(this.companyName);
|
||||||
if (typeof specialIp === "string" && specialIp !== "") {
|
if (server instanceof Server) {
|
||||||
const server = AllServers[specialIp];
|
if (server && server.backdoorInstalled) return 0.75;
|
||||||
if (server instanceof Server) {
|
|
||||||
if (server && server.backdoorInstalled) return 0.75;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.5;
|
return 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2191,9 +2188,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
|
|
||||||
//Fulcrum Secret Technologies - If u've unlocked fulcrum secret technolgoies server and have a high rep with the company
|
//Fulcrum Secret Technologies - If u've unlocked fulcrum secret technolgoies server and have a high rep with the company
|
||||||
const fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"];
|
const fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"];
|
||||||
const fulcrumIP = SpecialServerIps[SpecialServerNames.BitRunnersServer];
|
const fulcrumSecretServer = GetServer(SpecialServers.FulcrumSecretTechnologies);
|
||||||
if (typeof fulcrumIP !== "string") throw new Error("Fulcrum Secret Technologies should be string");
|
|
||||||
const fulcrumSecretServer = AllServers[fulcrumIP];
|
|
||||||
if (!(fulcrumSecretServer instanceof Server)) throw new Error("Fulcrum Secret Technologies should be normal server");
|
if (!(fulcrumSecretServer instanceof Server)) throw new Error("Fulcrum Secret Technologies should be normal server");
|
||||||
if (fulcrumSecretServer == null) {
|
if (fulcrumSecretServer == null) {
|
||||||
console.error("Could not find Fulcrum Secret Technologies Server");
|
console.error("Could not find Fulcrum Secret Technologies Server");
|
||||||
@ -2211,9 +2206,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
|
|
||||||
//BitRunners
|
//BitRunners
|
||||||
const bitrunnersFac = Factions["BitRunners"];
|
const bitrunnersFac = Factions["BitRunners"];
|
||||||
const bitrunnerIP = SpecialServerIps[SpecialServerNames.BitRunnersServer];
|
const bitrunnersServer = GetServer(SpecialServers.BitRunnersServer);
|
||||||
if (typeof bitrunnerIP !== "string") throw new Error("BitRunners should be string");
|
|
||||||
const bitrunnersServer = AllServers[bitrunnerIP];
|
|
||||||
if (!(bitrunnersServer instanceof Server)) throw new Error("BitRunners should be normal server");
|
if (!(bitrunnersServer instanceof Server)) throw new Error("BitRunners should be normal server");
|
||||||
if (bitrunnersServer == null) {
|
if (bitrunnersServer == null) {
|
||||||
console.error("Could not find BitRunners Server");
|
console.error("Could not find BitRunners Server");
|
||||||
@ -2229,9 +2222,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
//The Black Hand
|
//The Black Hand
|
||||||
|
|
||||||
const theblackhandFac = Factions["The Black Hand"];
|
const theblackhandFac = Factions["The Black Hand"];
|
||||||
const tbhIP = SpecialServerIps[SpecialServerNames.TheBlackHandServer];
|
const blackhandServer = GetServer(SpecialServers.TheBlackHandServer);
|
||||||
if (typeof tbhIP !== "string") throw new Error("TheBlackHand should be string");
|
|
||||||
const blackhandServer = AllServers[tbhIP];
|
|
||||||
if (!(blackhandServer instanceof Server)) throw new Error("TheBlackHand should be normal server");
|
if (!(blackhandServer instanceof Server)) throw new Error("TheBlackHand should be normal server");
|
||||||
if (blackhandServer == null) {
|
if (blackhandServer == null) {
|
||||||
console.error("Could not find The Black Hand Server");
|
console.error("Could not find The Black Hand Server");
|
||||||
@ -2246,9 +2237,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
|
|
||||||
//NiteSec
|
//NiteSec
|
||||||
const nitesecFac = Factions["NiteSec"];
|
const nitesecFac = Factions["NiteSec"];
|
||||||
const nitesecIP = SpecialServerIps[SpecialServerNames.NiteSecServer];
|
const nitesecServer = GetServer(SpecialServers.NiteSecServer);
|
||||||
if (typeof nitesecIP !== "string") throw new Error("NiteSec should be string");
|
|
||||||
const nitesecServer = AllServers[nitesecIP];
|
|
||||||
if (!(nitesecServer instanceof Server)) throw new Error("NiteSec should be normal server");
|
if (!(nitesecServer instanceof Server)) throw new Error("NiteSec should be normal server");
|
||||||
if (nitesecServer == null) {
|
if (nitesecServer == null) {
|
||||||
console.error("Could not find NiteSec Server");
|
console.error("Could not find NiteSec Server");
|
||||||
@ -2447,8 +2436,9 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
for (let i = 0; i < this.hacknetNodes.length; ++i) {
|
for (let i = 0; i < this.hacknetNodes.length; ++i) {
|
||||||
const v = this.hacknetNodes[i];
|
const v = this.hacknetNodes[i];
|
||||||
if (typeof v === "string") {
|
if (typeof v === "string") {
|
||||||
const hserver = AllServers[v];
|
const hserver = GetServer(v);
|
||||||
if (hserver instanceof Server) throw new Error("player hacknet server was not HacknetServer");
|
if (hserver === null || !(hserver instanceof HacknetServer))
|
||||||
|
throw new Error("player hacknet server was not HacknetServer");
|
||||||
totalHacknetLevels += hserver.level;
|
totalHacknetLevels += hserver.level;
|
||||||
totalHacknetRam += hserver.maxRam;
|
totalHacknetRam += hserver.maxRam;
|
||||||
totalHacknetCores += hserver.cores;
|
totalHacknetCores += hserver.cores;
|
||||||
@ -2485,9 +2475,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
|
|
||||||
//CyberSec
|
//CyberSec
|
||||||
const cybersecFac = Factions["CyberSec"];
|
const cybersecFac = Factions["CyberSec"];
|
||||||
const cyberSecIP = SpecialServerIps[SpecialServerNames.CyberSecServer];
|
const cybersecServer = GetServer(SpecialServers.CyberSecServer);
|
||||||
if (typeof cyberSecIP !== "string") throw new Error("cybersec should be string");
|
|
||||||
const cybersecServer = AllServers[cyberSecIP];
|
|
||||||
if (!(cybersecServer instanceof Server)) throw new Error("cybersec should be normal server");
|
if (!(cybersecServer instanceof Server)) throw new Error("cybersec should be normal server");
|
||||||
if (cybersecServer == null) {
|
if (cybersecServer == null) {
|
||||||
console.error("Could not find CyberSec Server");
|
console.error("Could not find CyberSec Server");
|
||||||
|
@ -7,22 +7,23 @@ import { CONSTANTS } from "../../Constants";
|
|||||||
|
|
||||||
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||||
import { Server } from "../../Server/Server";
|
import { Server } from "../../Server/Server";
|
||||||
|
import { BaseServer } from "../../Server/BaseServer";
|
||||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
||||||
import { AddToAllServers, AllServers, createUniqueRandomIp } from "../../Server/AllServers";
|
import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers";
|
||||||
import { SpecialServerIps } from "../../Server/SpecialServerIps";
|
import { SpecialServers } from "../../Server/data/SpecialServers";
|
||||||
|
|
||||||
export function hasTorRouter(this: IPlayer): boolean {
|
export function hasTorRouter(this: IPlayer): boolean {
|
||||||
return SpecialServerIps.hasOwnProperty("Darkweb Server");
|
return !!GetServer(SpecialServers.DarkWeb);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCurrentServer(this: IPlayer): Server | HacknetServer {
|
export function getCurrentServer(this: IPlayer): BaseServer {
|
||||||
const server = AllServers[this.currentServer];
|
const server = GetServer(this.currentServer);
|
||||||
if (server === null) throw new Error("somehow connected to a server that does not exist.");
|
if (server === null) throw new Error("somehow connected to a server that does not exist.");
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getHomeComputer(this: IPlayer): Server {
|
export function getHomeComputer(this: IPlayer): Server {
|
||||||
const home = AllServers[this.homeComputer];
|
const home = GetServer("home");
|
||||||
if (home instanceof Server) return home;
|
if (home instanceof Server) return home;
|
||||||
throw new Error("home computer was not a normal server");
|
throw new Error("home computer was not a normal server");
|
||||||
}
|
}
|
||||||
@ -48,13 +49,13 @@ export function createHacknetServer(this: IPlayer): HacknetServer {
|
|||||||
ip: createUniqueRandomIp(),
|
ip: createUniqueRandomIp(),
|
||||||
// player: this,
|
// player: this,
|
||||||
});
|
});
|
||||||
this.hacknetNodes.push(server.ip);
|
this.hacknetNodes.push(server.hostname);
|
||||||
|
|
||||||
// Configure the HacknetServer to actually act as a Server
|
// Configure the HacknetServer to actually act as a Server
|
||||||
AddToAllServers(server);
|
AddToAllServers(server);
|
||||||
const homeComputer = this.getHomeComputer();
|
const homeComputer = this.getHomeComputer();
|
||||||
homeComputer.serversOnNetwork.push(server.ip);
|
homeComputer.serversOnNetwork.push(server.hostname);
|
||||||
server.serversOnNetwork.push(homeComputer.ip);
|
server.serversOnNetwork.push(SpecialServers.Home);
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,10 @@ import { Router } from "./ui/GameRoot";
|
|||||||
import { resetPidCounter } from "./Netscript/Pid";
|
import { resetPidCounter } from "./Netscript/Pid";
|
||||||
import { LiteratureNames } from "./Literature/data/LiteratureNames";
|
import { LiteratureNames } from "./Literature/data/LiteratureNames";
|
||||||
|
|
||||||
import { AllServers, AddToAllServers, initForeignServers, prestigeAllServers } from "./Server/AllServers";
|
import { GetServer, AddToAllServers, initForeignServers, prestigeAllServers } from "./Server/AllServers";
|
||||||
import { prestigeHomeComputer } from "./Server/ServerHelpers";
|
import { prestigeHomeComputer } from "./Server/ServerHelpers";
|
||||||
import { SourceFileFlags, updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
|
import { SourceFileFlags, updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||||
import { SpecialServerIps, prestigeSpecialServerIps, SpecialServerNames } from "./Server/SpecialServerIps";
|
import { SpecialServers } from "./Server/data/SpecialServers";
|
||||||
import { deleteStockMarket, initStockMarket, initSymbolToStockMap } from "./StockMarket/StockMarket";
|
import { deleteStockMarket, initStockMarket, initSymbolToStockMap } from "./StockMarket/StockMarket";
|
||||||
import { Terminal } from "./Terminal";
|
import { Terminal } from "./Terminal";
|
||||||
|
|
||||||
@ -46,9 +46,6 @@ function prestigeAugmentation(): void {
|
|||||||
// Delete all servers except home computer
|
// Delete all servers except home computer
|
||||||
prestigeAllServers();
|
prestigeAllServers();
|
||||||
|
|
||||||
// Delete Special Server IPs
|
|
||||||
prestigeSpecialServerIps(); // Must be done before initForeignServers()
|
|
||||||
|
|
||||||
// Reset home computer (only the programs) and add to AllServers
|
// Reset home computer (only the programs) and add to AllServers
|
||||||
AddToAllServers(homeComp);
|
AddToAllServers(homeComp);
|
||||||
prestigeHomeComputer(homeComp);
|
prestigeHomeComputer(homeComp);
|
||||||
@ -87,6 +84,7 @@ function prestigeAugmentation(): void {
|
|||||||
if (Terminal.action !== null) {
|
if (Terminal.action !== null) {
|
||||||
Terminal.finishAction(Router, Player, true);
|
Terminal.finishAction(Router, Player, true);
|
||||||
}
|
}
|
||||||
|
Terminal.clear();
|
||||||
|
|
||||||
// Re-initialize things - This will update any changes
|
// Re-initialize things - This will update any changes
|
||||||
initFactions(); // Factions must be initialized before augmentations
|
initFactions(); // Factions must be initialized before augmentations
|
||||||
@ -131,15 +129,11 @@ function prestigeAugmentation(): void {
|
|||||||
|
|
||||||
// Red Pill
|
// Red Pill
|
||||||
if (augmentationExists(AugmentationNames.TheRedPill) && Augmentations[AugmentationNames.TheRedPill].owned) {
|
if (augmentationExists(AugmentationNames.TheRedPill) && Augmentations[AugmentationNames.TheRedPill].owned) {
|
||||||
const WorldDaemonIP = SpecialServerIps[SpecialServerNames.WorldDaemon];
|
const WorldDaemon = GetServer(SpecialServers.WorldDaemon);
|
||||||
if (typeof WorldDaemonIP !== "string") throw new Error("WorldDaemonIP should be string");
|
const DaedalusServer = GetServer(SpecialServers.DaedalusServer);
|
||||||
const WorldDaemon = AllServers[WorldDaemonIP];
|
|
||||||
const DaedalusServerIP = SpecialServerIps[SpecialServerNames.DaedalusServer];
|
|
||||||
if (typeof DaedalusServerIP !== "string") throw new Error("DaedalusServerIP should be string");
|
|
||||||
const DaedalusServer = AllServers[DaedalusServerIP];
|
|
||||||
if (WorldDaemon && DaedalusServer) {
|
if (WorldDaemon && DaedalusServer) {
|
||||||
WorldDaemon.serversOnNetwork.push(DaedalusServer.ip);
|
WorldDaemon.serversOnNetwork.push(DaedalusServer.hostname);
|
||||||
DaedalusServer.serversOnNetwork.push(WorldDaemon.ip);
|
DaedalusServer.serversOnNetwork.push(WorldDaemon.hostname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,9 +153,6 @@ function prestigeSourceFile(flume: boolean): void {
|
|||||||
// Delete all servers except home computer
|
// Delete all servers except home computer
|
||||||
prestigeAllServers(); // Must be done before initForeignServers()
|
prestigeAllServers(); // Must be done before initForeignServers()
|
||||||
|
|
||||||
// Delete Special Server IPs
|
|
||||||
prestigeSpecialServerIps();
|
|
||||||
|
|
||||||
// Reset home computer (only the programs) and add to AllServers
|
// Reset home computer (only the programs) and add to AllServers
|
||||||
AddToAllServers(homeComp);
|
AddToAllServers(homeComp);
|
||||||
prestigeHomeComputer(homeComp);
|
prestigeHomeComputer(homeComp);
|
||||||
|
@ -5,9 +5,8 @@ import { Server } from "../../Server/Server";
|
|||||||
import { ITerminal } from "../../Terminal/ITerminal";
|
import { ITerminal } from "../../Terminal/ITerminal";
|
||||||
import { IRouter } from "../../ui/Router";
|
import { IRouter } from "../../ui/Router";
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
|
||||||
import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions";
|
import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions";
|
||||||
import { getServer } from "../../Server/ServerHelpers";
|
import { GetServer } from "../../Server/AllServers";
|
||||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||||
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||||
import { BitFlumeEvent } from "../../BitNode/ui/BitFlumeModal";
|
import { BitFlumeEvent } from "../../BitNode/ui/BitFlumeModal";
|
||||||
@ -224,14 +223,14 @@ export const programsMetadata: IProgramCreationParams[] = [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetServer = getServer(args[0]);
|
const targetServer = GetServer(args[0]);
|
||||||
if (targetServer == null) {
|
if (targetServer == null) {
|
||||||
terminal.print("Invalid server IP/hostname");
|
terminal.print("Invalid server IP/hostname");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetServer instanceof HacknetServer) {
|
if (!(targetServer instanceof Server)) {
|
||||||
terminal.print(`ServerProfiler.exe cannot be run on a Hacknet Server.`);
|
terminal.print(`ServerProfiler.exe can only be run on normal servers.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,8 @@ import { Factions, loadFactions } from "./Faction/Factions";
|
|||||||
import { loadAllGangs, AllGangs } from "./Gang/AllGangs";
|
import { loadAllGangs, AllGangs } from "./Gang/AllGangs";
|
||||||
import { loadMessages, initMessages, Messages } from "./Message/MessageHelpers";
|
import { loadMessages, initMessages, Messages } from "./Message/MessageHelpers";
|
||||||
import { Player, loadPlayer } from "./Player";
|
import { Player, loadPlayer } from "./Player";
|
||||||
import { AllServers, loadAllServers } from "./Server/AllServers";
|
import { saveAllServers, loadAllServers } from "./Server/AllServers";
|
||||||
import { Settings } from "./Settings/Settings";
|
import { Settings } from "./Settings/Settings";
|
||||||
import { loadSpecialServerIps, SpecialServerIps } from "./Server/SpecialServerIps";
|
|
||||||
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
|
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||||
import { loadStockMarket, StockMarket } from "./StockMarket/StockMarket";
|
import { loadStockMarket, StockMarket } from "./StockMarket/StockMarket";
|
||||||
|
|
||||||
@ -28,7 +27,6 @@ class BitburnerSaveObject {
|
|||||||
AllServersSave = "";
|
AllServersSave = "";
|
||||||
CompaniesSave = "";
|
CompaniesSave = "";
|
||||||
FactionsSave = "";
|
FactionsSave = "";
|
||||||
SpecialServerIpsSave = "";
|
|
||||||
AliasesSave = "";
|
AliasesSave = "";
|
||||||
GlobalAliasesSave = "";
|
GlobalAliasesSave = "";
|
||||||
MessagesSave = "";
|
MessagesSave = "";
|
||||||
@ -41,24 +39,9 @@ class BitburnerSaveObject {
|
|||||||
getSaveString(): string {
|
getSaveString(): string {
|
||||||
this.PlayerSave = JSON.stringify(Player);
|
this.PlayerSave = JSON.stringify(Player);
|
||||||
|
|
||||||
// Delete all logs from all running scripts
|
this.AllServersSave = saveAllServers();
|
||||||
const TempAllServers = JSON.parse(JSON.stringify(AllServers), Reviver);
|
|
||||||
for (const ip in TempAllServers) {
|
|
||||||
const server = TempAllServers[ip];
|
|
||||||
if (server == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (let i = 0; i < server.runningScripts.length; ++i) {
|
|
||||||
const runningScriptObj = server.runningScripts[i];
|
|
||||||
runningScriptObj.logs.length = 0;
|
|
||||||
runningScriptObj.logs = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.AllServersSave = JSON.stringify(TempAllServers);
|
|
||||||
this.CompaniesSave = JSON.stringify(Companies);
|
this.CompaniesSave = JSON.stringify(Companies);
|
||||||
this.FactionsSave = JSON.stringify(Factions);
|
this.FactionsSave = JSON.stringify(Factions);
|
||||||
this.SpecialServerIpsSave = JSON.stringify(SpecialServerIps);
|
|
||||||
this.AliasesSave = JSON.stringify(Aliases);
|
this.AliasesSave = JSON.stringify(Aliases);
|
||||||
this.GlobalAliasesSave = JSON.stringify(GlobalAliases);
|
this.GlobalAliasesSave = JSON.stringify(GlobalAliases);
|
||||||
this.MessagesSave = JSON.stringify(Messages);
|
this.MessagesSave = JSON.stringify(Messages);
|
||||||
@ -170,7 +153,6 @@ function loadGame(saveString: string): boolean {
|
|||||||
loadAllServers(saveObj.AllServersSave);
|
loadAllServers(saveObj.AllServersSave);
|
||||||
loadCompanies(saveObj.CompaniesSave);
|
loadCompanies(saveObj.CompaniesSave);
|
||||||
loadFactions(saveObj.FactionsSave);
|
loadFactions(saveObj.FactionsSave);
|
||||||
loadSpecialServerIps(saveObj.SpecialServerIpsSave);
|
|
||||||
|
|
||||||
if (saveObj.hasOwnProperty("AliasesSave")) {
|
if (saveObj.hasOwnProperty("AliasesSave")) {
|
||||||
try {
|
try {
|
||||||
@ -232,6 +214,13 @@ function loadGame(saveString: string): boolean {
|
|||||||
console.error("ERROR: Failed to parse last export bonus Settings " + err);
|
console.error("ERROR: Failed to parse last export bonus Settings " + err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Player.inGang() && saveObj.hasOwnProperty("AllGangsSave")) {
|
||||||
|
try {
|
||||||
|
loadAllGangs(saveObj.AllGangsSave);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("ERROR: Failed to parse AllGangsSave: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (saveObj.hasOwnProperty("VersionSave")) {
|
if (saveObj.hasOwnProperty("VersionSave")) {
|
||||||
try {
|
try {
|
||||||
const ver = JSON.parse(saveObj.VersionSave, Reviver);
|
const ver = JSON.parse(saveObj.VersionSave, Reviver);
|
||||||
@ -249,13 +238,6 @@ function loadGame(saveString: string): boolean {
|
|||||||
} else {
|
} else {
|
||||||
createNewUpdateText();
|
createNewUpdateText();
|
||||||
}
|
}
|
||||||
if (Player.inGang() && saveObj.hasOwnProperty("AllGangsSave")) {
|
|
||||||
try {
|
|
||||||
loadAllGangs(saveObj.AllGangsSave);
|
|
||||||
} catch (e) {
|
|
||||||
console.error("ERROR: Failed to parse AllGangsSave: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ export class RunningScript {
|
|||||||
// Script arguments
|
// Script arguments
|
||||||
args: any[] = [];
|
args: any[] = [];
|
||||||
|
|
||||||
// Map of [key: server ip] -> Hacking data. Used for offline progress calculations.
|
// Map of [key: hostname] -> Hacking data. Used for offline progress calculations.
|
||||||
// Hacking data format: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
|
// Hacking data format: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
|
||||||
dataMap: IMap<number[]> = {};
|
dataMap: IMap<number[]> = {};
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ export class RunningScript {
|
|||||||
// How much RAM this script uses for ONE thread
|
// How much RAM this script uses for ONE thread
|
||||||
ramUsage = 0;
|
ramUsage = 0;
|
||||||
|
|
||||||
// IP of the server on which this script is running
|
// hostname of the server on which this script is running
|
||||||
server = "";
|
server = "";
|
||||||
|
|
||||||
// Number of threads that this script is running with
|
// Number of threads that this script is running with
|
||||||
@ -93,28 +93,28 @@ export class RunningScript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the moneyStolen and numTimesHack maps when hacking
|
// Update the moneyStolen and numTimesHack maps when hacking
|
||||||
recordHack(serverIp: string, moneyGained: number, n = 1): void {
|
recordHack(hostname: string, moneyGained: number, n = 1): void {
|
||||||
if (this.dataMap[serverIp] == null || this.dataMap[serverIp].constructor !== Array) {
|
if (this.dataMap[hostname] == null || this.dataMap[hostname].constructor !== Array) {
|
||||||
this.dataMap[serverIp] = [0, 0, 0, 0];
|
this.dataMap[hostname] = [0, 0, 0, 0];
|
||||||
}
|
}
|
||||||
this.dataMap[serverIp][0] += moneyGained;
|
this.dataMap[hostname][0] += moneyGained;
|
||||||
this.dataMap[serverIp][1] += n;
|
this.dataMap[hostname][1] += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the grow map when calling grow()
|
// Update the grow map when calling grow()
|
||||||
recordGrow(serverIp: string, n = 1): void {
|
recordGrow(hostname: string, n = 1): void {
|
||||||
if (this.dataMap[serverIp] == null || this.dataMap[serverIp].constructor !== Array) {
|
if (this.dataMap[hostname] == null || this.dataMap[hostname].constructor !== Array) {
|
||||||
this.dataMap[serverIp] = [0, 0, 0, 0];
|
this.dataMap[hostname] = [0, 0, 0, 0];
|
||||||
}
|
}
|
||||||
this.dataMap[serverIp][2] += n;
|
this.dataMap[hostname][2] += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the weaken map when calling weaken() {
|
// Update the weaken map when calling weaken() {
|
||||||
recordWeaken(serverIp: string, n = 1): void {
|
recordWeaken(hostname: string, n = 1): void {
|
||||||
if (this.dataMap[serverIp] == null || this.dataMap[serverIp].constructor !== Array) {
|
if (this.dataMap[hostname] == null || this.dataMap[hostname].constructor !== Array) {
|
||||||
this.dataMap[serverIp] = [0, 0, 0, 0];
|
this.dataMap[hostname] = [0, 0, 0, 0];
|
||||||
}
|
}
|
||||||
this.dataMap[serverIp][3] += n;
|
this.dataMap[hostname][3] += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize the current object to a JSON save state
|
// Serialize the current object to a JSON save state
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AllServers } from "../Server/AllServers";
|
import { GetServer } from "../Server/AllServers";
|
||||||
import { RunningScript } from "./RunningScript";
|
import { RunningScript } from "./RunningScript";
|
||||||
|
|
||||||
export function getRamUsageFromRunningScript(script: RunningScript): number {
|
export function getRamUsageFromRunningScript(script: RunningScript): number {
|
||||||
@ -6,7 +6,7 @@ export function getRamUsageFromRunningScript(script: RunningScript): number {
|
|||||||
return script.ramUsage; // Use cached value
|
return script.ramUsage; // Use cached value
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = AllServers[script.server];
|
const server = GetServer(script.server);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,14 @@ export class Script {
|
|||||||
// Amount of RAM this Script requres to run
|
// Amount of RAM this Script requres to run
|
||||||
ramUsage = 0;
|
ramUsage = 0;
|
||||||
|
|
||||||
// IP of server that this script is on.
|
// hostname of server that this script is on.
|
||||||
server = "";
|
server = "";
|
||||||
|
|
||||||
constructor(fn = "", code = "", server = "", otherScripts: Script[] = []) {
|
constructor(fn = "", code = "", server = "", otherScripts: Script[] = []) {
|
||||||
this.filename = fn;
|
this.filename = fn;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.ramUsage = 0;
|
this.ramUsage = 0;
|
||||||
this.server = server; // IP of server this script is on
|
this.server = server; // hostname of server this script is on
|
||||||
this.module = "";
|
this.module = "";
|
||||||
this.moduleSequenceNumber = ++globalModuleSequenceNumber;
|
this.moduleSequenceNumber = ++globalModuleSequenceNumber;
|
||||||
if (this.code !== "") {
|
if (this.code !== "") {
|
||||||
@ -90,12 +90,12 @@ export class Script {
|
|||||||
* @param {string} code - The new contents of the script
|
* @param {string} code - The new contents of the script
|
||||||
* @param {Script[]} otherScripts - Other scripts on the server. Used to process imports
|
* @param {Script[]} otherScripts - Other scripts on the server. Used to process imports
|
||||||
*/
|
*/
|
||||||
saveScript(filename: string, code: string, serverIp: string, otherScripts: Script[]): void {
|
saveScript(filename: string, code: string, hostname: string, otherScripts: Script[]): void {
|
||||||
// Update code and filename
|
// Update code and filename
|
||||||
this.code = code.replace(/^\s+|\s+$/g, "");
|
this.code = code.replace(/^\s+|\s+$/g, "");
|
||||||
|
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
this.server = serverIp;
|
this.server = hostname;
|
||||||
this.updateRamUsage(otherScripts);
|
this.updateRamUsage(otherScripts);
|
||||||
this.markUpdated();
|
this.markUpdated();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { CONSTANTS } from "../Constants";
|
import { CONSTANTS } from "../Constants";
|
||||||
import { Player } from "../Player";
|
import { Player } from "../Player";
|
||||||
import { AllServers } from "../Server/AllServers";
|
|
||||||
import { BaseServer } from "../Server/BaseServer";
|
import { BaseServer } from "../Server/BaseServer";
|
||||||
import { Server } from "../Server/Server";
|
import { Server } from "../Server/Server";
|
||||||
import { RunningScript } from "../Script/RunningScript";
|
import { RunningScript } from "../Script/RunningScript";
|
||||||
import { processSingleServerGrowth } from "../Server/ServerHelpers";
|
import { processSingleServerGrowth } from "../Server/ServerHelpers";
|
||||||
|
import { GetServer } from "../Server/AllServers";
|
||||||
|
|
||||||
import { numeralWrapper } from "../ui/numeralFormat";
|
import { numeralWrapper } from "../ui/numeralFormat";
|
||||||
|
|
||||||
@ -27,20 +27,21 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
|||||||
//Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
|
//Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
|
||||||
|
|
||||||
// Grow
|
// Grow
|
||||||
for (const ip in runningScript.dataMap) {
|
for (const hostname in runningScript.dataMap) {
|
||||||
if (runningScript.dataMap.hasOwnProperty(ip)) {
|
if (runningScript.dataMap.hasOwnProperty(hostname)) {
|
||||||
if (runningScript.dataMap[ip][2] == 0 || runningScript.dataMap[ip][2] == null) {
|
if (runningScript.dataMap[hostname][2] == 0 || runningScript.dataMap[hostname][2] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const serv = AllServers[ip];
|
const serv = GetServer(hostname);
|
||||||
if (serv == null) {
|
if (serv == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const timesGrown = Math.round(
|
const timesGrown = Math.round(
|
||||||
((0.5 * runningScript.dataMap[ip][2]) / runningScript.onlineRunningTime) * timePassed,
|
((0.5 * runningScript.dataMap[hostname][2]) / runningScript.onlineRunningTime) * timePassed,
|
||||||
);
|
);
|
||||||
runningScript.log(`Called on ${serv.hostname} ${timesGrown} times while offline`);
|
runningScript.log(`Called on ${serv.hostname} ${timesGrown} times while offline`);
|
||||||
const host = AllServers[runningScript.server];
|
const host = GetServer(runningScript.server);
|
||||||
|
if (host === null) throw new Error("getServer of null key?");
|
||||||
if (!(serv instanceof Server)) throw new Error("trying to grow a non-normal server");
|
if (!(serv instanceof Server)) throw new Error("trying to grow a non-normal server");
|
||||||
const growth = processSingleServerGrowth(serv, timesGrown, Player, host.cpuCores);
|
const growth = processSingleServerGrowth(serv, timesGrown, Player, host.cpuCores);
|
||||||
runningScript.log(
|
runningScript.log(
|
||||||
@ -59,20 +60,21 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
|||||||
runningScript.offlineExpGained += expGain;
|
runningScript.offlineExpGained += expGain;
|
||||||
|
|
||||||
// Weaken
|
// Weaken
|
||||||
for (const ip in runningScript.dataMap) {
|
for (const hostname in runningScript.dataMap) {
|
||||||
if (runningScript.dataMap.hasOwnProperty(ip)) {
|
if (runningScript.dataMap.hasOwnProperty(hostname)) {
|
||||||
if (runningScript.dataMap[ip][3] == 0 || runningScript.dataMap[ip][3] == null) {
|
if (runningScript.dataMap[hostname][3] == 0 || runningScript.dataMap[hostname][3] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const serv = AllServers[ip];
|
const serv = GetServer(hostname);
|
||||||
if (serv == null) {
|
if (serv == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(serv instanceof Server)) throw new Error("trying to weaken a non-normal server");
|
if (!(serv instanceof Server)) throw new Error("trying to weaken a non-normal server");
|
||||||
const host = AllServers[runningScript.server];
|
const host = GetServer(runningScript.server);
|
||||||
|
if (host === null) throw new Error("getServer of null key?");
|
||||||
const timesWeakened = Math.round(
|
const timesWeakened = Math.round(
|
||||||
((0.5 * runningScript.dataMap[ip][3]) / runningScript.onlineRunningTime) * timePassed,
|
((0.5 * runningScript.dataMap[hostname][3]) / runningScript.onlineRunningTime) * timePassed,
|
||||||
);
|
);
|
||||||
runningScript.log(`Called weaken() on ${serv.hostname} ${timesWeakened} times while offline`);
|
runningScript.log(`Called weaken() on ${serv.hostname} ${timesWeakened} times while offline`);
|
||||||
const coreBonus = 1 + (host.cpuCores - 1) / 16;
|
const coreBonus = 1 + (host.cpuCores - 1) / 16;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Server } from "./Server";
|
import { Server } from "./Server";
|
||||||
import { SpecialServerIps } from "./SpecialServerIps";
|
import { BaseServer } from "./BaseServer";
|
||||||
import { serverMetadata } from "./data/servers";
|
import { serverMetadata } from "./data/servers";
|
||||||
|
|
||||||
import { HacknetServer } from "../Hacknet/HacknetServer";
|
import { HacknetServer } from "../Hacknet/HacknetServer";
|
||||||
@ -8,13 +8,68 @@ import { IMap } from "../types";
|
|||||||
import { createRandomIp } from "../utils/IPAddress";
|
import { createRandomIp } from "../utils/IPAddress";
|
||||||
import { getRandomInt } from "../utils/helpers/getRandomInt";
|
import { getRandomInt } from "../utils/helpers/getRandomInt";
|
||||||
import { Reviver } from "../utils/JSONReviver";
|
import { Reviver } from "../utils/JSONReviver";
|
||||||
|
import { isValidIPAddress } from "../utils/helpers/isValidIPAddress";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of all Servers that exist in the game
|
* Map of all Servers that exist in the game
|
||||||
* Key (string) = IP
|
* Key (string) = IP
|
||||||
* Value = Server object
|
* Value = Server object
|
||||||
*/
|
*/
|
||||||
export let AllServers: IMap<Server | HacknetServer> = {};
|
let AllServers: IMap<Server | HacknetServer> = {};
|
||||||
|
|
||||||
|
function GetServerByIP(ip: string): BaseServer | undefined {
|
||||||
|
for (const key in AllServers) {
|
||||||
|
const server = AllServers[key];
|
||||||
|
if (server.ip !== ip) continue;
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns server object with corresponding hostname
|
||||||
|
// Relatively slow, would rather not use this a lot
|
||||||
|
function GetServerByHostname(hostname: string): BaseServer | null {
|
||||||
|
for (const key in AllServers) {
|
||||||
|
const server = AllServers[key];
|
||||||
|
if (server.hostname == hostname) {
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get server by IP or hostname. Returns null if invalid
|
||||||
|
export function GetServer(s: string): BaseServer | null {
|
||||||
|
const server = AllServers[s];
|
||||||
|
if (server) return server;
|
||||||
|
if (!isValidIPAddress(s)) {
|
||||||
|
return GetServerByHostname(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ipserver = GetServerByIP(s);
|
||||||
|
if (ipserver !== undefined) {
|
||||||
|
return ipserver;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GetAllServers(): BaseServer[] {
|
||||||
|
const servers: BaseServer[] = [];
|
||||||
|
for (const key in AllServers) {
|
||||||
|
servers.push(AllServers[key]);
|
||||||
|
}
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DeleteServer(serverkey: string): void {
|
||||||
|
for (const key in AllServers) {
|
||||||
|
const server = AllServers[key];
|
||||||
|
if (server.ip !== serverkey && server.hostname !== serverkey) continue;
|
||||||
|
delete AllServers[key];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function ipExists(ip: string): boolean {
|
export function ipExists(ip: string): boolean {
|
||||||
return AllServers[ip] != null;
|
return AllServers[ip] != null;
|
||||||
@ -33,15 +88,13 @@ export function createUniqueRandomIp(): string {
|
|||||||
|
|
||||||
// Saftely add a Server to the AllServers map
|
// Saftely add a Server to the AllServers map
|
||||||
export function AddToAllServers(server: Server | HacknetServer): void {
|
export function AddToAllServers(server: Server | HacknetServer): void {
|
||||||
const serverIp = server.ip;
|
if (GetServer(server.hostname)) {
|
||||||
if (ipExists(serverIp)) {
|
|
||||||
console.warn(`IP of server that's being added: ${serverIp}`);
|
|
||||||
console.warn(`Hostname of the server thats being added: ${server.hostname}`);
|
console.warn(`Hostname of the server thats being added: ${server.hostname}`);
|
||||||
console.warn(`The server that already has this IP is: ${AllServers[serverIp].hostname}`);
|
console.warn(`The server that already has this IP is: ${AllServers[server.hostname].hostname}`);
|
||||||
throw new Error("Error: Trying to add a server with an existing IP");
|
throw new Error("Error: Trying to add a server with an existing IP");
|
||||||
}
|
}
|
||||||
|
|
||||||
AllServers[serverIp] = server;
|
AllServers[server.hostname] = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IServerParams {
|
interface IServerParams {
|
||||||
@ -108,10 +161,6 @@ export function initForeignServers(homeComputer: Server): void {
|
|||||||
server.messages.push(filename);
|
server.messages.push(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metadata.specialName !== undefined) {
|
|
||||||
SpecialServerIps.addIp(metadata.specialName, server.ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
AddToAllServers(server);
|
AddToAllServers(server);
|
||||||
if (metadata.networkLayer !== undefined) {
|
if (metadata.networkLayer !== undefined) {
|
||||||
networkLayers[toNumber(metadata.networkLayer) - 1].push(server);
|
networkLayers[toNumber(metadata.networkLayer) - 1].push(server);
|
||||||
@ -120,8 +169,8 @@ export function initForeignServers(homeComputer: Server): void {
|
|||||||
|
|
||||||
/* Create a randomized network for all the foreign servers */
|
/* Create a randomized network for all the foreign servers */
|
||||||
const linkComputers = (server1: Server, server2: Server): void => {
|
const linkComputers = (server1: Server, server2: Server): void => {
|
||||||
server1.serversOnNetwork.push(server2.ip);
|
server1.serversOnNetwork.push(server2.hostname);
|
||||||
server2.serversOnNetwork.push(server1.ip);
|
server2.serversOnNetwork.push(server1.hostname);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getRandomArrayItem = (arr: any[]): any => arr[Math.floor(Math.random() * arr.length)];
|
const getRandomArrayItem = (arr: any[]): any => arr[Math.floor(Math.random() * arr.length)];
|
||||||
@ -148,5 +197,18 @@ export function prestigeAllServers(): void {
|
|||||||
|
|
||||||
export function loadAllServers(saveString: string): void {
|
export function loadAllServers(saveString: string): void {
|
||||||
AllServers = JSON.parse(saveString, Reviver);
|
AllServers = JSON.parse(saveString, Reviver);
|
||||||
console.log(AllServers);
|
}
|
||||||
|
|
||||||
|
export function saveAllServers(): string {
|
||||||
|
const TempAllServers = JSON.parse(JSON.stringify(AllServers), Reviver);
|
||||||
|
for (const key in TempAllServers) {
|
||||||
|
const server = TempAllServers[key];
|
||||||
|
for (let i = 0; i < server.runningScripts.length; ++i) {
|
||||||
|
const runningScriptObj = server.runningScripts[i];
|
||||||
|
runningScriptObj.logs.length = 0;
|
||||||
|
runningScriptObj.logs = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return JSON.stringify(TempAllServers);
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ export class BaseServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, create a new script
|
// Otherwise, create a new script
|
||||||
const newScript = new Script(fn, code, this.ip, this.scripts);
|
const newScript = new Script(fn, code, this.hostname, this.scripts);
|
||||||
this.scripts.push(newScript);
|
this.scripts.push(newScript);
|
||||||
ret.success = true;
|
ret.success = true;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
import { AllServers, createUniqueRandomIp, ipExists } from "./AllServers";
|
import { GetServer, createUniqueRandomIp, ipExists } from "./AllServers";
|
||||||
import { Server, IConstructorParams } from "./Server";
|
import { Server, IConstructorParams } from "./Server";
|
||||||
import { BaseServer } from "./BaseServer";
|
import { BaseServer } from "./BaseServer";
|
||||||
import { calculateServerGrowth } from "./formulas/grow";
|
import { calculateServerGrowth } from "./formulas/grow";
|
||||||
|
|
||||||
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
||||||
import { CONSTANTS } from "../Constants";
|
import { CONSTANTS } from "../Constants";
|
||||||
import { HacknetServer } from "../Hacknet/HacknetServer";
|
|
||||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
import { Programs } from "../Programs/Programs";
|
import { Programs } from "../Programs/Programs";
|
||||||
import { LiteratureNames } from "../Literature/data/LiteratureNames";
|
import { LiteratureNames } from "../Literature/data/LiteratureNames";
|
||||||
|
|
||||||
import { isValidNumber } from "../utils/helpers/isValidNumber";
|
import { isValidNumber } from "../utils/helpers/isValidNumber";
|
||||||
import { isValidIPAddress } from "../utils/helpers/isValidIPAddress";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new server, while also ensuring that the new server
|
* Constructs a new server, while also ensuring that the new server
|
||||||
@ -22,12 +20,12 @@ export function safetlyCreateUniqueServer(params: IConstructorParams): Server {
|
|||||||
params.ip = createUniqueRandomIp();
|
params.ip = createUniqueRandomIp();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetServerByHostname(params.hostname) != null) {
|
if (GetServer(params.hostname) != null) {
|
||||||
// Use a for loop to ensure that we don't get suck in an infinite loop somehow
|
// Use a for loop to ensure that we don't get suck in an infinite loop somehow
|
||||||
let hostname: string = params.hostname;
|
let hostname: string = params.hostname;
|
||||||
for (let i = 0; i < 200; ++i) {
|
for (let i = 0; i < 200; ++i) {
|
||||||
hostname = `${params.hostname}-${i}`;
|
hostname = `${params.hostname}-${i}`;
|
||||||
if (GetServerByHostname(hostname) == null) {
|
if (GetServer(hostname) == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,46 +117,20 @@ export function prestigeHomeComputer(homeComp: Server): void {
|
|||||||
homeComp.messages.push(LiteratureNames.HackersStartingHandbook);
|
homeComp.messages.push(LiteratureNames.HackersStartingHandbook);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Returns server object with corresponding hostname
|
|
||||||
// Relatively slow, would rather not use this a lot
|
|
||||||
export function GetServerByHostname(hostname: string): Server | HacknetServer | null {
|
|
||||||
for (const ip in AllServers) {
|
|
||||||
if (AllServers.hasOwnProperty(ip)) {
|
|
||||||
if (AllServers[ip].hostname == hostname) {
|
|
||||||
return AllServers[ip];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get server by IP or hostname. Returns null if invalid
|
|
||||||
export function getServer(s: string): Server | HacknetServer | null {
|
|
||||||
if (!isValidIPAddress(s)) {
|
|
||||||
return GetServerByHostname(s);
|
|
||||||
}
|
|
||||||
if (AllServers[s] !== undefined) {
|
|
||||||
return AllServers[s];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the i-th server on the specified server's network
|
// Returns the i-th server on the specified server's network
|
||||||
// A Server's serverOnNetwork property holds only the IPs. This function returns
|
// A Server's serverOnNetwork property holds only the IPs. This function returns
|
||||||
// the actual Server object
|
// the actual Server object
|
||||||
export function getServerOnNetwork(server: BaseServer, i: number): Server | HacknetServer | null {
|
export function getServerOnNetwork(server: BaseServer, i: number): BaseServer | null {
|
||||||
if (i > server.serversOnNetwork.length) {
|
if (i > server.serversOnNetwork.length) {
|
||||||
console.error("Tried to get server on network that was out of range");
|
console.error("Tried to get server on network that was out of range");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AllServers[server.serversOnNetwork[i]];
|
return GetServer(server.serversOnNetwork[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isBackdoorInstalled(server: Server | HacknetServer): boolean {
|
export function isBackdoorInstalled(server: BaseServer): boolean {
|
||||||
if ("backdoorInstalled" in server) {
|
if (server instanceof Server) {
|
||||||
return server.backdoorInstalled;
|
return server.backdoorInstalled;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -80,12 +80,12 @@ export function purchaseServer(hostname: string, ram: number, cost: number, p: I
|
|||||||
AddToAllServers(newServ);
|
AddToAllServers(newServ);
|
||||||
|
|
||||||
// Add to Player's purchasedServers array
|
// Add to Player's purchasedServers array
|
||||||
p.purchasedServers.push(newServ.ip);
|
p.purchasedServers.push(newServ.hostname);
|
||||||
|
|
||||||
// Connect new server to home computer
|
// Connect new server to home computer
|
||||||
const homeComputer = p.getHomeComputer();
|
const homeComputer = p.getHomeComputer();
|
||||||
homeComputer.serversOnNetwork.push(newServ.ip);
|
homeComputer.serversOnNetwork.push(newServ.hostname);
|
||||||
newServ.serversOnNetwork.push(homeComputer.ip);
|
newServ.serversOnNetwork.push(homeComputer.hostname);
|
||||||
|
|
||||||
p.loseMoney(cost);
|
p.loseMoney(cost);
|
||||||
|
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
import { IMap } from "../types";
|
|
||||||
import { Reviver, Generic_toJSON, Generic_fromJSON } from "../utils/JSONReviver";
|
|
||||||
|
|
||||||
/* Holds IP of Special Servers */
|
|
||||||
export const SpecialServerNames: IMap<string> = {
|
|
||||||
FulcrumSecretTechnologies: "Fulcrum Secret Technologies Server",
|
|
||||||
CyberSecServer: "CyberSec Server",
|
|
||||||
NiteSecServer: "NiteSec Server",
|
|
||||||
TheBlackHandServer: "The Black Hand Server",
|
|
||||||
BitRunnersServer: "BitRunners Server",
|
|
||||||
TheDarkArmyServer: "The Dark Army Server",
|
|
||||||
DaedalusServer: "Daedalus Server",
|
|
||||||
WorldDaemon: "w0r1d_d43m0n",
|
|
||||||
};
|
|
||||||
|
|
||||||
export class SpecialServerIpsMap {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
||||||
[key: string]: Function | string;
|
|
||||||
|
|
||||||
addIp(name: string, ip: string): void {
|
|
||||||
this[name] = ip;
|
|
||||||
}
|
|
||||||
|
|
||||||
getIp(name: string): string {
|
|
||||||
return this[name] as string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Serialize the current object to a JSON save state
|
|
||||||
toJSON(): any {
|
|
||||||
return Generic_toJSON("SpecialServerIpsMap", this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initializes a SpecialServerIpsMap Object from a JSON save state
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
||||||
static fromJSON(value: any): SpecialServerIpsMap {
|
|
||||||
return Generic_fromJSON(SpecialServerIpsMap, value.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Reviver.constructors.SpecialServerIpsMap = SpecialServerIpsMap;
|
|
||||||
|
|
||||||
export let SpecialServerIps: SpecialServerIpsMap = new SpecialServerIpsMap();
|
|
||||||
|
|
||||||
export function prestigeSpecialServerIps(): void {
|
|
||||||
for (const member in SpecialServerIps) {
|
|
||||||
delete SpecialServerIps[member];
|
|
||||||
}
|
|
||||||
|
|
||||||
SpecialServerIps = new SpecialServerIpsMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loadSpecialServerIps(saveString: string): void {
|
|
||||||
SpecialServerIps = JSON.parse(saveString, Reviver);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function initSpecialServerIps(): void {
|
|
||||||
SpecialServerIps = new SpecialServerIpsMap();
|
|
||||||
}
|
|
26
src/Server/data/SpecialServers.ts
Normal file
26
src/Server/data/SpecialServers.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* Holds IP of Special Servers */
|
||||||
|
export const SpecialServers: {
|
||||||
|
[key: string]: string | undefined;
|
||||||
|
|
||||||
|
Home: string;
|
||||||
|
FulcrumSecretTechnologies: string;
|
||||||
|
CyberSecServer: string;
|
||||||
|
NiteSecServer: string;
|
||||||
|
TheBlackHandServer: string;
|
||||||
|
BitRunnersServer: string;
|
||||||
|
TheDarkArmyServer: string;
|
||||||
|
DaedalusServer: string;
|
||||||
|
WorldDaemon: string;
|
||||||
|
DarkWeb: string;
|
||||||
|
} = {
|
||||||
|
Home: "home",
|
||||||
|
FulcrumSecretTechnologies: "fulcrumassets",
|
||||||
|
CyberSecServer: "CSEC",
|
||||||
|
NiteSecServer: "avmnite-02h",
|
||||||
|
TheBlackHandServer: "I.I.I.I",
|
||||||
|
BitRunnersServer: "run4theh111z",
|
||||||
|
TheDarkArmyServer: ".",
|
||||||
|
DaedalusServer: "The-Cave",
|
||||||
|
WorldDaemon: "w0r1d_d43m0n",
|
||||||
|
DarkWeb: "darkweb",
|
||||||
|
};
|
@ -4,6 +4,7 @@
|
|||||||
import { IMinMaxRange } from "../../types";
|
import { IMinMaxRange } from "../../types";
|
||||||
import { LocationName } from "../../Locations/data/LocationNames";
|
import { LocationName } from "../../Locations/data/LocationNames";
|
||||||
import { LiteratureNames } from "../../Literature/data/LiteratureNames";
|
import { LiteratureNames } from "../../Literature/data/LiteratureNames";
|
||||||
|
import { SpecialServers } from "./SpecialServers";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The metadata describing the base state of servers on the network.
|
* The metadata describing the base state of servers on the network.
|
||||||
@ -319,7 +320,7 @@ export const serverMetadata: IServerMetadata[] = [
|
|||||||
min: 1100,
|
min: 1100,
|
||||||
},
|
},
|
||||||
serverGrowth: 1,
|
serverGrowth: 1,
|
||||||
specialName: "Fulcrum Secret Technologies Server",
|
specialName: SpecialServers.FulcrumSecretTechnologies,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hackDifficulty: {
|
hackDifficulty: {
|
||||||
@ -1470,7 +1471,7 @@ export const serverMetadata: IServerMetadata[] = [
|
|||||||
min: 505,
|
min: 505,
|
||||||
},
|
},
|
||||||
serverGrowth: 0,
|
serverGrowth: 0,
|
||||||
specialName: "BitRunners Server",
|
specialName: SpecialServers.BitRunnersServer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hackDifficulty: 0,
|
hackDifficulty: 0,
|
||||||
@ -1489,7 +1490,7 @@ export const serverMetadata: IServerMetadata[] = [
|
|||||||
min: 340,
|
min: 340,
|
||||||
},
|
},
|
||||||
serverGrowth: 0,
|
serverGrowth: 0,
|
||||||
specialName: "The Black Hand Server",
|
specialName: SpecialServers.TheBlackHandServer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hackDifficulty: 0,
|
hackDifficulty: 0,
|
||||||
@ -1508,7 +1509,7 @@ export const serverMetadata: IServerMetadata[] = [
|
|||||||
min: 202,
|
min: 202,
|
||||||
},
|
},
|
||||||
serverGrowth: 0,
|
serverGrowth: 0,
|
||||||
specialName: "NiteSec Server",
|
specialName: SpecialServers.NiteSecServer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hackDifficulty: 0,
|
hackDifficulty: 0,
|
||||||
@ -1523,7 +1524,7 @@ export const serverMetadata: IServerMetadata[] = [
|
|||||||
min: 505,
|
min: 505,
|
||||||
},
|
},
|
||||||
serverGrowth: 0,
|
serverGrowth: 0,
|
||||||
specialName: "The Dark Army Server",
|
specialName: SpecialServers.TheDarkArmyServer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hackDifficulty: 0,
|
hackDifficulty: 0,
|
||||||
@ -1539,7 +1540,7 @@ export const serverMetadata: IServerMetadata[] = [
|
|||||||
min: 51,
|
min: 51,
|
||||||
},
|
},
|
||||||
serverGrowth: 0,
|
serverGrowth: 0,
|
||||||
specialName: "CyberSec Server",
|
specialName: SpecialServers.CyberSecServer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hackDifficulty: 0,
|
hackDifficulty: 0,
|
||||||
@ -1551,7 +1552,7 @@ export const serverMetadata: IServerMetadata[] = [
|
|||||||
organizationName: "Helios",
|
organizationName: "Helios",
|
||||||
requiredHackingSkill: 925,
|
requiredHackingSkill: 925,
|
||||||
serverGrowth: 0,
|
serverGrowth: 0,
|
||||||
specialName: "Daedalus Server",
|
specialName: SpecialServers.DaedalusServer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hackDifficulty: 0,
|
hackDifficulty: 0,
|
||||||
@ -1561,6 +1562,6 @@ export const serverMetadata: IServerMetadata[] = [
|
|||||||
organizationName: "w0r1d_d43m0n",
|
organizationName: "w0r1d_d43m0n",
|
||||||
requiredHackingSkill: 3000,
|
requiredHackingSkill: 3000,
|
||||||
serverGrowth: 0,
|
serverGrowth: 0,
|
||||||
specialName: "w0r1d_d43m0n",
|
specialName: SpecialServers.WorldDaemon,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -22,7 +22,6 @@ export const TerminalHelpText: string[] = [
|
|||||||
"help [command] Display this help text, or the help text for a command",
|
"help [command] Display this help text, or the help text for a command",
|
||||||
"home Connect to home computer",
|
"home Connect to home computer",
|
||||||
"hostname Displays the hostname of the machine",
|
"hostname Displays the hostname of the machine",
|
||||||
"ifconfig Displays the IP address of the machine",
|
|
||||||
"kill [script/pid] [args...] Stops the specified script on the current server ",
|
"kill [script/pid] [args...] Stops the specified script on the current server ",
|
||||||
"killall Stops all running scripts on the current machine",
|
"killall Stops all running scripts on the current machine",
|
||||||
"ls [dir] [| grep pattern] Displays all files on the machine",
|
"ls [dir] [| grep pattern] Displays all files on the machine",
|
||||||
@ -219,7 +218,6 @@ export const HelpTexts: IMap<string[]> = {
|
|||||||
"home" + "Connect to your home computer. This will work no matter what server you are currently connected to.",
|
"home" + "Connect to your home computer. This will work no matter what server you are currently connected to.",
|
||||||
],
|
],
|
||||||
hostname: ["hostname", " ", "Prints the hostname of the current server"],
|
hostname: ["hostname", " ", "Prints the hostname of the current server"],
|
||||||
ifconfig: ["ipconfig", " ", "Prints the IP address of the current server"],
|
|
||||||
kill: [
|
kill: [
|
||||||
"kill [script name] [args...]",
|
"kill [script name] [args...]",
|
||||||
" ",
|
" ",
|
||||||
|
@ -12,14 +12,14 @@ import { TextFile } from "../TextFile";
|
|||||||
import { Script } from "../Script/Script";
|
import { Script } from "../Script/Script";
|
||||||
import { isScriptFilename } from "../Script/isScriptFilename";
|
import { isScriptFilename } from "../Script/isScriptFilename";
|
||||||
import { CONSTANTS } from "../Constants";
|
import { CONSTANTS } from "../Constants";
|
||||||
import { AllServers } from "../Server/AllServers";
|
import { GetServer, GetAllServers } from "../Server/AllServers";
|
||||||
|
|
||||||
import { removeLeadingSlash, isInRootDirectory, evaluateFilePath } from "./DirectoryHelpers";
|
import { removeLeadingSlash, isInRootDirectory, evaluateFilePath } from "./DirectoryHelpers";
|
||||||
import { checkIfConnectedToDarkweb } from "../DarkWeb/DarkWeb";
|
import { checkIfConnectedToDarkweb } from "../DarkWeb/DarkWeb";
|
||||||
import { iTutorialNextStep, iTutorialSteps, ITutorial } from "../InteractiveTutorial";
|
import { iTutorialNextStep, iTutorialSteps, ITutorial } from "../InteractiveTutorial";
|
||||||
import { GetServerByHostname, getServer, getServerOnNetwork, processSingleServerGrowth } from "../Server/ServerHelpers";
|
import { getServerOnNetwork, processSingleServerGrowth } from "../Server/ServerHelpers";
|
||||||
import { ParseCommand, ParseCommands } from "./Parser";
|
import { ParseCommand, ParseCommands } from "./Parser";
|
||||||
import { SpecialServerIps, SpecialServerNames } from "../Server/SpecialServerIps";
|
import { SpecialServers } from "../Server/data/SpecialServers";
|
||||||
import { Settings } from "../Settings/Settings";
|
import { Settings } from "../Settings/Settings";
|
||||||
import { createProgressBarText } from "../utils/helpers/createProgressBarText";
|
import { createProgressBarText } from "../utils/helpers/createProgressBarText";
|
||||||
import {
|
import {
|
||||||
@ -49,7 +49,6 @@ import { hack } from "./commands/hack";
|
|||||||
import { help } from "./commands/help";
|
import { help } from "./commands/help";
|
||||||
import { home } from "./commands/home";
|
import { home } from "./commands/home";
|
||||||
import { hostname } from "./commands/hostname";
|
import { hostname } from "./commands/hostname";
|
||||||
import { ifconfig } from "./commands/ifconfig";
|
|
||||||
import { kill } from "./commands/kill";
|
import { kill } from "./commands/kill";
|
||||||
import { killall } from "./commands/killall";
|
import { killall } from "./commands/killall";
|
||||||
import { ls } from "./commands/ls";
|
import { ls } from "./commands/ls";
|
||||||
@ -116,6 +115,7 @@ export class Terminal implements ITerminal {
|
|||||||
this.error("Cannot hack this kind of server");
|
this.error("Cannot hack this kind of server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(server instanceof Server)) throw new Error("server should be normal server");
|
||||||
this.startAction(calculateHackingTime(server, player) / 4, "h");
|
this.startAction(calculateHackingTime(server, player) / 4, "h");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,6 +125,7 @@ export class Terminal implements ITerminal {
|
|||||||
this.error("Cannot hack this kind of server");
|
this.error("Cannot hack this kind of server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(server instanceof Server)) throw new Error("server should be normal server");
|
||||||
this.startAction(calculateGrowTime(server, player) / 16, "g");
|
this.startAction(calculateGrowTime(server, player) / 16, "g");
|
||||||
}
|
}
|
||||||
startWeaken(player: IPlayer): void {
|
startWeaken(player: IPlayer): void {
|
||||||
@ -133,6 +134,7 @@ export class Terminal implements ITerminal {
|
|||||||
this.error("Cannot hack this kind of server");
|
this.error("Cannot hack this kind of server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(server instanceof Server)) throw new Error("server should be normal server");
|
||||||
this.startAction(calculateWeakenTime(server, player) / 16, "w");
|
this.startAction(calculateWeakenTime(server, player) / 16, "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +145,7 @@ export class Terminal implements ITerminal {
|
|||||||
this.error("Cannot backdoor this kind of server");
|
this.error("Cannot backdoor this kind of server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(server instanceof Server)) throw new Error("server should be normal server");
|
||||||
this.startAction(calculateHackingTime(server, player) / 4, "b");
|
this.startAction(calculateHackingTime(server, player) / 4, "b");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +166,7 @@ export class Terminal implements ITerminal {
|
|||||||
this.error("Cannot hack this kind of server");
|
this.error("Cannot hack this kind of server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(server instanceof Server)) throw new Error("server should be normal server");
|
||||||
|
|
||||||
// Calculate whether hack was successful
|
// Calculate whether hack was successful
|
||||||
const hackChance = calculateHackingChance(server, player);
|
const hackChance = calculateHackingChance(server, player);
|
||||||
@ -171,10 +175,7 @@ export class Terminal implements ITerminal {
|
|||||||
const expGainedOnFailure = expGainedOnSuccess / 4;
|
const expGainedOnFailure = expGainedOnSuccess / 4;
|
||||||
if (rand < hackChance) {
|
if (rand < hackChance) {
|
||||||
// Success!
|
// Success!
|
||||||
if (
|
if (SpecialServers.WorldDaemon === server.hostname) {
|
||||||
SpecialServerIps[SpecialServerNames.WorldDaemon] &&
|
|
||||||
SpecialServerIps[SpecialServerNames.WorldDaemon] == server.ip
|
|
||||||
) {
|
|
||||||
if (player.bitNodeN == null) {
|
if (player.bitNodeN == null) {
|
||||||
player.bitNodeN = 1;
|
player.bitNodeN = 1;
|
||||||
}
|
}
|
||||||
@ -218,6 +219,7 @@ export class Terminal implements ITerminal {
|
|||||||
this.error("Cannot hack this kind of server");
|
this.error("Cannot hack this kind of server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(server instanceof Server)) throw new Error("server should be normal server");
|
||||||
const expGain = calculateHackingExpGain(server, player);
|
const expGain = calculateHackingExpGain(server, player);
|
||||||
const growth = processSingleServerGrowth(server, 1, player, server.cpuCores) - 1;
|
const growth = processSingleServerGrowth(server, 1, player, server.cpuCores) - 1;
|
||||||
this.print(
|
this.print(
|
||||||
@ -235,6 +237,7 @@ export class Terminal implements ITerminal {
|
|||||||
this.error("Cannot hack this kind of server");
|
this.error("Cannot hack this kind of server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(server instanceof Server)) throw new Error("server should be normal server");
|
||||||
const expGain = calculateHackingExpGain(server, player);
|
const expGain = calculateHackingExpGain(server, player);
|
||||||
server.weaken(CONSTANTS.ServerWeakenAmount);
|
server.weaken(CONSTANTS.ServerWeakenAmount);
|
||||||
this.print(
|
this.print(
|
||||||
@ -251,10 +254,8 @@ export class Terminal implements ITerminal {
|
|||||||
this.error("Cannot hack this kind of server");
|
this.error("Cannot hack this kind of server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (
|
if (!(server instanceof Server)) throw new Error("server should be normal server");
|
||||||
SpecialServerIps[SpecialServerNames.WorldDaemon] &&
|
if (SpecialServers.WorldDaemon === server.hostname) {
|
||||||
SpecialServerIps[SpecialServerNames.WorldDaemon] == server.ip
|
|
||||||
) {
|
|
||||||
if (player.bitNodeN == null) {
|
if (player.bitNodeN == null) {
|
||||||
player.bitNodeN = 1;
|
player.bitNodeN = 1;
|
||||||
}
|
}
|
||||||
@ -287,7 +288,7 @@ export class Terminal implements ITerminal {
|
|||||||
}
|
}
|
||||||
this.print(
|
this.print(
|
||||||
`Total money available on server: ${
|
`Total money available on server: ${
|
||||||
!(currServ instanceof HacknetServer) ? numeralWrapper.formatMoney(currServ.moneyAvailable) : "N/A"
|
currServ instanceof Server ? numeralWrapper.formatMoney(currServ.moneyAvailable) : "N/A"
|
||||||
}`,
|
}`,
|
||||||
);
|
);
|
||||||
if (currServ instanceof Server) {
|
if (currServ instanceof Server) {
|
||||||
@ -449,8 +450,8 @@ export class Terminal implements ITerminal {
|
|||||||
const visited: {
|
const visited: {
|
||||||
[key: string]: number | undefined;
|
[key: string]: number | undefined;
|
||||||
} = {};
|
} = {};
|
||||||
for (const ip in AllServers) {
|
for (const server of GetAllServers()) {
|
||||||
visited[ip] = 0;
|
visited[server.hostname] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stack: BaseServer[] = [];
|
const stack: BaseServer[] = [];
|
||||||
@ -465,12 +466,12 @@ export class Terminal implements ITerminal {
|
|||||||
const isHacknet = s instanceof HacknetServer;
|
const isHacknet = s instanceof HacknetServer;
|
||||||
if (!all && (s as any).purchasedByPlayer && s.hostname != "home") {
|
if (!all && (s as any).purchasedByPlayer && s.hostname != "home") {
|
||||||
continue; // Purchased server
|
continue; // Purchased server
|
||||||
} else if (visited[s.ip] || d > depth) {
|
} else if (visited[s.hostname] || d > depth) {
|
||||||
continue; // Already visited or out-of-depth
|
continue; // Already visited or out-of-depth
|
||||||
} else if (!all && isHacknet) {
|
} else if (!all && isHacknet) {
|
||||||
continue; // Hacknet Server
|
continue; // Hacknet Server
|
||||||
} else {
|
} else {
|
||||||
visited[s.ip] = 1;
|
visited[s.hostname] = 1;
|
||||||
}
|
}
|
||||||
for (let i = s.serversOnNetwork.length - 1; i >= 0; --i) {
|
for (let i = s.serversOnNetwork.length - 1; i >= 0; --i) {
|
||||||
const newS = getServerOnNetwork(s, i);
|
const newS = getServerOnNetwork(s, i);
|
||||||
@ -505,13 +506,13 @@ export class Terminal implements ITerminal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connectToServer(player: IPlayer, server: string): void {
|
connectToServer(player: IPlayer, server: string): void {
|
||||||
const serv = getServer(server);
|
const serv = GetServer(server);
|
||||||
if (serv == null) {
|
if (serv == null) {
|
||||||
this.error("Invalid server. Connection failed.");
|
this.error("Invalid server. Connection failed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.getCurrentServer().isConnectedTo = false;
|
player.getCurrentServer().isConnectedTo = false;
|
||||||
player.currentServer = serv.ip;
|
player.currentServer = serv.hostname;
|
||||||
player.getCurrentServer().isConnectedTo = true;
|
player.getCurrentServer().isConnectedTo = true;
|
||||||
this.print("Connected to " + serv.hostname);
|
this.print("Connected to " + serv.hostname);
|
||||||
this.setcwd("/");
|
this.setcwd("/");
|
||||||
@ -569,7 +570,7 @@ export class Terminal implements ITerminal {
|
|||||||
const s = player.getCurrentServer();
|
const s = player.getCurrentServer();
|
||||||
/****************** Interactive Tutorial Terminal Commands ******************/
|
/****************** Interactive Tutorial Terminal Commands ******************/
|
||||||
if (ITutorial.isRunning) {
|
if (ITutorial.isRunning) {
|
||||||
const n00dlesServ = GetServerByHostname("n00dles");
|
const n00dlesServ = GetServer("n00dles");
|
||||||
if (n00dlesServ == null) {
|
if (n00dlesServ == null) {
|
||||||
throw new Error("Could not get n00dles server");
|
throw new Error("Could not get n00dles server");
|
||||||
return;
|
return;
|
||||||
@ -617,7 +618,10 @@ export class Terminal implements ITerminal {
|
|||||||
break;
|
break;
|
||||||
case iTutorialSteps.TerminalConnect:
|
case iTutorialSteps.TerminalConnect:
|
||||||
if (commandArray.length == 2) {
|
if (commandArray.length == 2) {
|
||||||
if (commandArray[0] == "connect" && (commandArray[1] == "n00dles" || commandArray[1] == n00dlesServ.ip)) {
|
if (
|
||||||
|
commandArray[0] == "connect" &&
|
||||||
|
(commandArray[1] == "n00dles" || commandArray[1] == n00dlesServ.hostname)
|
||||||
|
) {
|
||||||
iTutorialNextStep();
|
iTutorialNextStep();
|
||||||
} else {
|
} else {
|
||||||
this.print("Wrong command! Try again!");
|
this.print("Wrong command! Try again!");
|
||||||
@ -733,7 +737,6 @@ export class Terminal implements ITerminal {
|
|||||||
help: help,
|
help: help,
|
||||||
home: home,
|
home: home,
|
||||||
hostname: hostname,
|
hostname: hostname,
|
||||||
ifconfig: ifconfig,
|
|
||||||
kill: kill,
|
kill: kill,
|
||||||
killall: killall,
|
killall: killall,
|
||||||
ls: ls,
|
ls: ls,
|
||||||
|
@ -3,7 +3,8 @@ import { IRouter } from "../../ui/Router";
|
|||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { BaseServer } from "../../Server/BaseServer";
|
import { BaseServer } from "../../Server/BaseServer";
|
||||||
import { listAllDarkwebItems, buyDarkwebItem } from "../../DarkWeb/DarkWeb";
|
import { listAllDarkwebItems, buyDarkwebItem } from "../../DarkWeb/DarkWeb";
|
||||||
import { SpecialServerIps } from "../../Server/SpecialServerIps";
|
import { SpecialServers } from "../../Server/data/SpecialServers";
|
||||||
|
import { GetServer } from "../../Server/AllServers";
|
||||||
|
|
||||||
export function buy(
|
export function buy(
|
||||||
terminal: ITerminal,
|
terminal: ITerminal,
|
||||||
@ -12,7 +13,7 @@ export function buy(
|
|||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number)[],
|
||||||
): void {
|
): void {
|
||||||
if (!SpecialServerIps.hasOwnProperty("Darkweb Server")) {
|
if (!GetServer(SpecialServers.DarkWeb)) {
|
||||||
terminal.error(
|
terminal.error(
|
||||||
"You need to be able to connect to the Dark Web to use the buy command. (Maybe there's a TOR router you can buy somewhere)",
|
"You need to be able to connect to the Dark Web to use the buy command. (Maybe there's a TOR router you can buy somewhere)",
|
||||||
);
|
);
|
||||||
|
@ -17,13 +17,13 @@ export function connect(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ip = args[0] + "";
|
const hostname = args[0] + "";
|
||||||
|
|
||||||
for (let i = 0; i < server.serversOnNetwork.length; i++) {
|
for (let i = 0; i < server.serversOnNetwork.length; i++) {
|
||||||
const other = getServerOnNetwork(server, i);
|
const other = getServerOnNetwork(server, i);
|
||||||
if (other === null) throw new Error(`Server on network should not be null`);
|
if (other === null) throw new Error(`Server on network should not be null`);
|
||||||
if (other.ip == ip || other.hostname == ip) {
|
if (other.hostname == hostname) {
|
||||||
terminal.connectToServer(player, ip);
|
terminal.connectToServer(player, hostname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export function home(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.getCurrentServer().isConnectedTo = false;
|
player.getCurrentServer().isConnectedTo = false;
|
||||||
player.currentServer = player.getHomeComputer().ip;
|
player.currentServer = player.getHomeComputer().hostname;
|
||||||
player.getCurrentServer().isConnectedTo = true;
|
player.getCurrentServer().isConnectedTo = true;
|
||||||
terminal.print("Connected to home");
|
terminal.print("Connected to home");
|
||||||
terminal.setcwd("/");
|
terminal.setcwd("/");
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
import { ITerminal } from "../ITerminal";
|
|
||||||
import { IRouter } from "../../ui/Router";
|
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
|
||||||
import { BaseServer } from "../../Server/BaseServer";
|
|
||||||
|
|
||||||
export function ifconfig(
|
|
||||||
terminal: ITerminal,
|
|
||||||
router: IRouter,
|
|
||||||
player: IPlayer,
|
|
||||||
server: BaseServer,
|
|
||||||
args: (string | number)[],
|
|
||||||
): void {
|
|
||||||
if (args.length !== 0) {
|
|
||||||
terminal.error("Incorrect usage of ifconfig command. Usage: ifconfig");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
terminal.print(player.getCurrentServer().ip);
|
|
||||||
}
|
|
@ -36,7 +36,7 @@ export function kill(
|
|||||||
terminal.error("No such script is running. Nothing to kill");
|
terminal.error("No such script is running. Nothing to kill");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
killWorkerScript(runningScript, server.ip, false);
|
killWorkerScript(runningScript, server.hostname, false);
|
||||||
terminal.print(`Killing ${scriptName}`);
|
terminal.print(`Killing ${scriptName}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
terminal.error(e + "");
|
terminal.error(e + "");
|
||||||
|
@ -7,7 +7,7 @@ import { WorkerScriptStartStopEventEmitter } from "../../Netscript/WorkerScriptS
|
|||||||
|
|
||||||
export function killall(terminal: ITerminal, router: IRouter, player: IPlayer, server: BaseServer): void {
|
export function killall(terminal: ITerminal, router: IRouter, player: IPlayer, server: BaseServer): void {
|
||||||
for (let i = server.runningScripts.length - 1; i >= 0; --i) {
|
for (let i = server.runningScripts.length - 1; i >= 0; --i) {
|
||||||
killWorkerScript(server.runningScripts[i], server.ip, false);
|
killWorkerScript(server.runningScripts[i], server.hostname, false);
|
||||||
}
|
}
|
||||||
WorkerScriptStartStopEventEmitter.emit();
|
WorkerScriptStartStopEventEmitter.emit();
|
||||||
terminal.print("Killing all running scripts");
|
terminal.print("Killing all running scripts");
|
||||||
|
@ -3,7 +3,7 @@ import { IRouter } from "../../ui/Router";
|
|||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { BaseServer } from "../../Server/BaseServer";
|
import { BaseServer } from "../../Server/BaseServer";
|
||||||
import { Message } from "../../Message/Message";
|
import { Message } from "../../Message/Message";
|
||||||
import { getServer } from "../../Server/ServerHelpers";
|
import { GetServer } from "../../Server/AllServers";
|
||||||
import { isScriptFilename } from "../../Script/isScriptFilename";
|
import { isScriptFilename } from "../../Script/isScriptFilename";
|
||||||
|
|
||||||
export function scp(
|
export function scp(
|
||||||
@ -24,7 +24,7 @@ export function scp(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const destServer = getServer(args[1] + "");
|
const destServer = GetServer(args[1] + "");
|
||||||
if (destServer == null) {
|
if (destServer == null) {
|
||||||
terminal.error(`Invalid destination. ${args[1]} not found`);
|
terminal.error(`Invalid destination. ${args[1]} not found`);
|
||||||
return;
|
return;
|
||||||
|
@ -5,7 +5,7 @@ import { Aliases, GlobalAliases } from "../Alias";
|
|||||||
import { DarkWebItems } from "../DarkWeb/DarkWebItems";
|
import { DarkWebItems } from "../DarkWeb/DarkWebItems";
|
||||||
import { Message } from "../Message/Message";
|
import { Message } from "../Message/Message";
|
||||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
import { AllServers } from "../Server/AllServers";
|
import { GetServer, GetAllServers } from "../Server/AllServers";
|
||||||
|
|
||||||
// An array of all Terminal commands
|
// An array of all Terminal commands
|
||||||
const commands = [
|
const commands = [
|
||||||
@ -223,9 +223,8 @@ export function determineAllPossibilitiesForTabCompletion(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isCommand("scp") && index === 1) {
|
if (isCommand("scp") && index === 1) {
|
||||||
for (const iphostname in AllServers) {
|
for (const server of GetAllServers()) {
|
||||||
allPos.push(AllServers[iphostname].ip);
|
allPos.push(server.hostname);
|
||||||
allPos.push(AllServers[iphostname].hostname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return allPos;
|
return allPos;
|
||||||
@ -243,11 +242,10 @@ export function determineAllPossibilitiesForTabCompletion(
|
|||||||
if (isCommand("connect")) {
|
if (isCommand("connect")) {
|
||||||
// All network connections
|
// All network connections
|
||||||
for (let i = 0; i < currServ.serversOnNetwork.length; ++i) {
|
for (let i = 0; i < currServ.serversOnNetwork.length; ++i) {
|
||||||
const serv = AllServers[currServ.serversOnNetwork[i]];
|
const serv = GetServer(currServ.serversOnNetwork[i]);
|
||||||
if (serv == null) {
|
if (serv == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
allPos.push(serv.ip);
|
|
||||||
allPos.push(serv.hostname);
|
allPos.push(serv.hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ import { initForeignServers } from "./Server/AllServers";
|
|||||||
import { Settings } from "./Settings/Settings";
|
import { Settings } from "./Settings/Settings";
|
||||||
import { ThemeEvents } from "./ui/React/Theme";
|
import { ThemeEvents } from "./ui/React/Theme";
|
||||||
import { updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
|
import { updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||||
import { initSpecialServerIps } from "./Server/SpecialServerIps";
|
|
||||||
import { initSymbolToStockMap, processStockPrices } from "./StockMarket/StockMarket";
|
import { initSymbolToStockMap, processStockPrices } from "./StockMarket/StockMarket";
|
||||||
import { Terminal } from "./Terminal";
|
import { Terminal } from "./Terminal";
|
||||||
import { Sleeve } from "./PersonObjects/Sleeve/Sleeve";
|
import { Sleeve } from "./PersonObjects/Sleeve/Sleeve";
|
||||||
@ -409,7 +408,6 @@ const Engine: {
|
|||||||
} else {
|
} else {
|
||||||
// No save found, start new game
|
// No save found, start new game
|
||||||
initBitNodeMultipliers(Player);
|
initBitNodeMultipliers(Player);
|
||||||
initSpecialServerIps();
|
|
||||||
Engine.start(); // Run main game loop and Scripts loop
|
Engine.start(); // Run main game loop and Scripts loop
|
||||||
Player.init();
|
Player.init();
|
||||||
initForeignServers(Player.getHomeComputer());
|
initForeignServers(Player.getHomeComputer());
|
||||||
|
@ -11,7 +11,7 @@ import List from "@mui/material/List";
|
|||||||
import TablePagination from "@mui/material/TablePagination";
|
import TablePagination from "@mui/material/TablePagination";
|
||||||
import { WorkerScript } from "../../Netscript/WorkerScript";
|
import { WorkerScript } from "../../Netscript/WorkerScript";
|
||||||
import { WorkerScriptStartStopEventEmitter } from "../../Netscript/WorkerScriptStartStopEventEmitter";
|
import { WorkerScriptStartStopEventEmitter } from "../../Netscript/WorkerScriptStartStopEventEmitter";
|
||||||
import { getServer } from "../../Server/ServerHelpers";
|
import { GetServer } from "../../Server/AllServers";
|
||||||
import { BaseServer } from "../../Server/BaseServer";
|
import { BaseServer } from "../../Server/BaseServer";
|
||||||
import { Settings } from "../../Settings/Settings";
|
import { Settings } from "../../Settings/Settings";
|
||||||
import { TablePaginationActionsAll } from "../React/TablePaginationActionsAll";
|
import { TablePaginationActionsAll } from "../React/TablePaginationActionsAll";
|
||||||
@ -54,9 +54,9 @@ export function ServerAccordions(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
const serverToScriptMap: IServerToScriptsMap = {};
|
const serverToScriptMap: IServerToScriptsMap = {};
|
||||||
for (const ws of props.workerScripts.values()) {
|
for (const ws of props.workerScripts.values()) {
|
||||||
const server = getServer(ws.serverIp);
|
const server = GetServer(ws.hostname);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
console.warn(`WorkerScript has invalid IP address: ${ws.serverIp}`);
|
console.warn(`WorkerScript has invalid IP address: ${ws.hostname}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import { ITutorialEvents } from "./InteractiveTutorial/ITutorialEvents";
|
|||||||
import { Faction } from "../Faction/Faction";
|
import { Faction } from "../Faction/Faction";
|
||||||
import { prestigeAugmentation } from "../Prestige";
|
import { prestigeAugmentation } from "../Prestige";
|
||||||
import { dialogBoxCreate } from "./React/DialogBox";
|
import { dialogBoxCreate } from "./React/DialogBox";
|
||||||
import { AllServers } from "../Server/AllServers";
|
import { GetAllServers } from "../Server/AllServers";
|
||||||
import { Factions } from "../Faction/Factions";
|
import { Factions } from "../Faction/Factions";
|
||||||
import { buyStock, sellStock, shortStock, sellShort } from "../StockMarket/BuyingAndSelling";
|
import { buyStock, sellStock, shortStock, sellShort } from "../StockMarket/BuyingAndSelling";
|
||||||
import {
|
import {
|
||||||
@ -356,8 +356,8 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
|
|||||||
save={() => saveObject.saveGame()}
|
save={() => saveObject.saveGame()}
|
||||||
export={() => saveObject.exportGame()}
|
export={() => saveObject.exportGame()}
|
||||||
forceKill={() => {
|
forceKill={() => {
|
||||||
for (const hostname of Object.keys(AllServers)) {
|
for (const server of GetAllServers()) {
|
||||||
AllServers[hostname].runningScripts = [];
|
server.runningScripts = [];
|
||||||
}
|
}
|
||||||
dialogBoxCreate("Forcefully deleted all running scripts. Please save and refresh page.");
|
dialogBoxCreate("Forcefully deleted all running scripts. Please save and refresh page.");
|
||||||
}}
|
}}
|
||||||
|
@ -8,7 +8,6 @@ import Button from "@mui/material/Button";
|
|||||||
import Paper from "@mui/material/Paper";
|
import Paper from "@mui/material/Paper";
|
||||||
import Draggable from "react-draggable";
|
import Draggable from "react-draggable";
|
||||||
import { ResizableBox } from "react-resizable";
|
import { ResizableBox } from "react-resizable";
|
||||||
import { Theme } from "@mui/material";
|
|
||||||
import makeStyles from "@mui/styles/makeStyles";
|
import makeStyles from "@mui/styles/makeStyles";
|
||||||
import createStyles from "@mui/styles/createStyles";
|
import createStyles from "@mui/styles/createStyles";
|
||||||
import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
|
import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
|
||||||
|
@ -4,8 +4,9 @@
|
|||||||
* Configurable to only contain certain types of servers
|
* Configurable to only contain certain types of servers
|
||||||
*/
|
*/
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { AllServers } from "../../Server/AllServers";
|
import { GetAllServers } from "../../Server/AllServers";
|
||||||
import { Server } from "../../Server/Server";
|
import { Server } from "../../Server/Server";
|
||||||
|
import { BaseServer } from "../../Server/BaseServer";
|
||||||
|
|
||||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
||||||
import Select, { SelectChangeEvent } from "@mui/material/Select";
|
import Select, { SelectChangeEvent } from "@mui/material/Select";
|
||||||
@ -30,7 +31,7 @@ export function ServerDropdown(props: IProps): React.ReactElement {
|
|||||||
* Checks if the server should be shown in the dropdown menu, based on the
|
* Checks if the server should be shown in the dropdown menu, based on the
|
||||||
* 'serverType' property
|
* 'serverType' property
|
||||||
*/
|
*/
|
||||||
function isValidServer(s: Server | HacknetServer): boolean {
|
function isValidServer(s: BaseServer): boolean {
|
||||||
const purchased = s instanceof Server && s.purchasedByPlayer;
|
const purchased = s instanceof Server && s.purchasedByPlayer;
|
||||||
const type = props.serverType;
|
const type = props.serverType;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -49,8 +50,7 @@ export function ServerDropdown(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const servers = [];
|
const servers = [];
|
||||||
for (const serverName in AllServers) {
|
for (const server of GetAllServers()) {
|
||||||
const server = AllServers[serverName];
|
|
||||||
if (isValidServer(server)) {
|
if (isValidServer(server)) {
|
||||||
servers.push(
|
servers.push(
|
||||||
<MenuItem key={server.hostname} value={server.hostname}>
|
<MenuItem key={server.hostname} value={server.hostname}>
|
||||||
|
Loading…
Reference in New Issue
Block a user