From dfc2ca66698bec6d1084c8edf69d40fef8e3374b Mon Sep 17 00:00:00 2001 From: Undeemiss Date: Wed, 13 Apr 2022 11:03:17 -0500 Subject: [PATCH] Allowed ns.singularity.connect to connect to backdoored servers directly Added some small comments for readability and added a new case to ns.singularity.connect that allows connecting to backdoored servers directly regardless of if the current server is adjacent to them. --- src/NetscriptFunctions/Singularity.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index 28f7dcccd..4e34f427b 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -580,6 +580,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript throw _ctx.helper.makeRuntimeErrorMsg(`Invalid hostname: '${hostname}'`); } + //Home case if (hostname === "home") { player.getCurrentServer().isConnectedTo = false; player.currentServer = player.getHomeComputer().hostname; @@ -588,6 +589,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript return true; } + //Adjacent server case const server = player.getCurrentServer(); for (let i = 0; i < server.serversOnNetwork.length; i++) { const other = getServerOnNetwork(server, i); @@ -601,6 +603,17 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript } } + //Backdoor case + const other = GetServer(hostname); + if (other !== null && other instanceof Server && other.backdoorInstalled) { + player.getCurrentServer().isConnectedTo = false; + player.currentServer = target.hostname; + player.getCurrentServer().isConnectedTo = true; + Terminal.setcwd("/"); + return true; + } + + //Failure case return false; }, manualHack: (_ctx: NetscriptContext) =>