mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-06 23:57:49 +02:00
CODEBASE: Remove redundant check in getServer utility function and serverExists API (#2357)
This commit is contained in:
@@ -472,15 +472,16 @@ function scriptIdentifier(
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Server for a specific hostname/ip, throwing an error
|
||||
* if the server doesn't exist.
|
||||
* Gets the server with a specific hostname/ip. Throw an error if the server does not exist or it is an isolated
|
||||
* server (e.g., pre-TOR darkweb, pre-TRP WD).
|
||||
*
|
||||
* @param {NetscriptContext} ctx - Context from which getServer is being called. For logging purposes.
|
||||
* @param {string} hostname - Hostname of the server
|
||||
* @returns {BaseServer} The specified server as a BaseServer
|
||||
*/
|
||||
function getServer(ctx: NetscriptContext, hostname: string): BaseServer {
|
||||
const server = GetServer(hostname);
|
||||
if (server == null || (server.serversOnNetwork.length == 0 && server.hostname != "home")) {
|
||||
if (server == null || server.serversOnNetwork.length === 0) {
|
||||
const str = hostname === "" ? "'' (empty string)" : "'" + hostname + "'";
|
||||
throw errorMessage(ctx, `Invalid hostname: ${str}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user