mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-23 14:42:28 +01:00
unexport AllServers
This commit is contained in:
parent
1d488565c6
commit
be29481689
@ -6,11 +6,11 @@ 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 { GetAllServers } from "./Server/AllServers";
|
||||||
import { GetServerByHostname } from "./Server/ServerHelpers";
|
import { getServer } from "./Server/ServerHelpers";
|
||||||
import { SpecialServerNames } from "./Server/SpecialServerIps";
|
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 +68,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 +162,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
|
||||||
@ -181,13 +178,13 @@ function getRandomServer(): Server | HacknetServer {
|
|||||||
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) {
|
||||||
|
@ -8,8 +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 { GetAllServers } from "../../Server/AllServers";
|
||||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
import { Server } from "../../Server/Server";
|
||||||
import { GetServerByHostname } from "../../Server/ServerHelpers";
|
import { GetServerByHostname } from "../../Server/ServerHelpers";
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ export function Servers(): React.ReactElement {
|
|||||||
function rootServer(): void {
|
function rootServer(): void {
|
||||||
const s = GetServerByHostname(server);
|
const s = GetServerByHostname(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 +32,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;
|
||||||
@ -48,30 +47,28 @@ export function Servers(): React.ReactElement {
|
|||||||
function minSecurity(): void {
|
function minSecurity(): void {
|
||||||
const s = GetServerByHostname(server);
|
const s = GetServerByHostname(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 = GetServerByHostname(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 +86,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,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { AllServers } from "../Server/AllServers";
|
import { GetAllServers } from "../Server/AllServers";
|
||||||
|
import { getServer } from "../Server/ServerHelpers";
|
||||||
import { Modal } from "../ui/React/Modal";
|
import { Modal } from "../ui/React/Modal";
|
||||||
import { numeralWrapper } from "../ui/numeralFormat";
|
import { numeralWrapper } from "../ui/numeralFormat";
|
||||||
|
|
||||||
@ -21,7 +22,8 @@ interface IServerProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ServerAccordion(props: IServerProps): React.ReactElement {
|
function ServerAccordion(props: IServerProps): React.ReactElement {
|
||||||
const server = AllServers[props.ip];
|
const server = getServer(props.ip);
|
||||||
|
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 +100,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,7 +112,7 @@ 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((ip: string) => (
|
||||||
<ServerAccordion key={ip} ip={ip} />
|
<ServerAccordion key={ip} ip={ip} />
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
@ -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 { GetServerByHostname, getServer } from "../Server/ServerHelpers";
|
||||||
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;
|
||||||
|
@ -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,7 +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/ServerHelpers";
|
||||||
import { Server } from "../../Server/Server";
|
import { Server } from "../../Server/Server";
|
||||||
|
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
@ -50,8 +51,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 +89,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}
|
||||||
|
@ -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/ServerHelpers";
|
||||||
import { BaseServer } from "../Server/BaseServer";
|
import { BaseServer } from "../Server/BaseServer";
|
||||||
import { IMap } from "../types";
|
import { IMap } from "../types";
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ 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.serverIp);
|
||||||
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.serverIp}`);
|
||||||
}
|
}
|
||||||
@ -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.serverIp);
|
||||||
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,7 +7,7 @@ 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/ServerHelpers";
|
||||||
|
|
||||||
import { compareArrays } from "../utils/helpers/compareArrays";
|
import { compareArrays } from "../utils/helpers/compareArrays";
|
||||||
import { roundToTwo } from "../utils/helpers/roundToTwo";
|
import { roundToTwo } from "../utils/helpers/roundToTwo";
|
||||||
@ -84,7 +84,7 @@ function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void
|
|||||||
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/ServerHelpers";
|
||||||
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,7 +14,7 @@ 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.serverIp);
|
||||||
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.serverIp}`);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ 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 { GetAllServers, DeleteServer, AddToAllServers, createUniqueRandomIp } from "./Server/AllServers";
|
||||||
import { RunningScript } from "./Script/RunningScript";
|
import { RunningScript } from "./Script/RunningScript";
|
||||||
import {
|
import {
|
||||||
GetServerByHostname,
|
GetServerByHostname,
|
||||||
@ -301,8 +301,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;
|
||||||
}
|
}
|
||||||
@ -2257,7 +2256,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;
|
||||||
|
@ -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/ServerHelpers";
|
||||||
|
|
||||||
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(
|
||||||
|
@ -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";
|
||||||
|
|
||||||
@ -600,10 +600,7 @@ 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)) {
|
|
||||||
const server = AllServers[property];
|
|
||||||
|
|
||||||
// Reset each server's RAM usage to 0
|
// Reset each server's RAM usage to 0
|
||||||
server.ramUsed = 0;
|
server.ramUsed = 0;
|
||||||
|
|
||||||
@ -625,7 +622,6 @@ export function loadAllRunningScripts(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a script from inside another script (run(), exec(), spawn(), etc.)
|
* Run a script from inside another script (run(), exec(), spawn(), etc.)
|
||||||
|
@ -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";
|
||||||
@ -185,7 +186,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";
|
||||||
@ -192,7 +193,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;
|
||||||
|
@ -32,9 +32,9 @@ import {
|
|||||||
getFactionSecurityWorkRepGain,
|
getFactionSecurityWorkRepGain,
|
||||||
getFactionFieldWorkRepGain,
|
getFactionFieldWorkRepGain,
|
||||||
} from "../formulas/reputation";
|
} from "../formulas/reputation";
|
||||||
import { AllServers, AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers";
|
import { AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers";
|
||||||
import { Server } from "../../Server/Server";
|
import { Server } from "../../Server/Server";
|
||||||
import { safetlyCreateUniqueServer } from "../../Server/ServerHelpers";
|
import { safetlyCreateUniqueServer, getServer } from "../../Server/ServerHelpers";
|
||||||
import { Settings } from "../../Settings/Settings";
|
import { Settings } from "../../Settings/Settings";
|
||||||
import { SpecialServerIps, SpecialServerNames } from "../../Server/SpecialServerIps";
|
import { SpecialServerIps, SpecialServerNames } from "../../Server/SpecialServerIps";
|
||||||
import { applySourceFile } from "../../SourceFile/applySourceFile";
|
import { applySourceFile } from "../../SourceFile/applySourceFile";
|
||||||
@ -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";
|
||||||
|
|
||||||
@ -578,7 +579,7 @@ 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 specialIp = SpecialServerIps[this.companyName];
|
||||||
if (typeof specialIp === "string" && specialIp !== "") {
|
if (typeof specialIp === "string" && specialIp !== "") {
|
||||||
const server = AllServers[specialIp];
|
const server = getServer(specialIp);
|
||||||
if (server instanceof Server) {
|
if (server instanceof Server) {
|
||||||
if (server && server.backdoorInstalled) return 0.75;
|
if (server && server.backdoorInstalled) return 0.75;
|
||||||
}
|
}
|
||||||
@ -2193,7 +2194,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
const fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"];
|
const fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"];
|
||||||
const fulcrumIP = SpecialServerIps[SpecialServerNames.BitRunnersServer];
|
const fulcrumIP = SpecialServerIps[SpecialServerNames.BitRunnersServer];
|
||||||
if (typeof fulcrumIP !== "string") throw new Error("Fulcrum Secret Technologies should be string");
|
if (typeof fulcrumIP !== "string") throw new Error("Fulcrum Secret Technologies should be string");
|
||||||
const fulcrumSecretServer = AllServers[fulcrumIP];
|
const fulcrumSecretServer = getServer(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");
|
||||||
@ -2213,7 +2214,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
const bitrunnersFac = Factions["BitRunners"];
|
const bitrunnersFac = Factions["BitRunners"];
|
||||||
const bitrunnerIP = SpecialServerIps[SpecialServerNames.BitRunnersServer];
|
const bitrunnerIP = SpecialServerIps[SpecialServerNames.BitRunnersServer];
|
||||||
if (typeof bitrunnerIP !== "string") throw new Error("BitRunners should be string");
|
if (typeof bitrunnerIP !== "string") throw new Error("BitRunners should be string");
|
||||||
const bitrunnersServer = AllServers[bitrunnerIP];
|
const bitrunnersServer = getServer(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");
|
||||||
@ -2231,7 +2232,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
const theblackhandFac = Factions["The Black Hand"];
|
const theblackhandFac = Factions["The Black Hand"];
|
||||||
const tbhIP = SpecialServerIps[SpecialServerNames.TheBlackHandServer];
|
const tbhIP = SpecialServerIps[SpecialServerNames.TheBlackHandServer];
|
||||||
if (typeof tbhIP !== "string") throw new Error("TheBlackHand should be string");
|
if (typeof tbhIP !== "string") throw new Error("TheBlackHand should be string");
|
||||||
const blackhandServer = AllServers[tbhIP];
|
const blackhandServer = getServer(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");
|
||||||
@ -2248,7 +2249,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
const nitesecFac = Factions["NiteSec"];
|
const nitesecFac = Factions["NiteSec"];
|
||||||
const nitesecIP = SpecialServerIps[SpecialServerNames.NiteSecServer];
|
const nitesecIP = SpecialServerIps[SpecialServerNames.NiteSecServer];
|
||||||
if (typeof nitesecIP !== "string") throw new Error("NiteSec should be string");
|
if (typeof nitesecIP !== "string") throw new Error("NiteSec should be string");
|
||||||
const nitesecServer = AllServers[nitesecIP];
|
const nitesecServer = getServer(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 +2448,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;
|
||||||
@ -2487,7 +2489,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
|||||||
const cybersecFac = Factions["CyberSec"];
|
const cybersecFac = Factions["CyberSec"];
|
||||||
const cyberSecIP = SpecialServerIps[SpecialServerNames.CyberSecServer];
|
const cyberSecIP = SpecialServerIps[SpecialServerNames.CyberSecServer];
|
||||||
if (typeof cyberSecIP !== "string") throw new Error("cybersec should be string");
|
if (typeof cyberSecIP !== "string") throw new Error("cybersec should be string");
|
||||||
const cybersecServer = AllServers[cyberSecIP];
|
const cybersecServer = getServer(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,24 @@ 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 { AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers";
|
||||||
|
import { getServer } from "../../Server/ServerHelpers";
|
||||||
import { SpecialServerIps } from "../../Server/SpecialServerIps";
|
import { SpecialServerIps } from "../../Server/SpecialServerIps";
|
||||||
|
|
||||||
export function hasTorRouter(this: IPlayer): boolean {
|
export function hasTorRouter(this: IPlayer): boolean {
|
||||||
return SpecialServerIps.hasOwnProperty("Darkweb Server");
|
return SpecialServerIps.hasOwnProperty("Darkweb Server");
|
||||||
}
|
}
|
||||||
|
|
||||||
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(this.homeComputer);
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ 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 { AddToAllServers, initForeignServers, prestigeAllServers } from "./Server/AllServers";
|
||||||
import { prestigeHomeComputer } from "./Server/ServerHelpers";
|
import { prestigeHomeComputer, getServer } from "./Server/ServerHelpers";
|
||||||
import { SourceFileFlags, updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
|
import { SourceFileFlags, updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||||
import { SpecialServerIps, prestigeSpecialServerIps, SpecialServerNames } from "./Server/SpecialServerIps";
|
import { SpecialServerIps, prestigeSpecialServerIps, SpecialServerNames } from "./Server/SpecialServerIps";
|
||||||
import { deleteStockMarket, initStockMarket, initSymbolToStockMap } from "./StockMarket/StockMarket";
|
import { deleteStockMarket, initStockMarket, initSymbolToStockMap } from "./StockMarket/StockMarket";
|
||||||
@ -133,10 +133,10 @@ function prestigeAugmentation(): void {
|
|||||||
if (augmentationExists(AugmentationNames.TheRedPill) && Augmentations[AugmentationNames.TheRedPill].owned) {
|
if (augmentationExists(AugmentationNames.TheRedPill) && Augmentations[AugmentationNames.TheRedPill].owned) {
|
||||||
const WorldDaemonIP = SpecialServerIps[SpecialServerNames.WorldDaemon];
|
const WorldDaemonIP = SpecialServerIps[SpecialServerNames.WorldDaemon];
|
||||||
if (typeof WorldDaemonIP !== "string") throw new Error("WorldDaemonIP should be string");
|
if (typeof WorldDaemonIP !== "string") throw new Error("WorldDaemonIP should be string");
|
||||||
const WorldDaemon = AllServers[WorldDaemonIP];
|
const WorldDaemon = getServer(WorldDaemonIP);
|
||||||
const DaedalusServerIP = SpecialServerIps[SpecialServerNames.DaedalusServer];
|
const DaedalusServerIP = SpecialServerIps[SpecialServerNames.DaedalusServer];
|
||||||
if (typeof DaedalusServerIP !== "string") throw new Error("DaedalusServerIP should be string");
|
if (typeof DaedalusServerIP !== "string") throw new Error("DaedalusServerIP should be string");
|
||||||
const DaedalusServer = AllServers[DaedalusServerIP];
|
const DaedalusServer = getServer(DaedalusServerIP);
|
||||||
if (WorldDaemon && DaedalusServer) {
|
if (WorldDaemon && DaedalusServer) {
|
||||||
WorldDaemon.serversOnNetwork.push(DaedalusServer.ip);
|
WorldDaemon.serversOnNetwork.push(DaedalusServer.ip);
|
||||||
DaedalusServer.serversOnNetwork.push(WorldDaemon.ip);
|
DaedalusServer.serversOnNetwork.push(WorldDaemon.ip);
|
||||||
|
@ -230,8 +230,8 @@ export const programsMetadata: IProgramCreationParams[] = [
|
|||||||
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,7 +5,7 @@ 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 { loadSpecialServerIps, SpecialServerIps } from "./Server/SpecialServerIps";
|
||||||
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
|
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||||
@ -41,21 +41,7 @@ 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.SpecialServerIpsSave = JSON.stringify(SpecialServerIps);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AllServers } from "../Server/AllServers";
|
import { getServer } from "../Server/ServerHelpers";
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
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, getServer } from "../Server/ServerHelpers";
|
||||||
|
|
||||||
import { numeralWrapper } from "../ui/numeralFormat";
|
import { numeralWrapper } from "../ui/numeralFormat";
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
|||||||
if (runningScript.dataMap[ip][2] == 0 || runningScript.dataMap[ip][2] == null) {
|
if (runningScript.dataMap[ip][2] == 0 || runningScript.dataMap[ip][2] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const serv = AllServers[ip];
|
const serv = getServer(ip);
|
||||||
if (serv == null) {
|
if (serv == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -40,7 +39,8 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
|||||||
((0.5 * runningScript.dataMap[ip][2]) / runningScript.onlineRunningTime) * timePassed,
|
((0.5 * runningScript.dataMap[ip][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(
|
||||||
@ -64,13 +64,14 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
|||||||
if (runningScript.dataMap[ip][3] == 0 || runningScript.dataMap[ip][3] == null) {
|
if (runningScript.dataMap[ip][3] == 0 || runningScript.dataMap[ip][3] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const serv = AllServers[ip];
|
const serv = getServer(ip);
|
||||||
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[ip][3]) / runningScript.onlineRunningTime) * timePassed,
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Server } from "./Server";
|
import { Server } from "./Server";
|
||||||
|
import { BaseServer } from "./BaseServer";
|
||||||
import { SpecialServerIps } from "./SpecialServerIps";
|
import { SpecialServerIps } from "./SpecialServerIps";
|
||||||
import { serverMetadata } from "./data/servers";
|
import { serverMetadata } from "./data/servers";
|
||||||
|
|
||||||
@ -14,7 +15,28 @@ import { Reviver } from "../utils/JSONReviver";
|
|||||||
* Key (string) = IP
|
* Key (string) = IP
|
||||||
* Value = Server object
|
* Value = Server object
|
||||||
*/
|
*/
|
||||||
export let AllServers: IMap<Server | HacknetServer> = {};
|
let AllServers: IMap<Server | HacknetServer> = {};
|
||||||
|
|
||||||
|
export function GetServerByIP(ip: string): Server | HacknetServer | undefined {
|
||||||
|
return AllServers[ip];
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
@ -148,5 +170,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);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AllServers, createUniqueRandomIp, ipExists } from "./AllServers";
|
import { GetAllServers, GetServerByIP, 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";
|
||||||
@ -121,12 +121,10 @@ export function prestigeHomeComputer(homeComp: Server): void {
|
|||||||
|
|
||||||
//Returns server object with corresponding hostname
|
//Returns server object with corresponding hostname
|
||||||
// Relatively slow, would rather not use this a lot
|
// Relatively slow, would rather not use this a lot
|
||||||
export function GetServerByHostname(hostname: string): Server | HacknetServer | null {
|
export function GetServerByHostname(hostname: string): BaseServer | null {
|
||||||
for (const ip in AllServers) {
|
for (const server of GetAllServers()) {
|
||||||
if (AllServers.hasOwnProperty(ip)) {
|
if (server.hostname == hostname) {
|
||||||
if (AllServers[ip].hostname == hostname) {
|
return server;
|
||||||
return AllServers[ip];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,12 +132,13 @@ export function GetServerByHostname(hostname: string): Server | HacknetServer |
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Get server by IP or hostname. Returns null if invalid
|
//Get server by IP or hostname. Returns null if invalid
|
||||||
export function getServer(s: string): Server | HacknetServer | null {
|
export function getServer(s: string): BaseServer | null {
|
||||||
if (!isValidIPAddress(s)) {
|
if (!isValidIPAddress(s)) {
|
||||||
return GetServerByHostname(s);
|
return GetServerByHostname(s);
|
||||||
}
|
}
|
||||||
if (AllServers[s] !== undefined) {
|
const server = GetServerByIP(s);
|
||||||
return AllServers[s];
|
if (server !== undefined) {
|
||||||
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -148,17 +147,17 @@ export function getServer(s: string): Server | HacknetServer | 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;
|
||||||
|
@ -12,7 +12,7 @@ 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 { 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";
|
||||||
@ -116,6 +116,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 +126,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 +135,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 +146,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 +167,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);
|
||||||
@ -218,6 +223,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 +241,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,6 +258,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");
|
||||||
if (
|
if (
|
||||||
SpecialServerIps[SpecialServerNames.WorldDaemon] &&
|
SpecialServerIps[SpecialServerNames.WorldDaemon] &&
|
||||||
SpecialServerIps[SpecialServerNames.WorldDaemon] == server.ip
|
SpecialServerIps[SpecialServerNames.WorldDaemon] == server.ip
|
||||||
@ -287,7 +295,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 +457,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 +473,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);
|
||||||
|
@ -5,7 +5,8 @@ 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 { GetAllServers } from "../Server/AllServers";
|
||||||
|
import { getServer } from "../Server/ServerHelpers";
|
||||||
|
|
||||||
// An array of all Terminal commands
|
// An array of all Terminal commands
|
||||||
const commands = [
|
const commands = [
|
||||||
@ -223,9 +224,9 @@ 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.ip);
|
||||||
allPos.push(AllServers[iphostname].hostname);
|
allPos.push(server.hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return allPos;
|
return allPos;
|
||||||
@ -243,7 +244,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -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