finish convert to hostname

This commit is contained in:
Olivier Gagnon 2021-10-07 17:55:49 -04:00
parent 2958034ad4
commit 7d0536a4d2
37 changed files with 211 additions and 314 deletions

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 { Factions } from "./Faction/Factions";
import { Player } from "./Player"; import { Player } from "./Player";
import { GetServer, GetAllServers } from "./Server/AllServers"; import { GetServer, GetAllServers } from "./Server/AllServers";
import { SpecialServerNames } from "./Server/SpecialServerIps"; import { SpecialServers } from "./Server/data/SpecialServers";
import { Server } from "./Server/Server"; import { Server } from "./Server/Server";
import { BaseServer } from "./Server/BaseServer"; import { BaseServer } from "./Server/BaseServer";
@ -172,7 +172,7 @@ function getRandomServer(): BaseServer {
if ( if (
randServer instanceof Server && randServer instanceof Server &&
!randServer.purchasedByPlayer && !randServer.purchasedByPlayer &&
randServer.hostname !== SpecialServerNames.WorldDaemon randServer.hostname !== SpecialServers.WorldDaemon
) { ) {
break; break;
} }

@ -2,20 +2,13 @@ import { DarkWebItems } from "./DarkWebItems";
import { Player } from "../Player"; import { Player } from "../Player";
import { Terminal } from "../Terminal"; import { Terminal } from "../Terminal";
import { SpecialServerIps } from "../Server/SpecialServerIps"; import { SpecialServers } from "../Server/data/SpecialServers";
import { numeralWrapper } from "../ui/numeralFormat"; import { numeralWrapper } from "../ui/numeralFormat";
import { isValidIPAddress } from "../utils/helpers/isValidIPAddress";
//Posts a "help" message if connected to DarkWeb //Posts a "help" message if connected to DarkWeb
export function checkIfConnectedToDarkweb(): void { export function checkIfConnectedToDarkweb(): void {
if (SpecialServerIps.hasOwnProperty("Darkweb Server")) {
const darkwebIp = SpecialServerIps.getIp("Darkweb Server");
if (!isValidIPAddress(darkwebIp)) {
return;
}
const server = Player.getCurrentServer(); const server = Player.getCurrentServer();
if (server !== null && darkwebIp == server.ip) { if (server !== null && SpecialServers.DarkWeb == server.hostname) {
Terminal.print( Terminal.print(
"You are now connected to the dark web. From the dark web you can purchase illegal items. " + "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] " + "Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " +
@ -23,7 +16,6 @@ export function checkIfConnectedToDarkweb(): void {
); );
} }
} }
}
export function listAllDarkwebItems(): void { export function listAllDarkwebItems(): void {
for (const key in DarkWebItems) { for (const key in DarkWebItems) {

@ -17,11 +17,11 @@ import AccordionDetails from "@mui/material/AccordionDetails";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
interface IServerProps { interface IServerProps {
ip: string; hostname: string;
} }
function ServerAccordion(props: IServerProps): React.ReactElement { function ServerAccordion(props: IServerProps): React.ReactElement {
const server = GetServer(props.ip); const server = GetServer(props.hostname);
if (server === null) throw new Error("server should not be null"); 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) {
@ -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 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>
{keys.map((ip: string) => ( {keys.map((hostname: string) => (
<ServerAccordion key={ip} ip={ip} /> <ServerAccordion key={hostname} hostname={hostname} />
))} ))}
</> </>
</Modal> </Modal>

@ -7,7 +7,6 @@ import { CONSTANTS } from "../Constants";
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
import { AddToAllServers, createUniqueRandomIp } from "../Server/AllServers"; import { AddToAllServers, createUniqueRandomIp } from "../Server/AllServers";
import { safetlyCreateUniqueServer } from "../Server/ServerHelpers"; import { safetlyCreateUniqueServer } from "../Server/ServerHelpers";
import { SpecialServerIps } from "../Server/SpecialServerIps";
import { dialogBoxCreate } from "../ui/React/DialogBox"; import { dialogBoxCreate } from "../ui/React/DialogBox";
@ -36,10 +35,9 @@ export function purchaseTorRouter(p: IPlayer): void {
maxRam: 1, maxRam: 1,
}); });
AddToAllServers(darkweb); AddToAllServers(darkweb);
SpecialServerIps.addIp("Darkweb Server", darkweb.ip);
p.getHomeComputer().serversOnNetwork.push(darkweb.ip); p.getHomeComputer().serversOnNetwork.push(darkweb.hostname);
darkweb.serversOnNetwork.push(p.getHomeComputer().ip); darkweb.serversOnNetwork.push(p.getHomeComputer().hostname);
dialogBoxCreate( dialogBoxCreate(
"You have purchased a TOR router!<br>" + "You have purchased a TOR router!<br>" +
"You now have access to the dark web from your home computer.<br>" + "You now have access to the dark web from your home computer.<br>" +

@ -104,11 +104,11 @@ export class WorkerScript {
/** /**
* IP Address on which this script is running * IP Address on which this script is running
*/ */
serverIp: string; hostname: string;
constructor(runningScriptObj: RunningScript, pid: number, nsFuncsGenerator?: (ws: WorkerScript) => any) { constructor(runningScriptObj: RunningScript, pid: number, nsFuncsGenerator?: (ws: WorkerScript) => any) {
this.name = runningScriptObj.filename; this.name = runningScriptObj.filename;
this.serverIp = runningScriptObj.server; this.hostname = runningScriptObj.server;
const sanitizedPid = Math.round(pid); const sanitizedPid = Math.round(pid);
if (typeof sanitizedPid !== "number" || isNaN(sanitizedPid)) { if (typeof sanitizedPid !== "number" || isNaN(sanitizedPid)) {
@ -118,9 +118,9 @@ export class WorkerScript {
runningScriptObj.pid = sanitizedPid; runningScriptObj.pid = sanitizedPid;
// Get the underlying script's code // Get the underlying script's code
const server = GetServer(this.serverIp); const server = GetServer(this.hostname);
if (server == null) { if (server == null) {
throw new Error(`WorkerScript constructed with invalid server ip: ${this.serverIp}`); throw new Error(`WorkerScript constructed with invalid server ip: ${this.hostname}`);
} }
let found = false; let found = false;
for (let i = 0; i < server.scripts.length; ++i) { for (let i = 0; i < server.scripts.length; ++i) {
@ -147,7 +147,7 @@ export class WorkerScript {
* Returns the Server on which this script is running * Returns the Server on which this script is running
*/ */
getServer(): BaseServer { getServer(): BaseServer {
const server = 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?`); if (server == null) throw new Error(`Script ${this.name} pid ${this.pid} is running on non-existent server?`);
return server; return server;
} }

@ -12,12 +12,12 @@ import { GetServer } from "../Server/AllServers";
import { compareArrays } from "../utils/helpers/compareArrays"; import { compareArrays } from "../utils/helpers/compareArrays";
import { roundToTwo } from "../utils/helpers/roundToTwo"; import { roundToTwo } from "../utils/helpers/roundToTwo";
export function killWorkerScript(runningScriptObj: RunningScript, serverIp: string, rerenderUi?: boolean): boolean; export function killWorkerScript(runningScriptObj: RunningScript, hostname: string, rerenderUi?: boolean): boolean;
export function killWorkerScript(workerScript: WorkerScript): boolean; export function killWorkerScript(workerScript: WorkerScript): boolean;
export function killWorkerScript(pid: number): boolean; export function killWorkerScript(pid: number): boolean;
export function killWorkerScript( export function killWorkerScript(
script: RunningScript | WorkerScript | number, script: RunningScript | WorkerScript | number,
serverIp?: string, hostname?: string,
rerenderUi?: boolean, rerenderUi?: boolean,
): boolean { ): boolean {
if (rerenderUi == null || typeof rerenderUi !== "boolean") { if (rerenderUi == null || typeof rerenderUi !== "boolean") {
@ -28,7 +28,7 @@ export function killWorkerScript(
stopAndCleanUpWorkerScript(script); stopAndCleanUpWorkerScript(script);
return true; return true;
} else if (script instanceof RunningScript && typeof serverIp === "string") { } else if (script instanceof RunningScript && typeof hostname === "string") {
// Try to kill by PID // Try to kill by PID
const res = killWorkerScriptByPid(script.pid, rerenderUi); const res = killWorkerScriptByPid(script.pid, rerenderUi);
if (res) { if (res) {
@ -37,7 +37,7 @@ export function killWorkerScript(
// If for some reason that doesn't work, we'll try the old way // If for some reason that doesn't work, we'll try the old way
for (const ws of workerScripts.values()) { for (const ws of workerScripts.values()) {
if (ws.name == script.filename && ws.serverIp == serverIp && compareArrays(ws.args, script.args)) { if (ws.name == script.filename && ws.hostname == hostname && compareArrays(ws.args, script.args)) {
stopAndCleanUpWorkerScript(ws, rerenderUi); stopAndCleanUpWorkerScript(ws, rerenderUi);
return true; return true;
@ -80,7 +80,7 @@ function stopAndCleanUpWorkerScript(workerScript: WorkerScript, rerenderUi = tru
*/ */
function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void { function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void {
if (workerScript instanceof WorkerScript) { if (workerScript instanceof WorkerScript) {
const ip = workerScript.serverIp; const ip = workerScript.hostname;
const name = workerScript.name; const name = workerScript.name;
// Get the server on which the script runs // Get the server on which the script runs

@ -14,9 +14,9 @@ export function netscriptDelay(time: number, workerScript: WorkerScript): Promis
export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): string { export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): string {
const lineNum = ""; const lineNum = "";
const server = GetServer(workerScript.serverIp); const server = GetServer(workerScript.hostname);
if (server == null) { if (server == null) {
throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.serverIp}`); throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`);
} }
return "|" + server.hostname + "|" + workerScript.name + "|" + msg + lineNum; return "|" + server.hostname + "|" + workerScript.name + "|" + msg + lineNum;

@ -99,7 +99,6 @@ import {
} from "./Server/ServerHelpers"; } from "./Server/ServerHelpers";
import { getPurchaseServerCost, getPurchaseServerLimit, getPurchaseServerMaxRam } from "./Server/ServerPurchases"; import { getPurchaseServerCost, getPurchaseServerLimit, getPurchaseServerMaxRam } from "./Server/ServerPurchases";
import { Server } from "./Server/Server"; import { Server } from "./Server/Server";
import { SpecialServerIps } from "./Server/SpecialServerIps";
import { SourceFileFlags } from "./SourceFile/SourceFileFlags"; import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
import { buyStock, sellStock, shortStock, sellShort } from "./StockMarket/BuyingAndSelling"; import { buyStock, sellStock, shortStock, sellShort } from "./StockMarket/BuyingAndSelling";
import { influenceStockThroughServerHack, influenceStockThroughServerGrow } from "./StockMarket/PlayerInfluencing"; import { influenceStockThroughServerHack, influenceStockThroughServerGrow } from "./StockMarket/PlayerInfluencing";
@ -137,7 +136,6 @@ import { IIndustry } from "./Corporation/IIndustry";
import { Faction } from "./Faction/Faction"; import { Faction } from "./Faction/Faction";
import { Augmentation } from "./Augmentation/Augmentation"; import { Augmentation } from "./Augmentation/Augmentation";
import { HacknetNode } from "./Hacknet/HacknetNode";
import { CodingContract } from "./CodingContracts"; import { CodingContract } from "./CodingContracts";
import { Stock } from "./StockMarket/Stock"; import { Stock } from "./StockMarket/Stock";
@ -198,7 +196,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
let threads = workerScript.scriptRef.threads; let threads = workerScript.scriptRef.threads;
if (typeof threads !== "number") { if (typeof threads !== "number") {
console.warn(`WorkerScript detected NaN for threadcount for ${workerScript.name} on ${workerScript.serverIp}`); console.warn(`WorkerScript detected NaN for threadcount for ${workerScript.name} on ${workerScript.hostname}`);
threads = 1; threads = 1;
} }
@ -271,7 +269,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
if (fn != null && typeof fn === "string") { if (fn != null && typeof fn === "string") {
// Get Logs of another script // Get Logs of another script
if (ip == null) { if (ip == null) {
ip = workerScript.serverIp; ip = workerScript.hostname;
} }
const server = safeGetServer(ip, callingFnName); const server = safeGetServer(ip, callingFnName);
@ -649,7 +647,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
workerScript.scriptRef.onlineMoneyMade += moneyGained; workerScript.scriptRef.onlineMoneyMade += moneyGained;
Player.scriptProdSinceLastAug += moneyGained; Player.scriptProdSinceLastAug += moneyGained;
Player.recordMoneySource(moneyGained, "hacking"); Player.recordMoneySource(moneyGained, "hacking");
workerScript.scriptRef.recordHack(server.ip, moneyGained, threads); workerScript.scriptRef.recordHack(server.hostname, moneyGained, threads);
Player.gainHackingExp(expGainedOnSuccess); Player.gainHackingExp(expGainedOnSuccess);
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess; workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
workerScript.log( workerScript.log(
@ -722,7 +720,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
hacknet: hacknet, hacknet: hacknet,
sprintf: sprintf, sprintf: sprintf,
vsprintf: vsprintf, vsprintf: vsprintf,
scan: function (ip: any = workerScript.serverIp, hostnames: any = true): any { scan: function (ip: any = workerScript.hostname, hostnames: any = true): any {
updateDynamicRam("scan", getRamCost("scan")); updateDynamicRam("scan", getRamCost("scan"));
const server = GetServer(ip); const server = GetServer(ip);
if (server == null) { if (server == null) {
@ -736,7 +734,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
if (hostnames) { if (hostnames) {
entry = s.hostname; entry = s.hostname;
} else { } else {
entry = s.ip; entry = s.hostname;
} }
if (entry == null) { if (entry == null) {
continue; continue;
@ -820,7 +818,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
throw makeRuntimeErrorMsg("grow", `Invalid IP/hostname: ${ip}.`); throw makeRuntimeErrorMsg("grow", `Invalid IP/hostname: ${ip}.`);
} }
const host = GetServer(workerScript.serverIp); const host = GetServer(workerScript.hostname);
if (host === null) { if (host === null) {
throw new Error("Workerscript host is null"); throw new Error("Workerscript host is null");
} }
@ -846,7 +844,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
const moneyBefore = server.moneyAvailable <= 0 ? 1 : server.moneyAvailable; const moneyBefore = server.moneyAvailable <= 0 ? 1 : server.moneyAvailable;
processSingleServerGrowth(server, threads, Player, host.cpuCores); processSingleServerGrowth(server, threads, Player, host.cpuCores);
const moneyAfter = server.moneyAvailable; const moneyAfter = server.moneyAvailable;
workerScript.scriptRef.recordGrow(server.ip, threads); workerScript.scriptRef.recordGrow(server.hostname, threads);
const expGain = calculateHackingExpGain(server, Player) * threads; const expGain = calculateHackingExpGain(server, Player) * threads;
const logGrowPercent = moneyAfter / moneyBefore - 1; const logGrowPercent = moneyAfter / moneyBefore - 1;
workerScript.log( workerScript.log(
@ -910,14 +908,14 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
); );
return netscriptDelay(weakenTime * 1000, workerScript).then(function () { return netscriptDelay(weakenTime * 1000, workerScript).then(function () {
if (workerScript.env.stopFlag) return Promise.reject(workerScript); if (workerScript.env.stopFlag) return Promise.reject(workerScript);
const host = GetServer(workerScript.serverIp); const host = GetServer(workerScript.hostname);
if (host === null) { if (host === null) {
workerScript.log("weaken", "Server is null, did it die?"); workerScript.log("weaken", "Server is null, did it die?");
return Promise.resolve(0); return Promise.resolve(0);
} }
const coreBonus = 1 + (host.cpuCores - 1) / 16; const coreBonus = 1 + (host.cpuCores - 1) / 16;
server.weaken(CONSTANTS.ServerWeakenAmount * threads * coreBonus); server.weaken(CONSTANTS.ServerWeakenAmount * threads * coreBonus);
workerScript.scriptRef.recordWeaken(server.ip, threads); workerScript.scriptRef.recordWeaken(server.hostname, threads);
const expGain = calculateHackingExpGain(server, Player) * threads; const expGain = calculateHackingExpGain(server, Player) * threads;
workerScript.log( workerScript.log(
"weaken", "weaken",
@ -983,7 +981,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
return runningScriptObj.logs.slice(); return runningScriptObj.logs.slice();
}, },
tail: function (fn: any, ip: any = workerScript.serverIp, ...scriptArgs: any): any { tail: function (fn: any, ip: any = workerScript.hostname, ...scriptArgs: any): any {
let runningScriptObj; let runningScriptObj;
if (arguments.length === 0) { if (arguments.length === 0) {
runningScriptObj = workerScript.scriptRef; runningScriptObj = workerScript.scriptRef;
@ -1159,7 +1157,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
if (isNaN(threads) || threads <= 0) { if (isNaN(threads) || threads <= 0) {
throw makeRuntimeErrorMsg("run", `Invalid thread count. Must be numeric and > 0, is ${threads}`); throw makeRuntimeErrorMsg("run", `Invalid thread count. Must be numeric and > 0, is ${threads}`);
} }
const scriptServer = GetServer(workerScript.serverIp); const scriptServer = GetServer(workerScript.hostname);
if (scriptServer == null) { if (scriptServer == null) {
throw makeRuntimeErrorMsg("run", "Could not find server. This is a bug. Report to dev."); throw makeRuntimeErrorMsg("run", "Could not find server. This is a bug. Report to dev.");
} }
@ -1191,7 +1189,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
if (isNaN(threads) || threads <= 0) { if (isNaN(threads) || threads <= 0) {
throw makeRuntimeErrorMsg("spawn", `Invalid thread count. Must be numeric and > 0, is ${threads}`); throw makeRuntimeErrorMsg("spawn", `Invalid thread count. Must be numeric and > 0, is ${threads}`);
} }
const scriptServer = GetServer(workerScript.serverIp); const scriptServer = GetServer(workerScript.hostname);
if (scriptServer == null) { if (scriptServer == null) {
throw makeRuntimeErrorMsg("spawn", "Could not find server. This is a bug. Report to dev"); throw makeRuntimeErrorMsg("spawn", "Could not find server. This is a bug. Report to dev");
} }
@ -1227,7 +1225,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
return false; return false;
} }
res = killWorkerScript(runningScriptObj, server.ip); res = killWorkerScript(runningScriptObj, server.hostname);
} }
if (res) { if (res) {
@ -1246,7 +1244,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
return false; return false;
} }
}, },
killall: function (ip: any = workerScript.serverIp): any { killall: function (ip: any = workerScript.hostname): any {
updateDynamicRam("killall", getRamCost("killall")); updateDynamicRam("killall", getRamCost("killall"));
if (ip === undefined) { if (ip === undefined) {
throw makeRuntimeErrorMsg("killall", "Takes 1 argument"); throw makeRuntimeErrorMsg("killall", "Takes 1 argument");
@ -1257,7 +1255,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
} }
const scriptsRunning = server.runningScripts.length > 0; const scriptsRunning = server.runningScripts.length > 0;
for (let i = server.runningScripts.length - 1; i >= 0; --i) { for (let i = server.runningScripts.length - 1; i >= 0; --i) {
killWorkerScript(server.runningScripts[i], server.ip, false); killWorkerScript(server.runningScripts[i], server.hostname, false);
} }
WorkerScriptStartStopEventEmitter.emit(); WorkerScriptStartStopEventEmitter.emit();
workerScript.log( workerScript.log(
@ -1327,7 +1325,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
throw makeRuntimeErrorMsg("scp", `Invalid IP/hostname: ${ip1}`); throw makeRuntimeErrorMsg("scp", `Invalid IP/hostname: ${ip1}`);
} }
currServ = GetServer(workerScript.serverIp); currServ = GetServer(workerScript.hostname);
if (currServ == null) { if (currServ == null) {
throw makeRuntimeErrorMsg("scp", "Could not find server ip for this script. This is a bug. Report to dev."); throw makeRuntimeErrorMsg("scp", "Could not find server ip for this script. This is a bug. Report to dev.");
} }
@ -1422,7 +1420,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
const newScript = new Script(scriptname); const newScript = new Script(scriptname);
newScript.code = sourceScript.code; newScript.code = sourceScript.code;
newScript.ramUsage = sourceScript.ramUsage; newScript.ramUsage = sourceScript.ramUsage;
newScript.server = destServer.ip; newScript.server = destServer.hostname;
destServer.scripts.push(newScript); destServer.scripts.push(newScript);
workerScript.log("scp", `File '${scriptname}' copied over to '${destServer.hostname}'.`); workerScript.log("scp", `File '${scriptname}' copied over to '${destServer.hostname}'.`);
return true; return true;
@ -1506,7 +1504,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
allFiles.sort(); allFiles.sort();
return allFiles; return allFiles;
}, },
ps: function (ip: any = workerScript.serverIp): any { ps: function (ip: any = workerScript.hostname): any {
updateDynamicRam("ps", getRamCost("ps")); updateDynamicRam("ps", getRamCost("ps"));
const server = GetServer(ip); const server = GetServer(ip);
if (server == null) { if (server == null) {
@ -1537,15 +1535,15 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
}, },
getIp: function (): any { getIp: function (): any {
updateDynamicRam("getIp", getRamCost("getIp")); updateDynamicRam("getIp", getRamCost("getIp"));
const scriptServer = GetServer(workerScript.serverIp); const scriptServer = GetServer(workerScript.hostname);
if (scriptServer == null) { if (scriptServer == null) {
throw makeRuntimeErrorMsg("getIp", "Could not find server. This is a bug. Report to dev."); throw makeRuntimeErrorMsg("getIp", "Could not find server. This is a bug. Report to dev.");
} }
return scriptServer.ip; return scriptServer.hostname;
}, },
getHostname: function (): any { getHostname: function (): any {
updateDynamicRam("getHostname", getRamCost("getHostname")); updateDynamicRam("getHostname", getRamCost("getHostname"));
const scriptServer = GetServer(workerScript.serverIp); const scriptServer = GetServer(workerScript.hostname);
if (scriptServer == null) { if (scriptServer == null) {
throw makeRuntimeErrorMsg("getHostname", "Could not find server. This is a bug. Report to dev."); throw makeRuntimeErrorMsg("getHostname", "Could not find server. This is a bug. Report to dev.");
} }
@ -1756,7 +1754,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
updateDynamicRam("serverExists", getRamCost("serverExists")); updateDynamicRam("serverExists", getRamCost("serverExists"));
return GetServer(ip) !== null; return GetServer(ip) !== null;
}, },
fileExists: function (filename: any, ip: any = workerScript.serverIp): any { fileExists: function (filename: any, ip: any = workerScript.hostname): any {
updateDynamicRam("fileExists", getRamCost("fileExists")); updateDynamicRam("fileExists", getRamCost("fileExists"));
if (filename === undefined) { if (filename === undefined) {
throw makeRuntimeErrorMsg("fileExists", "Usage: fileExists(scriptname, [server])"); throw makeRuntimeErrorMsg("fileExists", "Usage: fileExists(scriptname, [server])");
@ -1786,7 +1784,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
} }
return false; return false;
}, },
isRunning: function (fn: any, ip: any = workerScript.serverIp, ...scriptArgs: any): any { isRunning: function (fn: any, ip: any = workerScript.hostname, ...scriptArgs: any): any {
updateDynamicRam("isRunning", getRamCost("isRunning")); updateDynamicRam("isRunning", getRamCost("isRunning"));
if (fn === undefined || ip === undefined) { if (fn === undefined || ip === undefined) {
throw makeRuntimeErrorMsg("isRunning", "Usage: isRunning(scriptname, server, [arg1], [arg2]...)"); throw makeRuntimeErrorMsg("isRunning", "Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
@ -2170,10 +2168,10 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
}); });
AddToAllServers(newServ); AddToAllServers(newServ);
Player.purchasedServers.push(newServ.ip); Player.purchasedServers.push(newServ.hostname);
const homeComputer = Player.getHomeComputer(); const homeComputer = Player.getHomeComputer();
homeComputer.serversOnNetwork.push(newServ.ip); homeComputer.serversOnNetwork.push(newServ.hostname);
newServ.serversOnNetwork.push(homeComputer.ip); newServ.serversOnNetwork.push(homeComputer.hostname);
Player.loseMoney(cost); Player.loseMoney(cost);
workerScript.log( workerScript.log(
"purchaseServer", "purchaseServer",
@ -2200,7 +2198,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
return false; return false;
} }
const ip = server.ip; const ip = server.hostname;
// Can't delete server you're currently connected to // Can't delete server you're currently connected to
if (server.isConnectedTo) { if (server.isConnectedTo) {
@ -2209,7 +2207,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
} }
// A server cannot delete itself // A server cannot delete itself
if (ip === workerScript.serverIp) { if (ip === workerScript.hostname) {
workerScript.log("deleteServer", "Cannot delete the server this script is running on."); workerScript.log("deleteServer", "Cannot delete the server this script is running on.");
return false; return false;
} }
@ -2321,7 +2319,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
let script = workerScript.getScriptOnServer(fn, server); let script = workerScript.getScriptOnServer(fn, server);
if (script == null) { if (script == null) {
// Create a new script // Create a new script
script = new Script(fn, data, server.ip, server.scripts); script = new Script(fn, data, server.hostname, server.scripts);
server.scripts.push(script); server.scripts.push(script);
return true; return true;
} }
@ -2387,7 +2385,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
} else if (isString(port)) { } else if (isString(port)) {
// Read from script or text file // Read from script or text file
const fn = port; const fn = port;
const server = GetServer(workerScript.serverIp); const server = GetServer(workerScript.hostname);
if (server == null) { if (server == null) {
throw makeRuntimeErrorMsg("read", "Error getting Server. This is a bug. Report to dev."); throw makeRuntimeErrorMsg("read", "Error getting Server. This is a bug. Report to dev.");
} }
@ -2453,7 +2451,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
} else if (isString(port)) { } else if (isString(port)) {
// Clear text file // Clear text file
const fn = port; const fn = port;
const server = GetServer(workerScript.serverIp); const server = GetServer(workerScript.hostname);
if (server == null) { if (server == null) {
throw makeRuntimeErrorMsg("clear", "Error getting Server. This is a bug. Report to dev."); throw makeRuntimeErrorMsg("clear", "Error getting Server. This is a bug. Report to dev.");
} }
@ -2491,7 +2489,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
updateDynamicRam("rm", getRamCost("rm")); updateDynamicRam("rm", getRamCost("rm"));
if (ip == null || ip === "") { if (ip == null || ip === "") {
ip = workerScript.serverIp; ip = workerScript.hostname;
} }
const s = safeGetServer(ip, "rm"); const s = safeGetServer(ip, "rm");
@ -2524,7 +2522,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
let suc = false; let suc = false;
for (let i = 0; i < server.runningScripts.length; ++i) { for (let i = 0; i < server.runningScripts.length; ++i) {
if (server.runningScripts[i].filename == scriptname) { if (server.runningScripts[i].filename == scriptname) {
killWorkerScript(server.runningScripts[i], server.ip); killWorkerScript(server.runningScripts[i], server.hostname);
suc = true; suc = true;
} }
} }
@ -2533,7 +2531,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
getScriptName: function (): any { getScriptName: function (): any {
return workerScript.name; return workerScript.name;
}, },
getScriptRam: function (scriptname: any, ip: any = workerScript.serverIp): any { getScriptRam: function (scriptname: any, ip: any = workerScript.hostname): any {
updateDynamicRam("getScriptRam", getRamCost("getScriptRam")); updateDynamicRam("getScriptRam", getRamCost("getScriptRam"));
const server = GetServer(ip); const server = GetServer(ip);
if (server == null) { if (server == null) {
@ -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")) { if (!isScriptFilename(target) && !target.endsWith(".txt")) {
workerScript.log("wget", `Invalid target file: '${target}'. Must be a script or text file.`); workerScript.log("wget", `Invalid target file: '${target}'. Must be a script or text file.`);
return Promise.resolve(false); return Promise.resolve(false);
@ -2938,7 +2936,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
updateDynamicRam("purchaseTor", getRamCost("purchaseTor")); updateDynamicRam("purchaseTor", getRamCost("purchaseTor"));
checkSingularityAccess("purchaseTor", 1); checkSingularityAccess("purchaseTor", 1);
if (SpecialServerIps["Darkweb Server"] != null) { if (Player.hasTorRouter()) {
workerScript.log("purchaseTor", "You already have a TOR router!"); workerScript.log("purchaseTor", "You already have a TOR router!");
return false; return false;
} }
@ -2959,10 +2957,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
maxRam: 1, maxRam: 1,
}); });
AddToAllServers(darkweb); AddToAllServers(darkweb);
SpecialServerIps.addIp("Darkweb Server", darkweb.ip);
Player.getHomeComputer().serversOnNetwork.push(darkweb.ip); Player.getHomeComputer().serversOnNetwork.push(darkweb.hostname);
darkweb.serversOnNetwork.push(Player.getHomeComputer().ip); darkweb.serversOnNetwork.push(Player.getHomeComputer().hostname);
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
workerScript.log("purchaseTor", "You have purchased a Tor router!"); workerScript.log("purchaseTor", "You have purchased a Tor router!");
return true; return true;
@ -2971,7 +2968,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
updateDynamicRam("purchaseProgram", getRamCost("purchaseProgram")); updateDynamicRam("purchaseProgram", getRamCost("purchaseProgram"));
checkSingularityAccess("purchaseProgram", 1); checkSingularityAccess("purchaseProgram", 1);
if (SpecialServerIps["Darkweb Server"] == null) { if (!Player.hasTorRouter()) {
workerScript.log("purchaseProgram", "You do not have the TOR router."); workerScript.log("purchaseProgram", "You do not have the TOR router.");
return false; return false;
} }
@ -3032,7 +3029,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
if (hostname === "home") { if (hostname === "home") {
Player.getCurrentServer().isConnectedTo = false; Player.getCurrentServer().isConnectedTo = false;
Player.currentServer = Player.getHomeComputer().ip; Player.currentServer = Player.getHomeComputer().hostname;
Player.getCurrentServer().isConnectedTo = true; Player.getCurrentServer().isConnectedTo = true;
Terminal.setcwd("/"); Terminal.setcwd("/");
return true; return true;
@ -3042,9 +3039,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
for (let i = 0; i < server.serversOnNetwork.length; i++) { for (let i = 0; i < server.serversOnNetwork.length; i++) {
const other = getServerOnNetwork(server, i); const other = getServerOnNetwork(server, i);
if (other === null) continue; if (other === null) continue;
if (other.ip == hostname || other.hostname == hostname) { if (other.hostname == hostname) {
Player.getCurrentServer().isConnectedTo = false; Player.getCurrentServer().isConnectedTo = false;
Player.currentServer = target.ip; Player.currentServer = target.hostname;
Player.getCurrentServer().isConnectedTo = true; Player.getCurrentServer().isConnectedTo = true;
Terminal.setcwd("/"); Terminal.setcwd("/");
return true; return true;
@ -3137,7 +3134,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
workMoney: Player.work_money_mult, workMoney: Player.work_money_mult,
}, },
timeWorked: Player.timeWorked, timeWorked: Player.timeWorked,
tor: SpecialServerIps.hasOwnProperty("Darkweb Server"), tor: Player.hasTorRouter(),
workHackExpGain: Player.workHackExpGained, workHackExpGain: Player.workHackExpGained,
workStrExpGain: Player.workStrExpGained, workStrExpGain: Player.workStrExpGained,
workDefExpGain: Player.workDefExpGained, workDefExpGain: Player.workDefExpGained,
@ -3243,7 +3240,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
playtimeSinceLastBitnode: Player.playtimeSinceLastBitnode, playtimeSinceLastBitnode: Player.playtimeSinceLastBitnode,
jobs: {}, jobs: {},
factions: Player.factions.slice(), factions: Player.factions.slice(),
tor: SpecialServerIps.hasOwnProperty("Darkweb Server"), tor: Player.hasTorRouter(),
}; };
Object.assign(data.jobs, Player.jobs); Object.assign(data.jobs, Player.jobs);
return data; return data;
@ -4398,7 +4395,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
// Coding Contract API // Coding Contract API
codingcontract: { codingcontract: {
attempt: function (answer: any, fn: any, ip: any = workerScript.serverIp, { returnReward }: any = {}): any { attempt: function (answer: any, fn: any, ip: any = workerScript.hostname, { returnReward }: any = {}): any {
updateDynamicRam("attempt", getRamCost("codingcontract", "attempt")); updateDynamicRam("attempt", getRamCost("codingcontract", "attempt"));
const contract = getCodingContract("attempt", ip, fn); const contract = getCodingContract("attempt", ip, fn);
@ -4441,12 +4438,12 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
return returnReward ? "" : false; return returnReward ? "" : false;
} }
}, },
getContractType: function (fn: any, ip: any = workerScript.serverIp): any { getContractType: function (fn: any, ip: any = workerScript.hostname): any {
updateDynamicRam("getContractType", getRamCost("codingcontract", "getContractType")); updateDynamicRam("getContractType", getRamCost("codingcontract", "getContractType"));
const contract = getCodingContract("getContractType", ip, fn); const contract = getCodingContract("getContractType", ip, fn);
return contract.getType(); return contract.getType();
}, },
getData: function (fn: any, ip: any = workerScript.serverIp): any { getData: function (fn: any, ip: any = workerScript.hostname): any {
updateDynamicRam("getData", getRamCost("codingcontract", "getData")); updateDynamicRam("getData", getRamCost("codingcontract", "getData"));
const contract = getCodingContract("getData", ip, fn); const contract = getCodingContract("getData", ip, fn);
const data = contract.getData(); const data = contract.getData();
@ -4466,12 +4463,12 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
return data; return data;
} }
}, },
getDescription: function (fn: any, ip: any = workerScript.serverIp): any { getDescription: function (fn: any, ip: any = workerScript.hostname): any {
updateDynamicRam("getDescription", getRamCost("codingcontract", "getDescription")); updateDynamicRam("getDescription", getRamCost("codingcontract", "getDescription"));
const contract = getCodingContract("getDescription", ip, fn); const contract = getCodingContract("getDescription", ip, fn);
return contract.getDescription(); return contract.getDescription();
}, },
getNumTriesRemaining: function (fn: any, ip: any = workerScript.serverIp): any { getNumTriesRemaining: function (fn: any, ip: any = workerScript.hostname): any {
updateDynamicRam("getNumTriesRemaining", getRamCost("codingcontract", "getNumTriesRemaining")); updateDynamicRam("getNumTriesRemaining", getRamCost("codingcontract", "getNumTriesRemaining"));
const contract = getCodingContract("getNumTriesRemaining", ip, fn); const contract = getCodingContract("getNumTriesRemaining", ip, fn);
return contract.getMaxNumTries() - contract.tries; return contract.getMaxNumTries() - contract.tries;

@ -4,7 +4,6 @@ import { getRamCost } from "../Netscript/RamCostGenerator";
import { FactionWorkType } from "../Faction/FactionWorkTypeEnum"; import { FactionWorkType } from "../Faction/FactionWorkTypeEnum";
import { SourceFileFlags } from "../SourceFile/SourceFileFlags"; import { SourceFileFlags } from "../SourceFile/SourceFileFlags";
import { SleeveTaskType } from "../PersonObjects/Sleeve/SleeveTaskTypesEnum"; import { SleeveTaskType } from "../PersonObjects/Sleeve/SleeveTaskTypesEnum";
import { SpecialServerIps } from "../Server/SpecialServerIps";
import { WorkerScript } from "../Netscript/WorkerScript"; import { WorkerScript } from "../Netscript/WorkerScript";
import { findSleevePurchasableAugs } from "../PersonObjects/Sleeve/SleeveHelpers"; import { findSleevePurchasableAugs } from "../PersonObjects/Sleeve/SleeveHelpers";
import { Augmentations } from "../Augmentation/Augmentations"; import { Augmentations } from "../Augmentation/Augmentations";
@ -231,7 +230,6 @@ export function NetscriptSleeve(
jobs: Object.keys(player.jobs), // technically sleeves have the same jobs as the player. jobs: Object.keys(player.jobs), // technically sleeves have the same jobs as the player.
jobTitle: Object.values(player.jobs), jobTitle: Object.values(player.jobs),
maxHp: sl.max_hp, maxHp: sl.max_hp,
tor: SpecialServerIps.hasOwnProperty("Darkweb Server"), // There's no reason not to give that infomation here as well. Worst case scenario it isn't used.
mult: { mult: {
agility: sl.agility_mult, agility: sl.agility_mult,

@ -544,11 +544,11 @@ export function createAndAddWorkerScript(
console.error("Error text: " + w.errorMessage); console.error("Error text: " + w.errorMessage);
return; return;
} }
const serverIp = errorTextArray[1]; const hostname = errorTextArray[1];
const scriptName = errorTextArray[2]; const scriptName = errorTextArray[2];
const errorMsg = errorTextArray[3]; const errorMsg = errorTextArray[3];
let msg = `RUNTIME ERROR<br>${scriptName}@${serverIp}<br>`; let msg = `RUNTIME ERROR<br>${scriptName}@${hostname}<br>`;
if (w.args.length > 0) { if (w.args.length > 0) {
msg += `Args: ${arrayToString(w.args)}<br>`; msg += `Args: ${arrayToString(w.args)}<br>`;
} }

@ -36,7 +36,7 @@ import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/A
import { Server } from "../../Server/Server"; import { Server } from "../../Server/Server";
import { safetlyCreateUniqueServer } from "../../Server/ServerHelpers"; import { safetlyCreateUniqueServer } from "../../Server/ServerHelpers";
import { Settings } from "../../Settings/Settings"; import { Settings } from "../../Settings/Settings";
import { SpecialServerIps, SpecialServerNames } from "../../Server/SpecialServerIps"; import { SpecialServers } from "../../Server/data/SpecialServers";
import { applySourceFile } from "../../SourceFile/applySourceFile"; import { applySourceFile } from "../../SourceFile/applySourceFile";
import { applyExploit } from "../../Exploits/applyExploits"; import { applyExploit } from "../../Exploits/applyExploits";
import { SourceFiles } from "../../SourceFile/SourceFiles"; import { SourceFiles } from "../../SourceFile/SourceFiles";
@ -70,7 +70,7 @@ export function init(this: IPlayer): void {
organizationName: "Home PC", organizationName: "Home PC",
purchasedByPlayer: true, purchasedByPlayer: true,
}); });
this.currentServer = t_homeComp.ip; this.currentServer = SpecialServers.Home;
AddToAllServers(t_homeComp); AddToAllServers(t_homeComp);
this.getHomeComputer().programs.push(Programs.NukeProgram.name); this.getHomeComputer().programs.push(Programs.NukeProgram.name);
@ -78,7 +78,7 @@ export function init(this: IPlayer): void {
export function prestigeAugmentation(this: IPlayer): void { export function prestigeAugmentation(this: IPlayer): void {
const homeComp = this.getHomeComputer(); const homeComp = this.getHomeComputer();
this.currentServer = homeComp.ip; this.currentServer = SpecialServers.Home;
this.numPeopleKilled = 0; this.numPeopleKilled = 0;
this.karma = 0; this.karma = 0;
@ -575,13 +575,11 @@ export function startWork(this: IPlayer, router: IRouter, companyName: string):
} }
export function cancelationPenalty(this: IPlayer): number { export function cancelationPenalty(this: IPlayer): number {
const specialIp = SpecialServerIps[this.companyName]; const server = GetServer(this.companyName);
if (typeof specialIp === "string" && specialIp !== "") {
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;
} }
}
return 0.5; 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 //Fulcrum Secret Technologies - If u've unlocked fulcrum secret technolgoies server and have a high rep with the company
const fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"]; const fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"];
const fulcrumIP = SpecialServerIps[SpecialServerNames.BitRunnersServer]; const fulcrumSecretServer = GetServer(SpecialServers.FulcrumSecretTechnologies);
if (typeof fulcrumIP !== "string") throw new Error("Fulcrum Secret Technologies should be string");
const fulcrumSecretServer = 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");
@ -2210,9 +2206,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
//BitRunners //BitRunners
const bitrunnersFac = Factions["BitRunners"]; const bitrunnersFac = Factions["BitRunners"];
const bitrunnerIP = SpecialServerIps[SpecialServerNames.BitRunnersServer]; const bitrunnersServer = GetServer(SpecialServers.BitRunnersServer);
if (typeof bitrunnerIP !== "string") throw new Error("BitRunners should be string");
const bitrunnersServer = 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");
@ -2228,9 +2222,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
//The Black Hand //The Black Hand
const theblackhandFac = Factions["The Black Hand"]; const theblackhandFac = Factions["The Black Hand"];
const tbhIP = SpecialServerIps[SpecialServerNames.TheBlackHandServer]; const blackhandServer = GetServer(SpecialServers.TheBlackHandServer);
if (typeof tbhIP !== "string") throw new Error("TheBlackHand should be string");
const blackhandServer = 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");
@ -2245,9 +2237,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
//NiteSec //NiteSec
const nitesecFac = Factions["NiteSec"]; const nitesecFac = Factions["NiteSec"];
const nitesecIP = SpecialServerIps[SpecialServerNames.NiteSecServer]; const nitesecServer = GetServer(SpecialServers.NiteSecServer);
if (typeof nitesecIP !== "string") throw new Error("NiteSec should be string");
const nitesecServer = 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");
@ -2485,9 +2475,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
//CyberSec //CyberSec
const cybersecFac = Factions["CyberSec"]; const cybersecFac = Factions["CyberSec"];
const cyberSecIP = SpecialServerIps[SpecialServerNames.CyberSecServer]; const cybersecServer = GetServer(SpecialServers.CyberSecServer);
if (typeof cyberSecIP !== "string") throw new Error("cybersec should be string");
const cybersecServer = 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");

@ -10,10 +10,10 @@ import { Server } from "../../Server/Server";
import { BaseServer } from "../../Server/BaseServer"; import { BaseServer } from "../../Server/BaseServer";
import { HacknetServer } from "../../Hacknet/HacknetServer"; import { HacknetServer } from "../../Hacknet/HacknetServer";
import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers"; import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers";
import { SpecialServerIps } from "../../Server/SpecialServerIps"; import { SpecialServers } from "../../Server/data/SpecialServers";
export function hasTorRouter(this: IPlayer): boolean { export function hasTorRouter(this: IPlayer): boolean {
return SpecialServerIps.hasOwnProperty("Darkweb Server"); return !!GetServer(SpecialServers.DarkWeb);
} }
export function getCurrentServer(this: IPlayer): BaseServer { export function getCurrentServer(this: IPlayer): BaseServer {
@ -49,13 +49,13 @@ export function createHacknetServer(this: IPlayer): HacknetServer {
ip: createUniqueRandomIp(), ip: createUniqueRandomIp(),
// player: this, // player: this,
}); });
this.hacknetNodes.push(server.ip); this.hacknetNodes.push(server.hostname);
// Configure the HacknetServer to actually act as a Server // Configure the HacknetServer to actually act as a Server
AddToAllServers(server); AddToAllServers(server);
const homeComputer = this.getHomeComputer(); const homeComputer = this.getHomeComputer();
homeComputer.serversOnNetwork.push(server.ip); homeComputer.serversOnNetwork.push(server.hostname);
server.serversOnNetwork.push(homeComputer.ip); server.serversOnNetwork.push(SpecialServers.Home);
return server; return server;
} }

@ -20,7 +20,7 @@ import { LiteratureNames } from "./Literature/data/LiteratureNames";
import { GetServer, AddToAllServers, initForeignServers, prestigeAllServers } from "./Server/AllServers"; import { GetServer, AddToAllServers, initForeignServers, prestigeAllServers } from "./Server/AllServers";
import { prestigeHomeComputer } from "./Server/ServerHelpers"; import { prestigeHomeComputer } from "./Server/ServerHelpers";
import { SourceFileFlags, updateSourceFileFlags } from "./SourceFile/SourceFileFlags"; import { SourceFileFlags, updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
import { prestigeSpecialServerIps, SpecialServerNames } from "./Server/SpecialServerIps"; import { SpecialServers } from "./Server/data/SpecialServers";
import { deleteStockMarket, initStockMarket, initSymbolToStockMap } from "./StockMarket/StockMarket"; import { deleteStockMarket, initStockMarket, initSymbolToStockMap } from "./StockMarket/StockMarket";
import { Terminal } from "./Terminal"; import { Terminal } from "./Terminal";
@ -46,9 +46,6 @@ function prestigeAugmentation(): void {
// Delete all servers except home computer // Delete all servers except home computer
prestigeAllServers(); prestigeAllServers();
// Delete Special Server IPs
prestigeSpecialServerIps(); // Must be done before initForeignServers()
// Reset home computer (only the programs) and add to AllServers // Reset home computer (only the programs) and add to AllServers
AddToAllServers(homeComp); AddToAllServers(homeComp);
prestigeHomeComputer(homeComp); prestigeHomeComputer(homeComp);
@ -132,11 +129,11 @@ function prestigeAugmentation(): void {
// Red Pill // Red Pill
if (augmentationExists(AugmentationNames.TheRedPill) && Augmentations[AugmentationNames.TheRedPill].owned) { if (augmentationExists(AugmentationNames.TheRedPill) && Augmentations[AugmentationNames.TheRedPill].owned) {
const WorldDaemon = GetServer(SpecialServerNames.WorldDaemon); const WorldDaemon = GetServer(SpecialServers.WorldDaemon);
const DaedalusServer = GetServer(SpecialServerNames.DaedalusServer); const DaedalusServer = GetServer(SpecialServers.DaedalusServer);
if (WorldDaemon && DaedalusServer) { if (WorldDaemon && DaedalusServer) {
WorldDaemon.serversOnNetwork.push(DaedalusServer.ip); WorldDaemon.serversOnNetwork.push(DaedalusServer.hostname);
DaedalusServer.serversOnNetwork.push(WorldDaemon.ip); DaedalusServer.serversOnNetwork.push(WorldDaemon.hostname);
} }
} }
@ -156,9 +153,6 @@ function prestigeSourceFile(flume: boolean): void {
// Delete all servers except home computer // Delete all servers except home computer
prestigeAllServers(); // Must be done before initForeignServers() prestigeAllServers(); // Must be done before initForeignServers()
// Delete Special Server IPs
prestigeSpecialServerIps();
// Reset home computer (only the programs) and add to AllServers // Reset home computer (only the programs) and add to AllServers
AddToAllServers(homeComp); AddToAllServers(homeComp);
prestigeHomeComputer(homeComp); prestigeHomeComputer(homeComp);

@ -7,7 +7,6 @@ import { loadMessages, initMessages, Messages } from "./Message/MessageHelpers";
import { Player, loadPlayer } from "./Player"; import { Player, loadPlayer } from "./Player";
import { saveAllServers, loadAllServers } from "./Server/AllServers"; import { saveAllServers, loadAllServers } from "./Server/AllServers";
import { Settings } from "./Settings/Settings"; import { Settings } from "./Settings/Settings";
import { loadSpecialServerIps, SpecialServerIps } from "./Server/SpecialServerIps";
import { SourceFileFlags } from "./SourceFile/SourceFileFlags"; import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
import { loadStockMarket, StockMarket } from "./StockMarket/StockMarket"; import { loadStockMarket, StockMarket } from "./StockMarket/StockMarket";
@ -28,7 +27,6 @@ class BitburnerSaveObject {
AllServersSave = ""; AllServersSave = "";
CompaniesSave = ""; CompaniesSave = "";
FactionsSave = ""; FactionsSave = "";
SpecialServerIpsSave = "";
AliasesSave = ""; AliasesSave = "";
GlobalAliasesSave = ""; GlobalAliasesSave = "";
MessagesSave = ""; MessagesSave = "";
@ -44,7 +42,6 @@ class BitburnerSaveObject {
this.AllServersSave = saveAllServers(); this.AllServersSave = saveAllServers();
this.CompaniesSave = JSON.stringify(Companies); this.CompaniesSave = JSON.stringify(Companies);
this.FactionsSave = JSON.stringify(Factions); this.FactionsSave = JSON.stringify(Factions);
this.SpecialServerIpsSave = JSON.stringify(SpecialServerIps);
this.AliasesSave = JSON.stringify(Aliases); this.AliasesSave = JSON.stringify(Aliases);
this.GlobalAliasesSave = JSON.stringify(GlobalAliases); this.GlobalAliasesSave = JSON.stringify(GlobalAliases);
this.MessagesSave = JSON.stringify(Messages); this.MessagesSave = JSON.stringify(Messages);
@ -156,7 +153,6 @@ function loadGame(saveString: string): boolean {
loadAllServers(saveObj.AllServersSave); loadAllServers(saveObj.AllServersSave);
loadCompanies(saveObj.CompaniesSave); loadCompanies(saveObj.CompaniesSave);
loadFactions(saveObj.FactionsSave); loadFactions(saveObj.FactionsSave);
loadSpecialServerIps(saveObj.SpecialServerIpsSave);
if (saveObj.hasOwnProperty("AliasesSave")) { if (saveObj.hasOwnProperty("AliasesSave")) {
try { try {

@ -14,7 +14,7 @@ export class RunningScript {
// Script arguments // Script arguments
args: any[] = []; args: any[] = [];
// Map of [key: server ip] -> Hacking data. Used for offline progress calculations. // Map of [key: hostname] -> Hacking data. Used for offline progress calculations.
// Hacking data format: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] // Hacking data format: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
dataMap: IMap<number[]> = {}; dataMap: IMap<number[]> = {};
@ -52,7 +52,7 @@ export class RunningScript {
// How much RAM this script uses for ONE thread // How much RAM this script uses for ONE thread
ramUsage = 0; ramUsage = 0;
// IP of the server on which this script is running // hostname of the server on which this script is running
server = ""; server = "";
// Number of threads that this script is running with // Number of threads that this script is running with
@ -93,28 +93,28 @@ export class RunningScript {
} }
// Update the moneyStolen and numTimesHack maps when hacking // Update the moneyStolen and numTimesHack maps when hacking
recordHack(serverIp: string, moneyGained: number, n = 1): void { recordHack(hostname: string, moneyGained: number, n = 1): void {
if (this.dataMap[serverIp] == null || this.dataMap[serverIp].constructor !== Array) { if (this.dataMap[hostname] == null || this.dataMap[hostname].constructor !== Array) {
this.dataMap[serverIp] = [0, 0, 0, 0]; this.dataMap[hostname] = [0, 0, 0, 0];
} }
this.dataMap[serverIp][0] += moneyGained; this.dataMap[hostname][0] += moneyGained;
this.dataMap[serverIp][1] += n; this.dataMap[hostname][1] += n;
} }
// Update the grow map when calling grow() // Update the grow map when calling grow()
recordGrow(serverIp: string, n = 1): void { recordGrow(hostname: string, n = 1): void {
if (this.dataMap[serverIp] == null || this.dataMap[serverIp].constructor !== Array) { if (this.dataMap[hostname] == null || this.dataMap[hostname].constructor !== Array) {
this.dataMap[serverIp] = [0, 0, 0, 0]; this.dataMap[hostname] = [0, 0, 0, 0];
} }
this.dataMap[serverIp][2] += n; this.dataMap[hostname][2] += n;
} }
// Update the weaken map when calling weaken() { // Update the weaken map when calling weaken() {
recordWeaken(serverIp: string, n = 1): void { recordWeaken(hostname: string, n = 1): void {
if (this.dataMap[serverIp] == null || this.dataMap[serverIp].constructor !== Array) { if (this.dataMap[hostname] == null || this.dataMap[hostname].constructor !== Array) {
this.dataMap[serverIp] = [0, 0, 0, 0]; this.dataMap[hostname] = [0, 0, 0, 0];
} }
this.dataMap[serverIp][3] += n; this.dataMap[hostname][3] += n;
} }
// Serialize the current object to a JSON save state // Serialize the current object to a JSON save state

@ -37,14 +37,14 @@ export class Script {
// Amount of RAM this Script requres to run // Amount of RAM this Script requres to run
ramUsage = 0; ramUsage = 0;
// IP of server that this script is on. // hostname of server that this script is on.
server = ""; server = "";
constructor(fn = "", code = "", server = "", otherScripts: Script[] = []) { constructor(fn = "", code = "", server = "", otherScripts: Script[] = []) {
this.filename = fn; this.filename = fn;
this.code = code; this.code = code;
this.ramUsage = 0; this.ramUsage = 0;
this.server = server; // IP of server this script is on this.server = server; // hostname of server this script is on
this.module = ""; this.module = "";
this.moduleSequenceNumber = ++globalModuleSequenceNumber; this.moduleSequenceNumber = ++globalModuleSequenceNumber;
if (this.code !== "") { if (this.code !== "") {
@ -90,12 +90,12 @@ export class Script {
* @param {string} code - The new contents of the script * @param {string} code - The new contents of the script
* @param {Script[]} otherScripts - Other scripts on the server. Used to process imports * @param {Script[]} otherScripts - Other scripts on the server. Used to process imports
*/ */
saveScript(filename: string, code: string, serverIp: string, otherScripts: Script[]): void { saveScript(filename: string, code: string, hostname: string, otherScripts: Script[]): void {
// Update code and filename // Update code and filename
this.code = code.replace(/^\s+|\s+$/g, ""); this.code = code.replace(/^\s+|\s+$/g, "");
this.filename = filename; this.filename = filename;
this.server = serverIp; this.server = hostname;
this.updateRamUsage(otherScripts); this.updateRamUsage(otherScripts);
this.markUpdated(); this.markUpdated();
} }

@ -27,17 +27,17 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
//Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] //Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
// Grow // Grow
for (const ip in runningScript.dataMap) { for (const hostname in runningScript.dataMap) {
if (runningScript.dataMap.hasOwnProperty(ip)) { if (runningScript.dataMap.hasOwnProperty(hostname)) {
if (runningScript.dataMap[ip][2] == 0 || runningScript.dataMap[ip][2] == null) { if (runningScript.dataMap[hostname][2] == 0 || runningScript.dataMap[hostname][2] == null) {
continue; continue;
} }
const serv = GetServer(ip); const serv = GetServer(hostname);
if (serv == null) { if (serv == null) {
continue; continue;
} }
const timesGrown = Math.round( const timesGrown = Math.round(
((0.5 * runningScript.dataMap[ip][2]) / runningScript.onlineRunningTime) * timePassed, ((0.5 * runningScript.dataMap[hostname][2]) / runningScript.onlineRunningTime) * timePassed,
); );
runningScript.log(`Called on ${serv.hostname} ${timesGrown} times while offline`); runningScript.log(`Called on ${serv.hostname} ${timesGrown} times while offline`);
const host = GetServer(runningScript.server); const host = GetServer(runningScript.server);
@ -60,12 +60,12 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
runningScript.offlineExpGained += expGain; runningScript.offlineExpGained += expGain;
// Weaken // Weaken
for (const ip in runningScript.dataMap) { for (const hostname in runningScript.dataMap) {
if (runningScript.dataMap.hasOwnProperty(ip)) { if (runningScript.dataMap.hasOwnProperty(hostname)) {
if (runningScript.dataMap[ip][3] == 0 || runningScript.dataMap[ip][3] == null) { if (runningScript.dataMap[hostname][3] == 0 || runningScript.dataMap[hostname][3] == null) {
continue; continue;
} }
const serv = GetServer(ip); const serv = GetServer(hostname);
if (serv == null) { if (serv == null) {
continue; continue;
} }
@ -74,7 +74,7 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
const host = GetServer(runningScript.server); const host = GetServer(runningScript.server);
if (host === null) throw new Error("getServer of null key?"); if (host === null) throw new Error("getServer of null key?");
const timesWeakened = Math.round( const timesWeakened = Math.round(
((0.5 * runningScript.dataMap[ip][3]) / runningScript.onlineRunningTime) * timePassed, ((0.5 * runningScript.dataMap[hostname][3]) / runningScript.onlineRunningTime) * timePassed,
); );
runningScript.log(`Called weaken() on ${serv.hostname} ${timesWeakened} times while offline`); runningScript.log(`Called weaken() on ${serv.hostname} ${timesWeakened} times while offline`);
const coreBonus = 1 + (host.cpuCores - 1) / 16; const coreBonus = 1 + (host.cpuCores - 1) / 16;

@ -1,6 +1,5 @@
import { Server } from "./Server"; import { Server } from "./Server";
import { BaseServer } from "./BaseServer"; import { BaseServer } from "./BaseServer";
import { SpecialServerIps } from "./SpecialServerIps";
import { serverMetadata } from "./data/servers"; import { serverMetadata } from "./data/servers";
import { HacknetServer } from "../Hacknet/HacknetServer"; import { HacknetServer } from "../Hacknet/HacknetServer";
@ -90,13 +89,11 @@ export function createUniqueRandomIp(): string {
// Saftely add a Server to the AllServers map // Saftely add a Server to the AllServers map
export function AddToAllServers(server: Server | HacknetServer): void { export function AddToAllServers(server: Server | HacknetServer): void {
if (GetServer(server.hostname)) { 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(`Hostname of the server thats being added: ${server.hostname}`);
console.warn(`The server that already has this IP is: ${AllServers[server.hostname].hostname}`); console.warn(`The server that already has this IP is: ${AllServers[server.hostname].hostname}`);
throw new Error("Error: Trying to add a server with an existing IP"); throw new Error("Error: Trying to add a server with an existing IP");
} }
console.log(`adding ${server.hostname}`);
AllServers[server.hostname] = server; AllServers[server.hostname] = server;
} }
@ -164,10 +161,6 @@ export function initForeignServers(homeComputer: Server): void {
server.messages.push(filename); server.messages.push(filename);
} }
if (metadata.specialName !== undefined) {
SpecialServerIps.addIp(metadata.specialName, server.ip);
}
AddToAllServers(server); AddToAllServers(server);
if (metadata.networkLayer !== undefined) { if (metadata.networkLayer !== undefined) {
networkLayers[toNumber(metadata.networkLayer) - 1].push(server); networkLayers[toNumber(metadata.networkLayer) - 1].push(server);
@ -176,8 +169,8 @@ export function initForeignServers(homeComputer: Server): void {
/* Create a randomized network for all the foreign servers */ /* Create a randomized network for all the foreign servers */
const linkComputers = (server1: Server, server2: Server): void => { const linkComputers = (server1: Server, server2: Server): void => {
server1.serversOnNetwork.push(server2.ip); server1.serversOnNetwork.push(server2.hostname);
server2.serversOnNetwork.push(server1.ip); server2.serversOnNetwork.push(server1.hostname);
}; };
const getRandomArrayItem = (arr: any[]): any => arr[Math.floor(Math.random() * arr.length)]; const getRandomArrayItem = (arr: any[]): any => arr[Math.floor(Math.random() * arr.length)];

@ -267,7 +267,7 @@ export class BaseServer {
} }
// Otherwise, create a new script // Otherwise, create a new script
const newScript = new Script(fn, code, this.ip, this.scripts); const newScript = new Script(fn, code, this.hostname, this.scripts);
this.scripts.push(newScript); this.scripts.push(newScript);
ret.success = true; ret.success = true;
return ret; return ret;

@ -80,12 +80,12 @@ export function purchaseServer(hostname: string, ram: number, cost: number, p: I
AddToAllServers(newServ); AddToAllServers(newServ);
// Add to Player's purchasedServers array // Add to Player's purchasedServers array
p.purchasedServers.push(newServ.ip); p.purchasedServers.push(newServ.hostname);
// Connect new server to home computer // Connect new server to home computer
const homeComputer = p.getHomeComputer(); const homeComputer = p.getHomeComputer();
homeComputer.serversOnNetwork.push(newServ.ip); homeComputer.serversOnNetwork.push(newServ.hostname);
newServ.serversOnNetwork.push(homeComputer.ip); newServ.serversOnNetwork.push(homeComputer.hostname);
p.loseMoney(cost); p.loseMoney(cost);

@ -1,58 +0,0 @@
import { IMap } from "../types";
import { Reviver, Generic_toJSON, Generic_fromJSON } from "../utils/JSONReviver";
/* Holds IP of Special Servers */
export const SpecialServerNames: IMap<string> = {
FulcrumSecretTechnologies: "Fulcrum Secret Technologies Server",
CyberSecServer: "CyberSec Server",
NiteSecServer: "NiteSec Server",
TheBlackHandServer: "The Black Hand Server",
BitRunnersServer: "BitRunners Server",
TheDarkArmyServer: "The Dark Army Server",
DaedalusServer: "Daedalus Server",
WorldDaemon: "w0r1d_d43m0n",
};
export class SpecialServerIpsMap {
// eslint-disable-next-line @typescript-eslint/ban-types
[key: string]: Function | string;
addIp(name: string, ip: string): void {
this[name] = ip;
}
getIp(name: string): string {
return this[name] as string;
}
// Serialize the current object to a JSON save state
toJSON(): any {
return Generic_toJSON("SpecialServerIpsMap", this);
}
// Initializes a SpecialServerIpsMap Object from a JSON save state
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
static fromJSON(value: any): SpecialServerIpsMap {
return Generic_fromJSON(SpecialServerIpsMap, value.data);
}
}
Reviver.constructors.SpecialServerIpsMap = SpecialServerIpsMap;
export let SpecialServerIps: SpecialServerIpsMap = new SpecialServerIpsMap();
export function prestigeSpecialServerIps(): void {
for (const member in SpecialServerIps) {
delete SpecialServerIps[member];
}
SpecialServerIps = new SpecialServerIpsMap();
}
export function loadSpecialServerIps(saveString: string): void {
SpecialServerIps = JSON.parse(saveString, Reviver);
}
export function initSpecialServerIps(): void {
SpecialServerIps = new SpecialServerIpsMap();
}

@ -0,0 +1,26 @@
/* Holds IP of Special Servers */
export const SpecialServers: {
[key: string]: string | undefined;
Home: string;
FulcrumSecretTechnologies: string;
CyberSecServer: string;
NiteSecServer: string;
TheBlackHandServer: string;
BitRunnersServer: string;
TheDarkArmyServer: string;
DaedalusServer: string;
WorldDaemon: string;
DarkWeb: string;
} = {
Home: "home",
FulcrumSecretTechnologies: "fulcrumassets",
CyberSecServer: "CSEC",
NiteSecServer: "avmnite-02h",
TheBlackHandServer: "I.I.I.I",
BitRunnersServer: "run4theh111z",
TheDarkArmyServer: ".",
DaedalusServer: "The-Cave",
WorldDaemon: "w0r1d_d43m0n",
DarkWeb: "darkweb",
};

@ -4,6 +4,7 @@
import { IMinMaxRange } from "../../types"; import { IMinMaxRange } from "../../types";
import { LocationName } from "../../Locations/data/LocationNames"; import { LocationName } from "../../Locations/data/LocationNames";
import { LiteratureNames } from "../../Literature/data/LiteratureNames"; import { LiteratureNames } from "../../Literature/data/LiteratureNames";
import { SpecialServers } from "./SpecialServers";
/** /**
* The metadata describing the base state of servers on the network. * The metadata describing the base state of servers on the network.
@ -319,7 +320,7 @@ export const serverMetadata: IServerMetadata[] = [
min: 1100, min: 1100,
}, },
serverGrowth: 1, serverGrowth: 1,
specialName: "Fulcrum Secret Technologies Server", specialName: SpecialServers.FulcrumSecretTechnologies,
}, },
{ {
hackDifficulty: { hackDifficulty: {
@ -1470,7 +1471,7 @@ export const serverMetadata: IServerMetadata[] = [
min: 505, min: 505,
}, },
serverGrowth: 0, serverGrowth: 0,
specialName: "BitRunners Server", specialName: SpecialServers.BitRunnersServer,
}, },
{ {
hackDifficulty: 0, hackDifficulty: 0,
@ -1489,7 +1490,7 @@ export const serverMetadata: IServerMetadata[] = [
min: 340, min: 340,
}, },
serverGrowth: 0, serverGrowth: 0,
specialName: "The Black Hand Server", specialName: SpecialServers.TheBlackHandServer,
}, },
{ {
hackDifficulty: 0, hackDifficulty: 0,
@ -1508,7 +1509,7 @@ export const serverMetadata: IServerMetadata[] = [
min: 202, min: 202,
}, },
serverGrowth: 0, serverGrowth: 0,
specialName: "NiteSec Server", specialName: SpecialServers.NiteSecServer,
}, },
{ {
hackDifficulty: 0, hackDifficulty: 0,
@ -1523,7 +1524,7 @@ export const serverMetadata: IServerMetadata[] = [
min: 505, min: 505,
}, },
serverGrowth: 0, serverGrowth: 0,
specialName: "The Dark Army Server", specialName: SpecialServers.TheDarkArmyServer,
}, },
{ {
hackDifficulty: 0, hackDifficulty: 0,
@ -1539,7 +1540,7 @@ export const serverMetadata: IServerMetadata[] = [
min: 51, min: 51,
}, },
serverGrowth: 0, serverGrowth: 0,
specialName: "CyberSec Server", specialName: SpecialServers.CyberSecServer,
}, },
{ {
hackDifficulty: 0, hackDifficulty: 0,
@ -1551,7 +1552,7 @@ export const serverMetadata: IServerMetadata[] = [
organizationName: "Helios", organizationName: "Helios",
requiredHackingSkill: 925, requiredHackingSkill: 925,
serverGrowth: 0, serverGrowth: 0,
specialName: "Daedalus Server", specialName: SpecialServers.DaedalusServer,
}, },
{ {
hackDifficulty: 0, hackDifficulty: 0,
@ -1561,6 +1562,6 @@ export const serverMetadata: IServerMetadata[] = [
organizationName: "w0r1d_d43m0n", organizationName: "w0r1d_d43m0n",
requiredHackingSkill: 3000, requiredHackingSkill: 3000,
serverGrowth: 0, serverGrowth: 0,
specialName: "w0r1d_d43m0n", specialName: SpecialServers.WorldDaemon,
}, },
]; ];

@ -22,7 +22,6 @@ export const TerminalHelpText: string[] = [
"help [command] Display this help text, or the help text for a command", "help [command] Display this help text, or the help text for a command",
"home Connect to home computer", "home Connect to home computer",
"hostname Displays the hostname of the machine", "hostname Displays the hostname of the machine",
"ifconfig Displays the IP address of the machine",
"kill [script/pid] [args...] Stops the specified script on the current server ", "kill [script/pid] [args...] Stops the specified script on the current server ",
"killall Stops all running scripts on the current machine", "killall Stops all running scripts on the current machine",
"ls [dir] [| grep pattern] Displays all files on the machine", "ls [dir] [| grep pattern] Displays all files on the machine",
@ -219,7 +218,6 @@ export const HelpTexts: IMap<string[]> = {
"home" + "Connect to your home computer. This will work no matter what server you are currently connected to.", "home" + "Connect to your home computer. This will work no matter what server you are currently connected to.",
], ],
hostname: ["hostname", " ", "Prints the hostname of the current server"], hostname: ["hostname", " ", "Prints the hostname of the current server"],
ifconfig: ["ipconfig", " ", "Prints the IP address of the current server"],
kill: [ kill: [
"kill [script name] [args...]", "kill [script name] [args...]",
" ", " ",

@ -19,7 +19,7 @@ import { checkIfConnectedToDarkweb } from "../DarkWeb/DarkWeb";
import { iTutorialNextStep, iTutorialSteps, ITutorial } from "../InteractiveTutorial"; import { iTutorialNextStep, iTutorialSteps, ITutorial } from "../InteractiveTutorial";
import { getServerOnNetwork, processSingleServerGrowth } from "../Server/ServerHelpers"; import { getServerOnNetwork, processSingleServerGrowth } from "../Server/ServerHelpers";
import { ParseCommand, ParseCommands } from "./Parser"; import { ParseCommand, ParseCommands } from "./Parser";
import { SpecialServerIps, SpecialServerNames } from "../Server/SpecialServerIps"; import { SpecialServers } from "../Server/data/SpecialServers";
import { Settings } from "../Settings/Settings"; import { Settings } from "../Settings/Settings";
import { createProgressBarText } from "../utils/helpers/createProgressBarText"; import { createProgressBarText } from "../utils/helpers/createProgressBarText";
import { import {
@ -49,7 +49,6 @@ import { hack } from "./commands/hack";
import { help } from "./commands/help"; import { help } from "./commands/help";
import { home } from "./commands/home"; import { home } from "./commands/home";
import { hostname } from "./commands/hostname"; import { hostname } from "./commands/hostname";
import { ifconfig } from "./commands/ifconfig";
import { kill } from "./commands/kill"; import { kill } from "./commands/kill";
import { killall } from "./commands/killall"; import { killall } from "./commands/killall";
import { ls } from "./commands/ls"; import { ls } from "./commands/ls";
@ -176,10 +175,7 @@ export class Terminal implements ITerminal {
const expGainedOnFailure = expGainedOnSuccess / 4; const expGainedOnFailure = expGainedOnSuccess / 4;
if (rand < hackChance) { if (rand < hackChance) {
// Success! // Success!
if ( if (SpecialServers.WorldDaemon === server.hostname) {
SpecialServerIps[SpecialServerNames.WorldDaemon] &&
SpecialServerIps[SpecialServerNames.WorldDaemon] == server.ip
) {
if (player.bitNodeN == null) { if (player.bitNodeN == null) {
player.bitNodeN = 1; player.bitNodeN = 1;
} }
@ -259,10 +255,7 @@ export class Terminal implements ITerminal {
return; return;
} }
if (!(server instanceof Server)) throw new Error("server should be normal server"); if (!(server instanceof Server)) throw new Error("server should be normal server");
if ( if (SpecialServers.WorldDaemon === server.hostname) {
SpecialServerIps[SpecialServerNames.WorldDaemon] &&
SpecialServerIps[SpecialServerNames.WorldDaemon] == server.ip
) {
if (player.bitNodeN == null) { if (player.bitNodeN == null) {
player.bitNodeN = 1; player.bitNodeN = 1;
} }
@ -519,7 +512,7 @@ export class Terminal implements ITerminal {
return; return;
} }
player.getCurrentServer().isConnectedTo = false; player.getCurrentServer().isConnectedTo = false;
player.currentServer = serv.ip; player.currentServer = serv.hostname;
player.getCurrentServer().isConnectedTo = true; player.getCurrentServer().isConnectedTo = true;
this.print("Connected to " + serv.hostname); this.print("Connected to " + serv.hostname);
this.setcwd("/"); this.setcwd("/");
@ -625,7 +618,10 @@ export class Terminal implements ITerminal {
break; break;
case iTutorialSteps.TerminalConnect: case iTutorialSteps.TerminalConnect:
if (commandArray.length == 2) { if (commandArray.length == 2) {
if (commandArray[0] == "connect" && (commandArray[1] == "n00dles" || commandArray[1] == n00dlesServ.ip)) { if (
commandArray[0] == "connect" &&
(commandArray[1] == "n00dles" || commandArray[1] == n00dlesServ.hostname)
) {
iTutorialNextStep(); iTutorialNextStep();
} else { } else {
this.print("Wrong command! Try again!"); this.print("Wrong command! Try again!");
@ -741,7 +737,6 @@ export class Terminal implements ITerminal {
help: help, help: help,
home: home, home: home,
hostname: hostname, hostname: hostname,
ifconfig: ifconfig,
kill: kill, kill: kill,
killall: killall, killall: killall,
ls: ls, ls: ls,

@ -3,7 +3,8 @@ import { IRouter } from "../../ui/Router";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { BaseServer } from "../../Server/BaseServer"; import { BaseServer } from "../../Server/BaseServer";
import { listAllDarkwebItems, buyDarkwebItem } from "../../DarkWeb/DarkWeb"; import { listAllDarkwebItems, buyDarkwebItem } from "../../DarkWeb/DarkWeb";
import { SpecialServerIps } from "../../Server/SpecialServerIps"; import { SpecialServers } from "../../Server/data/SpecialServers";
import { GetServer } from "../../Server/AllServers";
export function buy( export function buy(
terminal: ITerminal, terminal: ITerminal,
@ -12,7 +13,7 @@ export function buy(
server: BaseServer, server: BaseServer,
args: (string | number)[], args: (string | number)[],
): void { ): void {
if (!SpecialServerIps.hasOwnProperty("Darkweb Server")) { if (!GetServer(SpecialServers.DarkWeb)) {
terminal.error( terminal.error(
"You need to be able to connect to the Dark Web to use the buy command. (Maybe there's a TOR router you can buy somewhere)", "You need to be able to connect to the Dark Web to use the buy command. (Maybe there's a TOR router you can buy somewhere)",
); );

@ -17,13 +17,13 @@ export function connect(
return; return;
} }
const ip = args[0] + ""; const hostname = args[0] + "";
for (let i = 0; i < server.serversOnNetwork.length; i++) { for (let i = 0; i < server.serversOnNetwork.length; i++) {
const other = getServerOnNetwork(server, i); const other = getServerOnNetwork(server, i);
if (other === null) throw new Error(`Server on network should not be null`); if (other === null) throw new Error(`Server on network should not be null`);
if (other.ip == ip || other.hostname == ip) { if (other.hostname == hostname) {
terminal.connectToServer(player, ip); terminal.connectToServer(player, hostname);
return; return;
} }
} }

@ -15,7 +15,7 @@ export function home(
return; return;
} }
player.getCurrentServer().isConnectedTo = false; player.getCurrentServer().isConnectedTo = false;
player.currentServer = player.getHomeComputer().ip; player.currentServer = player.getHomeComputer().hostname;
player.getCurrentServer().isConnectedTo = true; player.getCurrentServer().isConnectedTo = true;
terminal.print("Connected to home"); terminal.print("Connected to home");
terminal.setcwd("/"); terminal.setcwd("/");

@ -1,18 +0,0 @@
import { ITerminal } from "../ITerminal";
import { IRouter } from "../../ui/Router";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { BaseServer } from "../../Server/BaseServer";
export function ifconfig(
terminal: ITerminal,
router: IRouter,
player: IPlayer,
server: BaseServer,
args: (string | number)[],
): void {
if (args.length !== 0) {
terminal.error("Incorrect usage of ifconfig command. Usage: ifconfig");
return;
}
terminal.print(player.getCurrentServer().ip);
}

@ -36,7 +36,7 @@ export function kill(
terminal.error("No such script is running. Nothing to kill"); terminal.error("No such script is running. Nothing to kill");
return; return;
} }
killWorkerScript(runningScript, server.ip, false); killWorkerScript(runningScript, server.hostname, false);
terminal.print(`Killing ${scriptName}`); terminal.print(`Killing ${scriptName}`);
} catch (e) { } catch (e) {
terminal.error(e + ""); terminal.error(e + "");

@ -7,7 +7,7 @@ import { WorkerScriptStartStopEventEmitter } from "../../Netscript/WorkerScriptS
export function killall(terminal: ITerminal, router: IRouter, player: IPlayer, server: BaseServer): void { export function killall(terminal: ITerminal, router: IRouter, player: IPlayer, server: BaseServer): void {
for (let i = server.runningScripts.length - 1; i >= 0; --i) { for (let i = server.runningScripts.length - 1; i >= 0; --i) {
killWorkerScript(server.runningScripts[i], server.ip, false); killWorkerScript(server.runningScripts[i], server.hostname, false);
} }
WorkerScriptStartStopEventEmitter.emit(); WorkerScriptStartStopEventEmitter.emit();
terminal.print("Killing all running scripts"); terminal.print("Killing all running scripts");

@ -224,7 +224,6 @@ export function determineAllPossibilitiesForTabCompletion(
if (isCommand("scp") && index === 1) { if (isCommand("scp") && index === 1) {
for (const server of GetAllServers()) { for (const server of GetAllServers()) {
allPos.push(server.ip);
allPos.push(server.hostname); allPos.push(server.hostname);
} }
@ -247,7 +246,6 @@ export function determineAllPossibilitiesForTabCompletion(
if (serv == null) { if (serv == null) {
continue; continue;
} }
allPos.push(serv.ip);
allPos.push(serv.hostname); allPos.push(serv.hostname);
} }

@ -31,7 +31,6 @@ import { initForeignServers } from "./Server/AllServers";
import { Settings } from "./Settings/Settings"; import { Settings } from "./Settings/Settings";
import { ThemeEvents } from "./ui/React/Theme"; import { ThemeEvents } from "./ui/React/Theme";
import { updateSourceFileFlags } from "./SourceFile/SourceFileFlags"; import { updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
import { initSpecialServerIps } from "./Server/SpecialServerIps";
import { initSymbolToStockMap, processStockPrices } from "./StockMarket/StockMarket"; import { initSymbolToStockMap, processStockPrices } from "./StockMarket/StockMarket";
import { Terminal } from "./Terminal"; import { Terminal } from "./Terminal";
import { Sleeve } from "./PersonObjects/Sleeve/Sleeve"; import { Sleeve } from "./PersonObjects/Sleeve/Sleeve";
@ -409,7 +408,6 @@ const Engine: {
} else { } else {
// No save found, start new game // No save found, start new game
initBitNodeMultipliers(Player); initBitNodeMultipliers(Player);
initSpecialServerIps();
Engine.start(); // Run main game loop and Scripts loop Engine.start(); // Run main game loop and Scripts loop
Player.init(); Player.init();
initForeignServers(Player.getHomeComputer()); initForeignServers(Player.getHomeComputer());

@ -54,9 +54,9 @@ export function ServerAccordions(props: IProps): React.ReactElement {
const serverToScriptMap: IServerToScriptsMap = {}; const serverToScriptMap: IServerToScriptsMap = {};
for (const ws of props.workerScripts.values()) { for (const ws of props.workerScripts.values()) {
const server = GetServer(ws.serverIp); const server = GetServer(ws.hostname);
if (server == null) { if (server == null) {
console.warn(`WorkerScript has invalid IP address: ${ws.serverIp}`); console.warn(`WorkerScript has invalid IP address: ${ws.hostname}`);
continue; continue;
} }