fix manualHack

This commit is contained in:
Olivier Gagnon 2022-05-25 20:19:42 -04:00
parent 0dff3e22bc
commit 6a2e5b06ad
2 changed files with 31 additions and 32 deletions

@ -95,7 +95,7 @@ function wrapFunction(
boolean: helpers.boolean,
getServer: (hostname: string) => helpers.getServer(hostname, ctx),
checkSingularityAccess: () => helpers.checkSingularityAccess(functionName),
hack: helpers.hack,
hack: (hostname: any, manual: any, extra?: any) => helpers.hack(ctx, hostname, manual, extra),
getValidPort: (port: any) => helpers.getValidPort(functionPath, port),
},
};

@ -598,38 +598,37 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
const server = player.getCurrentServer();
return _ctx.helper.hack(server.hostname, true);
},
installBackdoor: (_ctx: NetscriptContext) =>
function (): Promise<void> {
_ctx.helper.checkSingularityAccess();
const baseserver = player.getCurrentServer();
if (!(baseserver instanceof Server)) {
_ctx.log(() => "cannot backdoor this kind of server");
return Promise.resolve();
installBackdoor: (_ctx: NetscriptContext) => async (): Promise<void> => {
_ctx.helper.checkSingularityAccess();
const baseserver = player.getCurrentServer();
if (!(baseserver instanceof Server)) {
_ctx.log(() => "cannot backdoor this kind of server");
return Promise.resolve();
}
const server = baseserver;
const installTime = (calculateHackingTime(server, player) / 4) * 1000;
// No root access or skill level too low
const canHack = netscriptCanHack(server, player);
if (!canHack.res) {
throw _ctx.helper.makeRuntimeErrorMsg(canHack.msg || "");
}
_ctx.log(
() => `Installing backdoor on '${server.hostname}' in ${convertTimeMsToTimeElapsedString(installTime, true)}`,
);
return netscriptDelay(installTime, workerScript).then(function () {
_ctx.log(() => `Successfully installed backdoor on '${server.hostname}'`);
server.backdoorInstalled = true;
if (SpecialServers.WorldDaemon === server.hostname) {
Router.toBitVerse(false, false);
}
const server = baseserver ;
const installTime = (calculateHackingTime(server, player) / 4) * 1000;
// No root access or skill level too low
const canHack = netscriptCanHack(server, player);
if (!canHack.res) {
throw _ctx.helper.makeRuntimeErrorMsg(canHack.msg || "");
}
_ctx.log(
() => `Installing backdoor on '${server.hostname}' in ${convertTimeMsToTimeElapsedString(installTime, true)}`,
);
return netscriptDelay(installTime, workerScript).then(function () {
_ctx.log(() => `Successfully installed backdoor on '${server.hostname}'`);
server.backdoorInstalled = true;
if (SpecialServers.WorldDaemon === server.hostname) {
Router.toBitVerse(false, false);
}
return Promise.resolve();
});
},
return Promise.resolve();
});
},
isFocused: (_ctx: NetscriptContext) =>
function (): boolean {
_ctx.helper.checkSingularityAccess();