mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 02:32:55 +02:00
NETSCRIPT: Add functionality and support to fully allow Players to use IP addresses in place of hostnames (#1990)
This commit is contained in:
@@ -464,9 +464,11 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 5000);
|
||||
return true;
|
||||
},
|
||||
getCurrentServer: (ctx) => () => {
|
||||
getCurrentServer: (ctx) => (_returnOpts) => {
|
||||
helpers.checkSingularityAccess(ctx);
|
||||
return Player.getCurrentServer().hostname;
|
||||
const returnOpts = helpers.hostReturnOptions(_returnOpts);
|
||||
const server = Player.getCurrentServer();
|
||||
return helpers.returnServerID(server, returnOpts);
|
||||
},
|
||||
cat: (ctx) => (_filename) => {
|
||||
helpers.checkSingularityAccess(ctx);
|
||||
@@ -474,16 +476,16 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
const server = Player.getCurrentServer();
|
||||
cat([filename], server);
|
||||
},
|
||||
connect: (ctx) => (_hostname) => {
|
||||
connect: (ctx) => (_host) => {
|
||||
helpers.checkSingularityAccess(ctx);
|
||||
const hostname = helpers.string(ctx, "hostname", _hostname);
|
||||
if (!hostname) {
|
||||
throw helpers.errorMessage(ctx, `Invalid hostname: '${hostname}'`);
|
||||
const host = helpers.string(ctx, "host", _host);
|
||||
if (!host) {
|
||||
throw helpers.errorMessage(ctx, `Invalid server: '${host}'`);
|
||||
}
|
||||
|
||||
const target = GetServer(hostname);
|
||||
const target = GetServer(host);
|
||||
if (target == null) {
|
||||
throw helpers.errorMessage(ctx, `Invalid hostname: '${hostname}'`);
|
||||
throw helpers.errorMessage(ctx, `Invalid server: '${host}'`);
|
||||
}
|
||||
|
||||
// Adjacent servers
|
||||
@@ -498,8 +500,8 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (other.hostname === hostname) {
|
||||
Terminal.connectToServer(hostname, true);
|
||||
if (other.hostname === target.hostname) {
|
||||
Terminal.connectToServer(host, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -509,7 +511,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
* is true.
|
||||
*/
|
||||
if (target.backdoorInstalled || target.purchasedByPlayer) {
|
||||
Terminal.connectToServer(hostname, true);
|
||||
Terminal.connectToServer(host, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user