From ac8ea6b5efa7e18d23d3c6d47ac2fd5457fc035b Mon Sep 17 00:00:00 2001 From: Tyasuh <122596795+Tyasuh@users.noreply.github.com> Date: Mon, 16 Jan 2023 15:59:33 -0500 Subject: [PATCH] split hacknet node from server in name, with SF9 (#327) --- src/Hacknet/HacknetHelpers.tsx | 2 +- src/PersonObjects/Player/PlayerObjectServerMethods.ts | 3 ++- src/Server/Server.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Hacknet/HacknetHelpers.tsx b/src/Hacknet/HacknetHelpers.tsx index fe9a58cf7..e1ad643ec 100644 --- a/src/Hacknet/HacknetHelpers.tsx +++ b/src/Hacknet/HacknetHelpers.tsx @@ -65,7 +65,7 @@ export function purchaseHacknet(): number { } // Auto generate a name for the Node - const name = "hacknet-node-" + numOwned; + const name = hasHacknetServers() ? `hacknet-server-${numOwned}` : `hacknet-node-${numOwned}`; const node = new HacknetNode(name, Player.mults.hacknet_node_money); Player.loseMoney(cost, "hacknet_expenses"); diff --git a/src/PersonObjects/Player/PlayerObjectServerMethods.ts b/src/PersonObjects/Player/PlayerObjectServerMethods.ts index ea991401c..547b50efd 100644 --- a/src/PersonObjects/Player/PlayerObjectServerMethods.ts +++ b/src/PersonObjects/Player/PlayerObjectServerMethods.ts @@ -9,6 +9,7 @@ import { BaseServer } from "../../Server/BaseServer"; import { HacknetServer } from "../../Hacknet/HacknetServer"; import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers"; import { SpecialServers } from "../../Server/data/SpecialServers"; +import { hasHacknetServers } from "../../Hacknet/HacknetHelpers"; export function hasTorRouter(this: PlayerObject): boolean { return this.getHomeComputer().serversOnNetwork.includes(SpecialServers.DarkWeb); @@ -44,7 +45,7 @@ export function getUpgradeHomeCoresCost(this: PlayerObject): number { export function createHacknetServer(this: PlayerObject): HacknetServer { const numOwned = this.hacknetNodes.length; - const name = `hacknet-node-${numOwned}`; + const name = hasHacknetServers() ? `hacknet-server-${numOwned}` : `hacknet-node-${numOwned}`; const server = new HacknetServer({ adminRights: true, hostname: name, diff --git a/src/Server/Server.ts b/src/Server/Server.ts index c1627700a..7f86a2f8d 100644 --- a/src/Server/Server.ts +++ b/src/Server/Server.ts @@ -59,7 +59,7 @@ export class Server extends BaseServer { super(params); // "hacknet-node-X" hostnames are reserved for Hacknet Servers - if (this.hostname.startsWith("hacknet-node-")) { + if (this.hostname.startsWith("hacknet-node-" || "hacknet-server-")) { this.hostname = createRandomString(10); }