mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 04:05:46 +01:00
finish convert to hostname
This commit is contained in:
parent
2958034ad4
commit
7d0536a4d2
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
@ -7,7 +7,7 @@ import {
|
||||
import { Factions } from "./Faction/Factions";
|
||||
import { Player } from "./Player";
|
||||
import { GetServer, GetAllServers } from "./Server/AllServers";
|
||||
import { SpecialServerNames } from "./Server/SpecialServerIps";
|
||||
import { SpecialServers } from "./Server/data/SpecialServers";
|
||||
import { Server } from "./Server/Server";
|
||||
import { BaseServer } from "./Server/BaseServer";
|
||||
|
||||
@ -172,7 +172,7 @@ function getRandomServer(): BaseServer {
|
||||
if (
|
||||
randServer instanceof Server &&
|
||||
!randServer.purchasedByPlayer &&
|
||||
randServer.hostname !== SpecialServerNames.WorldDaemon
|
||||
randServer.hostname !== SpecialServers.WorldDaemon
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
@ -2,26 +2,18 @@ import { DarkWebItems } from "./DarkWebItems";
|
||||
|
||||
import { Player } from "../Player";
|
||||
import { Terminal } from "../Terminal";
|
||||
import { SpecialServerIps } from "../Server/SpecialServerIps";
|
||||
import { SpecialServers } from "../Server/data/SpecialServers";
|
||||
import { numeralWrapper } from "../ui/numeralFormat";
|
||||
|
||||
import { isValidIPAddress } from "../utils/helpers/isValidIPAddress";
|
||||
|
||||
//Posts a "help" message if connected to DarkWeb
|
||||
export function checkIfConnectedToDarkweb(): void {
|
||||
if (SpecialServerIps.hasOwnProperty("Darkweb Server")) {
|
||||
const darkwebIp = SpecialServerIps.getIp("Darkweb Server");
|
||||
if (!isValidIPAddress(darkwebIp)) {
|
||||
return;
|
||||
}
|
||||
const server = Player.getCurrentServer();
|
||||
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.",
|
||||
);
|
||||
}
|
||||
const server = Player.getCurrentServer();
|
||||
if (server !== null && SpecialServers.DarkWeb == server.hostname) {
|
||||
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.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,11 +17,11 @@ import AccordionDetails from "@mui/material/AccordionDetails";
|
||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||
|
||||
interface IServerProps {
|
||||
ip: string;
|
||||
hostname: string;
|
||||
}
|
||||
|
||||
function ServerAccordion(props: IServerProps): React.ReactElement {
|
||||
const server = GetServer(props.ip);
|
||||
const server = GetServer(props.hostname);
|
||||
if (server === null) throw new Error("server should not be null");
|
||||
let totalSize = 0;
|
||||
for (const f of server.scripts) {
|
||||
@ -111,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
|
||||
text/scripts. This tool can help you narrow down where they are.
|
||||
</Typography>
|
||||
{keys.map((ip: string) => (
|
||||
<ServerAccordion key={ip} ip={ip} />
|
||||
{keys.map((hostname: string) => (
|
||||
<ServerAccordion key={hostname} hostname={hostname} />
|
||||
))}
|
||||
</>
|
||||
</Modal>
|
||||
|
@ -7,7 +7,6 @@ import { CONSTANTS } from "../Constants";
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { AddToAllServers, createUniqueRandomIp } from "../Server/AllServers";
|
||||
import { safetlyCreateUniqueServer } from "../Server/ServerHelpers";
|
||||
import { SpecialServerIps } from "../Server/SpecialServerIps";
|
||||
|
||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||
|
||||
@ -36,10 +35,9 @@ export function purchaseTorRouter(p: IPlayer): void {
|
||||
maxRam: 1,
|
||||
});
|
||||
AddToAllServers(darkweb);
|
||||
SpecialServerIps.addIp("Darkweb Server", darkweb.ip);
|
||||
|
||||
p.getHomeComputer().serversOnNetwork.push(darkweb.ip);
|
||||
darkweb.serversOnNetwork.push(p.getHomeComputer().ip);
|
||||
p.getHomeComputer().serversOnNetwork.push(darkweb.hostname);
|
||||
darkweb.serversOnNetwork.push(p.getHomeComputer().hostname);
|
||||
dialogBoxCreate(
|
||||
"You have purchased a TOR router!<br>" +
|
||||
"You now have access to the dark web from your home computer.<br>" +
|
||||
|
@ -104,11 +104,11 @@ export class WorkerScript {
|
||||
/**
|
||||
* IP Address on which this script is running
|
||||
*/
|
||||
serverIp: string;
|
||||
hostname: string;
|
||||
|
||||
constructor(runningScriptObj: RunningScript, pid: number, nsFuncsGenerator?: (ws: WorkerScript) => any) {
|
||||
this.name = runningScriptObj.filename;
|
||||
this.serverIp = runningScriptObj.server;
|
||||
this.hostname = runningScriptObj.server;
|
||||
|
||||
const sanitizedPid = Math.round(pid);
|
||||
if (typeof sanitizedPid !== "number" || isNaN(sanitizedPid)) {
|
||||
@ -118,9 +118,9 @@ export class WorkerScript {
|
||||
runningScriptObj.pid = sanitizedPid;
|
||||
|
||||
// Get the underlying script's code
|
||||
const server = GetServer(this.serverIp);
|
||||
const server = GetServer(this.hostname);
|
||||
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;
|
||||
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
|
||||
*/
|
||||
getServer(): BaseServer {
|
||||
const server = GetServer(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?`);
|
||||
return server;
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ import { GetServer } from "../Server/AllServers";
|
||||
import { compareArrays } from "../utils/helpers/compareArrays";
|
||||
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(pid: number): boolean;
|
||||
export function killWorkerScript(
|
||||
script: RunningScript | WorkerScript | number,
|
||||
serverIp?: string,
|
||||
hostname?: string,
|
||||
rerenderUi?: boolean,
|
||||
): boolean {
|
||||
if (rerenderUi == null || typeof rerenderUi !== "boolean") {
|
||||
@ -28,7 +28,7 @@ export function killWorkerScript(
|
||||
stopAndCleanUpWorkerScript(script);
|
||||
|
||||
return true;
|
||||
} else if (script instanceof RunningScript && typeof serverIp === "string") {
|
||||
} else if (script instanceof RunningScript && typeof hostname === "string") {
|
||||
// Try to kill by PID
|
||||
const res = killWorkerScriptByPid(script.pid, rerenderUi);
|
||||
if (res) {
|
||||
@ -37,7 +37,7 @@ export function killWorkerScript(
|
||||
|
||||
// If for some reason that doesn't work, we'll try the old way
|
||||
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);
|
||||
|
||||
return true;
|
||||
@ -80,7 +80,7 @@ function stopAndCleanUpWorkerScript(workerScript: WorkerScript, rerenderUi = tru
|
||||
*/
|
||||
function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void {
|
||||
if (workerScript instanceof WorkerScript) {
|
||||
const ip = workerScript.serverIp;
|
||||
const ip = workerScript.hostname;
|
||||
const name = workerScript.name;
|
||||
|
||||
// Get the server on which the script runs
|
||||
|
@ -14,9 +14,9 @@ export function netscriptDelay(time: number, workerScript: WorkerScript): Promis
|
||||
|
||||
export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): string {
|
||||
const lineNum = "";
|
||||
const server = GetServer(workerScript.serverIp);
|
||||
const server = GetServer(workerScript.hostname);
|
||||
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;
|
||||
|
@ -99,7 +99,6 @@ import {
|
||||
} from "./Server/ServerHelpers";
|
||||
import { getPurchaseServerCost, getPurchaseServerLimit, getPurchaseServerMaxRam } from "./Server/ServerPurchases";
|
||||
import { Server } from "./Server/Server";
|
||||
import { SpecialServerIps } from "./Server/SpecialServerIps";
|
||||
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||
import { buyStock, sellStock, shortStock, sellShort } from "./StockMarket/BuyingAndSelling";
|
||||
import { influenceStockThroughServerHack, influenceStockThroughServerGrow } from "./StockMarket/PlayerInfluencing";
|
||||
@ -137,7 +136,6 @@ import { IIndustry } from "./Corporation/IIndustry";
|
||||
|
||||
import { Faction } from "./Faction/Faction";
|
||||
import { Augmentation } from "./Augmentation/Augmentation";
|
||||
import { HacknetNode } from "./Hacknet/HacknetNode";
|
||||
|
||||
import { CodingContract } from "./CodingContracts";
|
||||
import { Stock } from "./StockMarket/Stock";
|
||||
@ -198,7 +196,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
let threads = workerScript.scriptRef.threads;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -271,7 +269,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
if (fn != null && typeof fn === "string") {
|
||||
// Get Logs of another script
|
||||
if (ip == null) {
|
||||
ip = workerScript.serverIp;
|
||||
ip = workerScript.hostname;
|
||||
}
|
||||
const server = safeGetServer(ip, callingFnName);
|
||||
|
||||
@ -649,7 +647,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
workerScript.scriptRef.onlineMoneyMade += moneyGained;
|
||||
Player.scriptProdSinceLastAug += moneyGained;
|
||||
Player.recordMoneySource(moneyGained, "hacking");
|
||||
workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
|
||||
workerScript.scriptRef.recordHack(server.hostname, moneyGained, threads);
|
||||
Player.gainHackingExp(expGainedOnSuccess);
|
||||
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
|
||||
workerScript.log(
|
||||
@ -722,7 +720,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
hacknet: hacknet,
|
||||
sprintf: sprintf,
|
||||
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"));
|
||||
const server = GetServer(ip);
|
||||
if (server == null) {
|
||||
@ -736,7 +734,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
if (hostnames) {
|
||||
entry = s.hostname;
|
||||
} else {
|
||||
entry = s.ip;
|
||||
entry = s.hostname;
|
||||
}
|
||||
if (entry == null) {
|
||||
continue;
|
||||
@ -820,7 +818,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
throw makeRuntimeErrorMsg("grow", `Invalid IP/hostname: ${ip}.`);
|
||||
}
|
||||
|
||||
const host = GetServer(workerScript.serverIp);
|
||||
const host = GetServer(workerScript.hostname);
|
||||
if (host === null) {
|
||||
throw new Error("Workerscript host is null");
|
||||
}
|
||||
@ -846,7 +844,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
const moneyBefore = server.moneyAvailable <= 0 ? 1 : server.moneyAvailable;
|
||||
processSingleServerGrowth(server, threads, Player, host.cpuCores);
|
||||
const moneyAfter = server.moneyAvailable;
|
||||
workerScript.scriptRef.recordGrow(server.ip, threads);
|
||||
workerScript.scriptRef.recordGrow(server.hostname, threads);
|
||||
const expGain = calculateHackingExpGain(server, Player) * threads;
|
||||
const logGrowPercent = moneyAfter / moneyBefore - 1;
|
||||
workerScript.log(
|
||||
@ -910,14 +908,14 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return netscriptDelay(weakenTime * 1000, workerScript).then(function () {
|
||||
if (workerScript.env.stopFlag) return Promise.reject(workerScript);
|
||||
const host = GetServer(workerScript.serverIp);
|
||||
const host = GetServer(workerScript.hostname);
|
||||
if (host === null) {
|
||||
workerScript.log("weaken", "Server is null, did it die?");
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
const coreBonus = 1 + (host.cpuCores - 1) / 16;
|
||||
server.weaken(CONSTANTS.ServerWeakenAmount * threads * coreBonus);
|
||||
workerScript.scriptRef.recordWeaken(server.ip, threads);
|
||||
workerScript.scriptRef.recordWeaken(server.hostname, threads);
|
||||
const expGain = calculateHackingExpGain(server, Player) * threads;
|
||||
workerScript.log(
|
||||
"weaken",
|
||||
@ -983,7 +981,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
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;
|
||||
if (arguments.length === 0) {
|
||||
runningScriptObj = workerScript.scriptRef;
|
||||
@ -1159,7 +1157,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
if (isNaN(threads) || threads <= 0) {
|
||||
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) {
|
||||
throw makeRuntimeErrorMsg("run", "Could not find server. This is a bug. Report to dev.");
|
||||
}
|
||||
@ -1191,7 +1189,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
if (isNaN(threads) || threads <= 0) {
|
||||
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) {
|
||||
throw makeRuntimeErrorMsg("spawn", "Could not find server. This is a bug. Report to dev");
|
||||
}
|
||||
@ -1227,7 +1225,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
return false;
|
||||
}
|
||||
|
||||
res = killWorkerScript(runningScriptObj, server.ip);
|
||||
res = killWorkerScript(runningScriptObj, server.hostname);
|
||||
}
|
||||
|
||||
if (res) {
|
||||
@ -1246,7 +1244,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
killall: function (ip: any = workerScript.serverIp): any {
|
||||
killall: function (ip: any = workerScript.hostname): any {
|
||||
updateDynamicRam("killall", getRamCost("killall"));
|
||||
if (ip === undefined) {
|
||||
throw makeRuntimeErrorMsg("killall", "Takes 1 argument");
|
||||
@ -1257,7 +1255,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
const scriptsRunning = server.runningScripts.length > 0;
|
||||
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();
|
||||
workerScript.log(
|
||||
@ -1327,7 +1325,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
throw makeRuntimeErrorMsg("scp", `Invalid IP/hostname: ${ip1}`);
|
||||
}
|
||||
|
||||
currServ = GetServer(workerScript.serverIp);
|
||||
currServ = GetServer(workerScript.hostname);
|
||||
if (currServ == null) {
|
||||
throw makeRuntimeErrorMsg("scp", "Could not find server ip for this script. This is a bug. Report to dev.");
|
||||
}
|
||||
@ -1422,7 +1420,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
const newScript = new Script(scriptname);
|
||||
newScript.code = sourceScript.code;
|
||||
newScript.ramUsage = sourceScript.ramUsage;
|
||||
newScript.server = destServer.ip;
|
||||
newScript.server = destServer.hostname;
|
||||
destServer.scripts.push(newScript);
|
||||
workerScript.log("scp", `File '${scriptname}' copied over to '${destServer.hostname}'.`);
|
||||
return true;
|
||||
@ -1506,7 +1504,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
allFiles.sort();
|
||||
return allFiles;
|
||||
},
|
||||
ps: function (ip: any = workerScript.serverIp): any {
|
||||
ps: function (ip: any = workerScript.hostname): any {
|
||||
updateDynamicRam("ps", getRamCost("ps"));
|
||||
const server = GetServer(ip);
|
||||
if (server == null) {
|
||||
@ -1537,15 +1535,15 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
},
|
||||
getIp: function (): any {
|
||||
updateDynamicRam("getIp", getRamCost("getIp"));
|
||||
const scriptServer = GetServer(workerScript.serverIp);
|
||||
const scriptServer = GetServer(workerScript.hostname);
|
||||
if (scriptServer == null) {
|
||||
throw makeRuntimeErrorMsg("getIp", "Could not find server. This is a bug. Report to dev.");
|
||||
}
|
||||
return scriptServer.ip;
|
||||
return scriptServer.hostname;
|
||||
},
|
||||
getHostname: function (): any {
|
||||
updateDynamicRam("getHostname", getRamCost("getHostname"));
|
||||
const scriptServer = GetServer(workerScript.serverIp);
|
||||
const scriptServer = GetServer(workerScript.hostname);
|
||||
if (scriptServer == null) {
|
||||
throw makeRuntimeErrorMsg("getHostname", "Could not find server. This is a bug. Report to dev.");
|
||||
}
|
||||
@ -1756,7 +1754,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
updateDynamicRam("serverExists", getRamCost("serverExists"));
|
||||
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"));
|
||||
if (filename === undefined) {
|
||||
throw makeRuntimeErrorMsg("fileExists", "Usage: fileExists(scriptname, [server])");
|
||||
@ -1786,7 +1784,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
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"));
|
||||
if (fn === undefined || ip === undefined) {
|
||||
throw makeRuntimeErrorMsg("isRunning", "Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
|
||||
@ -2170,10 +2168,10 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
});
|
||||
AddToAllServers(newServ);
|
||||
|
||||
Player.purchasedServers.push(newServ.ip);
|
||||
Player.purchasedServers.push(newServ.hostname);
|
||||
const homeComputer = Player.getHomeComputer();
|
||||
homeComputer.serversOnNetwork.push(newServ.ip);
|
||||
newServ.serversOnNetwork.push(homeComputer.ip);
|
||||
homeComputer.serversOnNetwork.push(newServ.hostname);
|
||||
newServ.serversOnNetwork.push(homeComputer.hostname);
|
||||
Player.loseMoney(cost);
|
||||
workerScript.log(
|
||||
"purchaseServer",
|
||||
@ -2200,7 +2198,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
return false;
|
||||
}
|
||||
|
||||
const ip = server.ip;
|
||||
const ip = server.hostname;
|
||||
|
||||
// Can't delete server you're currently connected to
|
||||
if (server.isConnectedTo) {
|
||||
@ -2209,7 +2207,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
|
||||
// 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.");
|
||||
return false;
|
||||
}
|
||||
@ -2321,7 +2319,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
let script = workerScript.getScriptOnServer(fn, server);
|
||||
if (script == null) {
|
||||
// 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);
|
||||
return true;
|
||||
}
|
||||
@ -2387,7 +2385,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
} else if (isString(port)) {
|
||||
// Read from script or text file
|
||||
const fn = port;
|
||||
const server = GetServer(workerScript.serverIp);
|
||||
const server = GetServer(workerScript.hostname);
|
||||
if (server == null) {
|
||||
throw makeRuntimeErrorMsg("read", "Error getting Server. This is a bug. Report to dev.");
|
||||
}
|
||||
@ -2453,7 +2451,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
} else if (isString(port)) {
|
||||
// Clear text file
|
||||
const fn = port;
|
||||
const server = GetServer(workerScript.serverIp);
|
||||
const server = GetServer(workerScript.hostname);
|
||||
if (server == null) {
|
||||
throw makeRuntimeErrorMsg("clear", "Error getting Server. This is a bug. Report to dev.");
|
||||
}
|
||||
@ -2491,7 +2489,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
updateDynamicRam("rm", getRamCost("rm"));
|
||||
|
||||
if (ip == null || ip === "") {
|
||||
ip = workerScript.serverIp;
|
||||
ip = workerScript.hostname;
|
||||
}
|
||||
const s = safeGetServer(ip, "rm");
|
||||
|
||||
@ -2524,7 +2522,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
let suc = false;
|
||||
for (let i = 0; i < server.runningScripts.length; ++i) {
|
||||
if (server.runningScripts[i].filename == scriptname) {
|
||||
killWorkerScript(server.runningScripts[i], server.ip);
|
||||
killWorkerScript(server.runningScripts[i], server.hostname);
|
||||
suc = true;
|
||||
}
|
||||
}
|
||||
@ -2533,7 +2531,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
getScriptName: function (): any {
|
||||
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"));
|
||||
const server = GetServer(ip);
|
||||
if (server == null) {
|
||||
@ -2700,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")) {
|
||||
workerScript.log("wget", `Invalid target file: '${target}'. Must be a script or text file.`);
|
||||
return Promise.resolve(false);
|
||||
@ -2938,7 +2936,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
updateDynamicRam("purchaseTor", getRamCost("purchaseTor"));
|
||||
checkSingularityAccess("purchaseTor", 1);
|
||||
|
||||
if (SpecialServerIps["Darkweb Server"] != null) {
|
||||
if (Player.hasTorRouter()) {
|
||||
workerScript.log("purchaseTor", "You already have a TOR router!");
|
||||
return false;
|
||||
}
|
||||
@ -2959,10 +2957,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
maxRam: 1,
|
||||
});
|
||||
AddToAllServers(darkweb);
|
||||
SpecialServerIps.addIp("Darkweb Server", darkweb.ip);
|
||||
|
||||
Player.getHomeComputer().serversOnNetwork.push(darkweb.ip);
|
||||
darkweb.serversOnNetwork.push(Player.getHomeComputer().ip);
|
||||
Player.getHomeComputer().serversOnNetwork.push(darkweb.hostname);
|
||||
darkweb.serversOnNetwork.push(Player.getHomeComputer().hostname);
|
||||
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.log("purchaseTor", "You have purchased a Tor router!");
|
||||
return true;
|
||||
@ -2971,7 +2968,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
updateDynamicRam("purchaseProgram", getRamCost("purchaseProgram"));
|
||||
checkSingularityAccess("purchaseProgram", 1);
|
||||
|
||||
if (SpecialServerIps["Darkweb Server"] == null) {
|
||||
if (!Player.hasTorRouter()) {
|
||||
workerScript.log("purchaseProgram", "You do not have the TOR router.");
|
||||
return false;
|
||||
}
|
||||
@ -3032,7 +3029,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
if (hostname === "home") {
|
||||
Player.getCurrentServer().isConnectedTo = false;
|
||||
Player.currentServer = Player.getHomeComputer().ip;
|
||||
Player.currentServer = Player.getHomeComputer().hostname;
|
||||
Player.getCurrentServer().isConnectedTo = true;
|
||||
Terminal.setcwd("/");
|
||||
return true;
|
||||
@ -3042,9 +3039,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
for (let i = 0; i < server.serversOnNetwork.length; i++) {
|
||||
const other = getServerOnNetwork(server, i);
|
||||
if (other === null) continue;
|
||||
if (other.ip == hostname || other.hostname == hostname) {
|
||||
if (other.hostname == hostname) {
|
||||
Player.getCurrentServer().isConnectedTo = false;
|
||||
Player.currentServer = target.ip;
|
||||
Player.currentServer = target.hostname;
|
||||
Player.getCurrentServer().isConnectedTo = true;
|
||||
Terminal.setcwd("/");
|
||||
return true;
|
||||
@ -3137,7 +3134,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
workMoney: Player.work_money_mult,
|
||||
},
|
||||
timeWorked: Player.timeWorked,
|
||||
tor: SpecialServerIps.hasOwnProperty("Darkweb Server"),
|
||||
tor: Player.hasTorRouter(),
|
||||
workHackExpGain: Player.workHackExpGained,
|
||||
workStrExpGain: Player.workStrExpGained,
|
||||
workDefExpGain: Player.workDefExpGained,
|
||||
@ -3243,7 +3240,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
playtimeSinceLastBitnode: Player.playtimeSinceLastBitnode,
|
||||
jobs: {},
|
||||
factions: Player.factions.slice(),
|
||||
tor: SpecialServerIps.hasOwnProperty("Darkweb Server"),
|
||||
tor: Player.hasTorRouter(),
|
||||
};
|
||||
Object.assign(data.jobs, Player.jobs);
|
||||
return data;
|
||||
@ -4398,7 +4395,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
// Coding Contract API
|
||||
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"));
|
||||
const contract = getCodingContract("attempt", ip, fn);
|
||||
|
||||
@ -4441,12 +4438,12 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
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"));
|
||||
const contract = getCodingContract("getContractType", ip, fn);
|
||||
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"));
|
||||
const contract = getCodingContract("getData", ip, fn);
|
||||
const data = contract.getData();
|
||||
@ -4466,12 +4463,12 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
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"));
|
||||
const contract = getCodingContract("getDescription", ip, fn);
|
||||
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"));
|
||||
const contract = getCodingContract("getNumTriesRemaining", ip, fn);
|
||||
return contract.getMaxNumTries() - contract.tries;
|
||||
|
@ -4,7 +4,6 @@ import { getRamCost } from "../Netscript/RamCostGenerator";
|
||||
import { FactionWorkType } from "../Faction/FactionWorkTypeEnum";
|
||||
import { SourceFileFlags } from "../SourceFile/SourceFileFlags";
|
||||
import { SleeveTaskType } from "../PersonObjects/Sleeve/SleeveTaskTypesEnum";
|
||||
import { SpecialServerIps } from "../Server/SpecialServerIps";
|
||||
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||
import { findSleevePurchasableAugs } from "../PersonObjects/Sleeve/SleeveHelpers";
|
||||
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.
|
||||
jobTitle: Object.values(player.jobs),
|
||||
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: {
|
||||
agility: sl.agility_mult,
|
||||
|
@ -544,11 +544,11 @@ export function createAndAddWorkerScript(
|
||||
console.error("Error text: " + w.errorMessage);
|
||||
return;
|
||||
}
|
||||
const serverIp = errorTextArray[1];
|
||||
const hostname = errorTextArray[1];
|
||||
const scriptName = errorTextArray[2];
|
||||
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) {
|
||||
msg += `Args: ${arrayToString(w.args)}<br>`;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/A
|
||||
import { Server } from "../../Server/Server";
|
||||
import { safetlyCreateUniqueServer } from "../../Server/ServerHelpers";
|
||||
import { Settings } from "../../Settings/Settings";
|
||||
import { SpecialServerIps, SpecialServerNames } from "../../Server/SpecialServerIps";
|
||||
import { SpecialServers } from "../../Server/data/SpecialServers";
|
||||
import { applySourceFile } from "../../SourceFile/applySourceFile";
|
||||
import { applyExploit } from "../../Exploits/applyExploits";
|
||||
import { SourceFiles } from "../../SourceFile/SourceFiles";
|
||||
@ -70,7 +70,7 @@ export function init(this: IPlayer): void {
|
||||
organizationName: "Home PC",
|
||||
purchasedByPlayer: true,
|
||||
});
|
||||
this.currentServer = t_homeComp.ip;
|
||||
this.currentServer = SpecialServers.Home;
|
||||
AddToAllServers(t_homeComp);
|
||||
|
||||
this.getHomeComputer().programs.push(Programs.NukeProgram.name);
|
||||
@ -78,7 +78,7 @@ export function init(this: IPlayer): void {
|
||||
|
||||
export function prestigeAugmentation(this: IPlayer): void {
|
||||
const homeComp = this.getHomeComputer();
|
||||
this.currentServer = homeComp.ip;
|
||||
this.currentServer = SpecialServers.Home;
|
||||
|
||||
this.numPeopleKilled = 0;
|
||||
this.karma = 0;
|
||||
@ -575,13 +575,11 @@ export function startWork(this: IPlayer, router: IRouter, companyName: string):
|
||||
}
|
||||
|
||||
export function cancelationPenalty(this: IPlayer): number {
|
||||
const specialIp = SpecialServerIps[this.companyName];
|
||||
if (typeof specialIp === "string" && specialIp !== "") {
|
||||
const server = GetServer(specialIp);
|
||||
if (server instanceof Server) {
|
||||
if (server && server.backdoorInstalled) return 0.75;
|
||||
}
|
||||
const server = GetServer(this.companyName);
|
||||
if (server instanceof Server) {
|
||||
if (server && server.backdoorInstalled) return 0.75;
|
||||
}
|
||||
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@ -2190,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
|
||||
const fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"];
|
||||
const fulcrumIP = SpecialServerIps[SpecialServerNames.BitRunnersServer];
|
||||
if (typeof fulcrumIP !== "string") throw new Error("Fulcrum Secret Technologies should be string");
|
||||
const fulcrumSecretServer = GetServer(fulcrumIP);
|
||||
const fulcrumSecretServer = GetServer(SpecialServers.FulcrumSecretTechnologies);
|
||||
if (!(fulcrumSecretServer instanceof Server)) throw new Error("Fulcrum Secret Technologies should be normal server");
|
||||
if (fulcrumSecretServer == null) {
|
||||
console.error("Could not find Fulcrum Secret Technologies Server");
|
||||
@ -2210,9 +2206,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
||||
|
||||
//BitRunners
|
||||
const bitrunnersFac = Factions["BitRunners"];
|
||||
const bitrunnerIP = SpecialServerIps[SpecialServerNames.BitRunnersServer];
|
||||
if (typeof bitrunnerIP !== "string") throw new Error("BitRunners should be string");
|
||||
const bitrunnersServer = GetServer(bitrunnerIP);
|
||||
const bitrunnersServer = GetServer(SpecialServers.BitRunnersServer);
|
||||
if (!(bitrunnersServer instanceof Server)) throw new Error("BitRunners should be normal server");
|
||||
if (bitrunnersServer == null) {
|
||||
console.error("Could not find BitRunners Server");
|
||||
@ -2228,9 +2222,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
||||
//The Black Hand
|
||||
|
||||
const theblackhandFac = Factions["The Black Hand"];
|
||||
const tbhIP = SpecialServerIps[SpecialServerNames.TheBlackHandServer];
|
||||
if (typeof tbhIP !== "string") throw new Error("TheBlackHand should be string");
|
||||
const blackhandServer = GetServer(tbhIP);
|
||||
const blackhandServer = GetServer(SpecialServers.TheBlackHandServer);
|
||||
if (!(blackhandServer instanceof Server)) throw new Error("TheBlackHand should be normal server");
|
||||
if (blackhandServer == null) {
|
||||
console.error("Could not find The Black Hand Server");
|
||||
@ -2245,9 +2237,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
||||
|
||||
//NiteSec
|
||||
const nitesecFac = Factions["NiteSec"];
|
||||
const nitesecIP = SpecialServerIps[SpecialServerNames.NiteSecServer];
|
||||
if (typeof nitesecIP !== "string") throw new Error("NiteSec should be string");
|
||||
const nitesecServer = GetServer(nitesecIP);
|
||||
const nitesecServer = GetServer(SpecialServers.NiteSecServer);
|
||||
if (!(nitesecServer instanceof Server)) throw new Error("NiteSec should be normal server");
|
||||
if (nitesecServer == null) {
|
||||
console.error("Could not find NiteSec Server");
|
||||
@ -2485,9 +2475,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
||||
|
||||
//CyberSec
|
||||
const cybersecFac = Factions["CyberSec"];
|
||||
const cyberSecIP = SpecialServerIps[SpecialServerNames.CyberSecServer];
|
||||
if (typeof cyberSecIP !== "string") throw new Error("cybersec should be string");
|
||||
const cybersecServer = GetServer(cyberSecIP);
|
||||
const cybersecServer = GetServer(SpecialServers.CyberSecServer);
|
||||
if (!(cybersecServer instanceof Server)) throw new Error("cybersec should be normal server");
|
||||
if (cybersecServer == null) {
|
||||
console.error("Could not find CyberSec Server");
|
||||
|
@ -10,10 +10,10 @@ import { Server } from "../../Server/Server";
|
||||
import { BaseServer } from "../../Server/BaseServer";
|
||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
||||
import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers";
|
||||
import { SpecialServerIps } from "../../Server/SpecialServerIps";
|
||||
import { SpecialServers } from "../../Server/data/SpecialServers";
|
||||
|
||||
export function hasTorRouter(this: IPlayer): boolean {
|
||||
return SpecialServerIps.hasOwnProperty("Darkweb Server");
|
||||
return !!GetServer(SpecialServers.DarkWeb);
|
||||
}
|
||||
|
||||
export function getCurrentServer(this: IPlayer): BaseServer {
|
||||
@ -49,13 +49,13 @@ export function createHacknetServer(this: IPlayer): HacknetServer {
|
||||
ip: createUniqueRandomIp(),
|
||||
// player: this,
|
||||
});
|
||||
this.hacknetNodes.push(server.ip);
|
||||
this.hacknetNodes.push(server.hostname);
|
||||
|
||||
// Configure the HacknetServer to actually act as a Server
|
||||
AddToAllServers(server);
|
||||
const homeComputer = this.getHomeComputer();
|
||||
homeComputer.serversOnNetwork.push(server.ip);
|
||||
server.serversOnNetwork.push(homeComputer.ip);
|
||||
homeComputer.serversOnNetwork.push(server.hostname);
|
||||
server.serversOnNetwork.push(SpecialServers.Home);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import { LiteratureNames } from "./Literature/data/LiteratureNames";
|
||||
import { GetServer, AddToAllServers, initForeignServers, prestigeAllServers } from "./Server/AllServers";
|
||||
import { prestigeHomeComputer } from "./Server/ServerHelpers";
|
||||
import { SourceFileFlags, updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||
import { prestigeSpecialServerIps, SpecialServerNames } from "./Server/SpecialServerIps";
|
||||
import { SpecialServers } from "./Server/data/SpecialServers";
|
||||
import { deleteStockMarket, initStockMarket, initSymbolToStockMap } from "./StockMarket/StockMarket";
|
||||
import { Terminal } from "./Terminal";
|
||||
|
||||
@ -46,9 +46,6 @@ function prestigeAugmentation(): void {
|
||||
// Delete all servers except home computer
|
||||
prestigeAllServers();
|
||||
|
||||
// Delete Special Server IPs
|
||||
prestigeSpecialServerIps(); // Must be done before initForeignServers()
|
||||
|
||||
// Reset home computer (only the programs) and add to AllServers
|
||||
AddToAllServers(homeComp);
|
||||
prestigeHomeComputer(homeComp);
|
||||
@ -132,11 +129,11 @@ function prestigeAugmentation(): void {
|
||||
|
||||
// Red Pill
|
||||
if (augmentationExists(AugmentationNames.TheRedPill) && Augmentations[AugmentationNames.TheRedPill].owned) {
|
||||
const WorldDaemon = GetServer(SpecialServerNames.WorldDaemon);
|
||||
const DaedalusServer = GetServer(SpecialServerNames.DaedalusServer);
|
||||
const WorldDaemon = GetServer(SpecialServers.WorldDaemon);
|
||||
const DaedalusServer = GetServer(SpecialServers.DaedalusServer);
|
||||
if (WorldDaemon && DaedalusServer) {
|
||||
WorldDaemon.serversOnNetwork.push(DaedalusServer.ip);
|
||||
DaedalusServer.serversOnNetwork.push(WorldDaemon.ip);
|
||||
WorldDaemon.serversOnNetwork.push(DaedalusServer.hostname);
|
||||
DaedalusServer.serversOnNetwork.push(WorldDaemon.hostname);
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,9 +153,6 @@ function prestigeSourceFile(flume: boolean): void {
|
||||
// Delete all servers except home computer
|
||||
prestigeAllServers(); // Must be done before initForeignServers()
|
||||
|
||||
// Delete Special Server IPs
|
||||
prestigeSpecialServerIps();
|
||||
|
||||
// Reset home computer (only the programs) and add to AllServers
|
||||
AddToAllServers(homeComp);
|
||||
prestigeHomeComputer(homeComp);
|
||||
|
@ -7,7 +7,6 @@ import { loadMessages, initMessages, Messages } from "./Message/MessageHelpers";
|
||||
import { Player, loadPlayer } from "./Player";
|
||||
import { saveAllServers, loadAllServers } from "./Server/AllServers";
|
||||
import { Settings } from "./Settings/Settings";
|
||||
import { loadSpecialServerIps, SpecialServerIps } from "./Server/SpecialServerIps";
|
||||
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||
import { loadStockMarket, StockMarket } from "./StockMarket/StockMarket";
|
||||
|
||||
@ -28,7 +27,6 @@ class BitburnerSaveObject {
|
||||
AllServersSave = "";
|
||||
CompaniesSave = "";
|
||||
FactionsSave = "";
|
||||
SpecialServerIpsSave = "";
|
||||
AliasesSave = "";
|
||||
GlobalAliasesSave = "";
|
||||
MessagesSave = "";
|
||||
@ -44,7 +42,6 @@ class BitburnerSaveObject {
|
||||
this.AllServersSave = saveAllServers();
|
||||
this.CompaniesSave = JSON.stringify(Companies);
|
||||
this.FactionsSave = JSON.stringify(Factions);
|
||||
this.SpecialServerIpsSave = JSON.stringify(SpecialServerIps);
|
||||
this.AliasesSave = JSON.stringify(Aliases);
|
||||
this.GlobalAliasesSave = JSON.stringify(GlobalAliases);
|
||||
this.MessagesSave = JSON.stringify(Messages);
|
||||
@ -156,7 +153,6 @@ function loadGame(saveString: string): boolean {
|
||||
loadAllServers(saveObj.AllServersSave);
|
||||
loadCompanies(saveObj.CompaniesSave);
|
||||
loadFactions(saveObj.FactionsSave);
|
||||
loadSpecialServerIps(saveObj.SpecialServerIpsSave);
|
||||
|
||||
if (saveObj.hasOwnProperty("AliasesSave")) {
|
||||
try {
|
||||
|
@ -14,7 +14,7 @@ export class RunningScript {
|
||||
// Script arguments
|
||||
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]
|
||||
dataMap: IMap<number[]> = {};
|
||||
|
||||
@ -52,7 +52,7 @@ export class RunningScript {
|
||||
// How much RAM this script uses for ONE thread
|
||||
ramUsage = 0;
|
||||
|
||||
// IP of the server on which this script is running
|
||||
// hostname of the server on which this script is running
|
||||
server = "";
|
||||
|
||||
// Number of threads that this script is running with
|
||||
@ -93,28 +93,28 @@ export class RunningScript {
|
||||
}
|
||||
|
||||
// Update the moneyStolen and numTimesHack maps when hacking
|
||||
recordHack(serverIp: string, moneyGained: number, n = 1): void {
|
||||
if (this.dataMap[serverIp] == null || this.dataMap[serverIp].constructor !== Array) {
|
||||
this.dataMap[serverIp] = [0, 0, 0, 0];
|
||||
recordHack(hostname: string, moneyGained: number, n = 1): void {
|
||||
if (this.dataMap[hostname] == null || this.dataMap[hostname].constructor !== Array) {
|
||||
this.dataMap[hostname] = [0, 0, 0, 0];
|
||||
}
|
||||
this.dataMap[serverIp][0] += moneyGained;
|
||||
this.dataMap[serverIp][1] += n;
|
||||
this.dataMap[hostname][0] += moneyGained;
|
||||
this.dataMap[hostname][1] += n;
|
||||
}
|
||||
|
||||
// Update the grow map when calling grow()
|
||||
recordGrow(serverIp: string, n = 1): void {
|
||||
if (this.dataMap[serverIp] == null || this.dataMap[serverIp].constructor !== Array) {
|
||||
this.dataMap[serverIp] = [0, 0, 0, 0];
|
||||
recordGrow(hostname: string, n = 1): void {
|
||||
if (this.dataMap[hostname] == null || this.dataMap[hostname].constructor !== Array) {
|
||||
this.dataMap[hostname] = [0, 0, 0, 0];
|
||||
}
|
||||
this.dataMap[serverIp][2] += n;
|
||||
this.dataMap[hostname][2] += n;
|
||||
}
|
||||
|
||||
// Update the weaken map when calling weaken() {
|
||||
recordWeaken(serverIp: string, n = 1): void {
|
||||
if (this.dataMap[serverIp] == null || this.dataMap[serverIp].constructor !== Array) {
|
||||
this.dataMap[serverIp] = [0, 0, 0, 0];
|
||||
recordWeaken(hostname: string, n = 1): void {
|
||||
if (this.dataMap[hostname] == null || this.dataMap[hostname].constructor !== Array) {
|
||||
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
|
||||
|
@ -37,14 +37,14 @@ export class Script {
|
||||
// Amount of RAM this Script requres to run
|
||||
ramUsage = 0;
|
||||
|
||||
// IP of server that this script is on.
|
||||
// hostname of server that this script is on.
|
||||
server = "";
|
||||
|
||||
constructor(fn = "", code = "", server = "", otherScripts: Script[] = []) {
|
||||
this.filename = fn;
|
||||
this.code = code;
|
||||
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.moduleSequenceNumber = ++globalModuleSequenceNumber;
|
||||
if (this.code !== "") {
|
||||
@ -90,12 +90,12 @@ export class Script {
|
||||
* @param {string} code - The new contents of the script
|
||||
* @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
|
||||
this.code = code.replace(/^\s+|\s+$/g, "");
|
||||
|
||||
this.filename = filename;
|
||||
this.server = serverIp;
|
||||
this.server = hostname;
|
||||
this.updateRamUsage(otherScripts);
|
||||
this.markUpdated();
|
||||
}
|
||||
|
@ -27,17 +27,17 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
||||
//Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
|
||||
|
||||
// Grow
|
||||
for (const ip in runningScript.dataMap) {
|
||||
if (runningScript.dataMap.hasOwnProperty(ip)) {
|
||||
if (runningScript.dataMap[ip][2] == 0 || runningScript.dataMap[ip][2] == null) {
|
||||
for (const hostname in runningScript.dataMap) {
|
||||
if (runningScript.dataMap.hasOwnProperty(hostname)) {
|
||||
if (runningScript.dataMap[hostname][2] == 0 || runningScript.dataMap[hostname][2] == null) {
|
||||
continue;
|
||||
}
|
||||
const serv = GetServer(ip);
|
||||
const serv = GetServer(hostname);
|
||||
if (serv == null) {
|
||||
continue;
|
||||
}
|
||||
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`);
|
||||
const host = GetServer(runningScript.server);
|
||||
@ -60,12 +60,12 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
||||
runningScript.offlineExpGained += expGain;
|
||||
|
||||
// Weaken
|
||||
for (const ip in runningScript.dataMap) {
|
||||
if (runningScript.dataMap.hasOwnProperty(ip)) {
|
||||
if (runningScript.dataMap[ip][3] == 0 || runningScript.dataMap[ip][3] == null) {
|
||||
for (const hostname in runningScript.dataMap) {
|
||||
if (runningScript.dataMap.hasOwnProperty(hostname)) {
|
||||
if (runningScript.dataMap[hostname][3] == 0 || runningScript.dataMap[hostname][3] == null) {
|
||||
continue;
|
||||
}
|
||||
const serv = GetServer(ip);
|
||||
const serv = GetServer(hostname);
|
||||
if (serv == null) {
|
||||
continue;
|
||||
}
|
||||
@ -74,7 +74,7 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
||||
const host = GetServer(runningScript.server);
|
||||
if (host === null) throw new Error("getServer of null key?");
|
||||
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`);
|
||||
const coreBonus = 1 + (host.cpuCores - 1) / 16;
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Server } from "./Server";
|
||||
import { BaseServer } from "./BaseServer";
|
||||
import { SpecialServerIps } from "./SpecialServerIps";
|
||||
import { serverMetadata } from "./data/servers";
|
||||
|
||||
import { HacknetServer } from "../Hacknet/HacknetServer";
|
||||
@ -90,13 +89,11 @@ export function createUniqueRandomIp(): string {
|
||||
// Saftely add a Server to the AllServers map
|
||||
export function AddToAllServers(server: Server | HacknetServer): void {
|
||||
if (GetServer(server.hostname)) {
|
||||
console.warn(`IP of server that's being added: ${server.ip}`);
|
||||
console.warn(`Hostname of the server thats being added: ${server.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");
|
||||
}
|
||||
|
||||
console.log(`adding ${server.hostname}`);
|
||||
AllServers[server.hostname] = server;
|
||||
}
|
||||
|
||||
@ -164,10 +161,6 @@ export function initForeignServers(homeComputer: Server): void {
|
||||
server.messages.push(filename);
|
||||
}
|
||||
|
||||
if (metadata.specialName !== undefined) {
|
||||
SpecialServerIps.addIp(metadata.specialName, server.ip);
|
||||
}
|
||||
|
||||
AddToAllServers(server);
|
||||
if (metadata.networkLayer !== undefined) {
|
||||
networkLayers[toNumber(metadata.networkLayer) - 1].push(server);
|
||||
@ -176,8 +169,8 @@ export function initForeignServers(homeComputer: Server): void {
|
||||
|
||||
/* Create a randomized network for all the foreign servers */
|
||||
const linkComputers = (server1: Server, server2: Server): void => {
|
||||
server1.serversOnNetwork.push(server2.ip);
|
||||
server2.serversOnNetwork.push(server1.ip);
|
||||
server1.serversOnNetwork.push(server2.hostname);
|
||||
server2.serversOnNetwork.push(server1.hostname);
|
||||
};
|
||||
|
||||
const getRandomArrayItem = (arr: any[]): any => arr[Math.floor(Math.random() * arr.length)];
|
||||
|
@ -267,7 +267,7 @@ export class BaseServer {
|
||||
}
|
||||
|
||||
// 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);
|
||||
ret.success = true;
|
||||
return ret;
|
||||
|
@ -80,12 +80,12 @@ export function purchaseServer(hostname: string, ram: number, cost: number, p: I
|
||||
AddToAllServers(newServ);
|
||||
|
||||
// Add to Player's purchasedServers array
|
||||
p.purchasedServers.push(newServ.ip);
|
||||
p.purchasedServers.push(newServ.hostname);
|
||||
|
||||
// Connect new server to home computer
|
||||
const homeComputer = p.getHomeComputer();
|
||||
homeComputer.serversOnNetwork.push(newServ.ip);
|
||||
newServ.serversOnNetwork.push(homeComputer.ip);
|
||||
homeComputer.serversOnNetwork.push(newServ.hostname);
|
||||
newServ.serversOnNetwork.push(homeComputer.hostname);
|
||||
|
||||
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 { LocationName } from "../../Locations/data/LocationNames";
|
||||
import { LiteratureNames } from "../../Literature/data/LiteratureNames";
|
||||
import { SpecialServers } from "./SpecialServers";
|
||||
|
||||
/**
|
||||
* The metadata describing the base state of servers on the network.
|
||||
@ -319,7 +320,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 1100,
|
||||
},
|
||||
serverGrowth: 1,
|
||||
specialName: "Fulcrum Secret Technologies Server",
|
||||
specialName: SpecialServers.FulcrumSecretTechnologies,
|
||||
},
|
||||
{
|
||||
hackDifficulty: {
|
||||
@ -1470,7 +1471,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 505,
|
||||
},
|
||||
serverGrowth: 0,
|
||||
specialName: "BitRunners Server",
|
||||
specialName: SpecialServers.BitRunnersServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@ -1489,7 +1490,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 340,
|
||||
},
|
||||
serverGrowth: 0,
|
||||
specialName: "The Black Hand Server",
|
||||
specialName: SpecialServers.TheBlackHandServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@ -1508,7 +1509,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 202,
|
||||
},
|
||||
serverGrowth: 0,
|
||||
specialName: "NiteSec Server",
|
||||
specialName: SpecialServers.NiteSecServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@ -1523,7 +1524,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 505,
|
||||
},
|
||||
serverGrowth: 0,
|
||||
specialName: "The Dark Army Server",
|
||||
specialName: SpecialServers.TheDarkArmyServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@ -1539,7 +1540,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
min: 51,
|
||||
},
|
||||
serverGrowth: 0,
|
||||
specialName: "CyberSec Server",
|
||||
specialName: SpecialServers.CyberSecServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@ -1551,7 +1552,7 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
organizationName: "Helios",
|
||||
requiredHackingSkill: 925,
|
||||
serverGrowth: 0,
|
||||
specialName: "Daedalus Server",
|
||||
specialName: SpecialServers.DaedalusServer,
|
||||
},
|
||||
{
|
||||
hackDifficulty: 0,
|
||||
@ -1561,6 +1562,6 @@ export const serverMetadata: IServerMetadata[] = [
|
||||
organizationName: "w0r1d_d43m0n",
|
||||
requiredHackingSkill: 3000,
|
||||
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",
|
||||
"home Connect to home computer",
|
||||
"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 ",
|
||||
"killall Stops all running scripts on the current 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.",
|
||||
],
|
||||
hostname: ["hostname", " ", "Prints the hostname of the current server"],
|
||||
ifconfig: ["ipconfig", " ", "Prints the IP address of the current server"],
|
||||
kill: [
|
||||
"kill [script name] [args...]",
|
||||
" ",
|
||||
|
@ -19,7 +19,7 @@ import { checkIfConnectedToDarkweb } from "../DarkWeb/DarkWeb";
|
||||
import { iTutorialNextStep, iTutorialSteps, ITutorial } from "../InteractiveTutorial";
|
||||
import { getServerOnNetwork, processSingleServerGrowth } from "../Server/ServerHelpers";
|
||||
import { ParseCommand, ParseCommands } from "./Parser";
|
||||
import { SpecialServerIps, SpecialServerNames } from "../Server/SpecialServerIps";
|
||||
import { SpecialServers } from "../Server/data/SpecialServers";
|
||||
import { Settings } from "../Settings/Settings";
|
||||
import { createProgressBarText } from "../utils/helpers/createProgressBarText";
|
||||
import {
|
||||
@ -49,7 +49,6 @@ import { hack } from "./commands/hack";
|
||||
import { help } from "./commands/help";
|
||||
import { home } from "./commands/home";
|
||||
import { hostname } from "./commands/hostname";
|
||||
import { ifconfig } from "./commands/ifconfig";
|
||||
import { kill } from "./commands/kill";
|
||||
import { killall } from "./commands/killall";
|
||||
import { ls } from "./commands/ls";
|
||||
@ -176,10 +175,7 @@ export class Terminal implements ITerminal {
|
||||
const expGainedOnFailure = expGainedOnSuccess / 4;
|
||||
if (rand < hackChance) {
|
||||
// Success!
|
||||
if (
|
||||
SpecialServerIps[SpecialServerNames.WorldDaemon] &&
|
||||
SpecialServerIps[SpecialServerNames.WorldDaemon] == server.ip
|
||||
) {
|
||||
if (SpecialServers.WorldDaemon === server.hostname) {
|
||||
if (player.bitNodeN == null) {
|
||||
player.bitNodeN = 1;
|
||||
}
|
||||
@ -259,10 +255,7 @@ export class Terminal implements ITerminal {
|
||||
return;
|
||||
}
|
||||
if (!(server instanceof Server)) throw new Error("server should be normal server");
|
||||
if (
|
||||
SpecialServerIps[SpecialServerNames.WorldDaemon] &&
|
||||
SpecialServerIps[SpecialServerNames.WorldDaemon] == server.ip
|
||||
) {
|
||||
if (SpecialServers.WorldDaemon === server.hostname) {
|
||||
if (player.bitNodeN == null) {
|
||||
player.bitNodeN = 1;
|
||||
}
|
||||
@ -519,7 +512,7 @@ export class Terminal implements ITerminal {
|
||||
return;
|
||||
}
|
||||
player.getCurrentServer().isConnectedTo = false;
|
||||
player.currentServer = serv.ip;
|
||||
player.currentServer = serv.hostname;
|
||||
player.getCurrentServer().isConnectedTo = true;
|
||||
this.print("Connected to " + serv.hostname);
|
||||
this.setcwd("/");
|
||||
@ -625,7 +618,10 @@ export class Terminal implements ITerminal {
|
||||
break;
|
||||
case iTutorialSteps.TerminalConnect:
|
||||
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();
|
||||
} else {
|
||||
this.print("Wrong command! Try again!");
|
||||
@ -741,7 +737,6 @@ export class Terminal implements ITerminal {
|
||||
help: help,
|
||||
home: home,
|
||||
hostname: hostname,
|
||||
ifconfig: ifconfig,
|
||||
kill: kill,
|
||||
killall: killall,
|
||||
ls: ls,
|
||||
|
@ -3,7 +3,8 @@ import { IRouter } from "../../ui/Router";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { BaseServer } from "../../Server/BaseServer";
|
||||
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(
|
||||
terminal: ITerminal,
|
||||
@ -12,7 +13,7 @@ export function buy(
|
||||
server: BaseServer,
|
||||
args: (string | number)[],
|
||||
): void {
|
||||
if (!SpecialServerIps.hasOwnProperty("Darkweb Server")) {
|
||||
if (!GetServer(SpecialServers.DarkWeb)) {
|
||||
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)",
|
||||
);
|
||||
|
@ -17,13 +17,13 @@ export function connect(
|
||||
return;
|
||||
}
|
||||
|
||||
const ip = args[0] + "";
|
||||
const hostname = args[0] + "";
|
||||
|
||||
for (let i = 0; i < server.serversOnNetwork.length; i++) {
|
||||
const other = getServerOnNetwork(server, i);
|
||||
if (other === null) throw new Error(`Server on network should not be null`);
|
||||
if (other.ip == ip || other.hostname == ip) {
|
||||
terminal.connectToServer(player, ip);
|
||||
if (other.hostname == hostname) {
|
||||
terminal.connectToServer(player, hostname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ export function home(
|
||||
return;
|
||||
}
|
||||
player.getCurrentServer().isConnectedTo = false;
|
||||
player.currentServer = player.getHomeComputer().ip;
|
||||
player.currentServer = player.getHomeComputer().hostname;
|
||||
player.getCurrentServer().isConnectedTo = true;
|
||||
terminal.print("Connected to home");
|
||||
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");
|
||||
return;
|
||||
}
|
||||
killWorkerScript(runningScript, server.ip, false);
|
||||
killWorkerScript(runningScript, server.hostname, false);
|
||||
terminal.print(`Killing ${scriptName}`);
|
||||
} catch (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 {
|
||||
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();
|
||||
terminal.print("Killing all running scripts");
|
||||
|
@ -224,7 +224,6 @@ export function determineAllPossibilitiesForTabCompletion(
|
||||
|
||||
if (isCommand("scp") && index === 1) {
|
||||
for (const server of GetAllServers()) {
|
||||
allPos.push(server.ip);
|
||||
allPos.push(server.hostname);
|
||||
}
|
||||
|
||||
@ -247,7 +246,6 @@ export function determineAllPossibilitiesForTabCompletion(
|
||||
if (serv == null) {
|
||||
continue;
|
||||
}
|
||||
allPos.push(serv.ip);
|
||||
allPos.push(serv.hostname);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ import { initForeignServers } from "./Server/AllServers";
|
||||
import { Settings } from "./Settings/Settings";
|
||||
import { ThemeEvents } from "./ui/React/Theme";
|
||||
import { updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||
import { initSpecialServerIps } from "./Server/SpecialServerIps";
|
||||
import { initSymbolToStockMap, processStockPrices } from "./StockMarket/StockMarket";
|
||||
import { Terminal } from "./Terminal";
|
||||
import { Sleeve } from "./PersonObjects/Sleeve/Sleeve";
|
||||
@ -409,7 +408,6 @@ const Engine: {
|
||||
} else {
|
||||
// No save found, start new game
|
||||
initBitNodeMultipliers(Player);
|
||||
initSpecialServerIps();
|
||||
Engine.start(); // Run main game loop and Scripts loop
|
||||
Player.init();
|
||||
initForeignServers(Player.getHomeComputer());
|
||||
|
@ -54,9 +54,9 @@ export function ServerAccordions(props: IProps): React.ReactElement {
|
||||
|
||||
const serverToScriptMap: IServerToScriptsMap = {};
|
||||
for (const ws of props.workerScripts.values()) {
|
||||
const server = GetServer(ws.serverIp);
|
||||
const server = GetServer(ws.hostname);
|
||||
if (server == null) {
|
||||
console.warn(`WorkerScript has invalid IP address: ${ws.serverIp}`);
|
||||
console.warn(`WorkerScript has invalid IP address: ${ws.hostname}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user