fix a few bugs

This commit is contained in:
Olivier Gagnon 2021-11-10 07:52:26 -05:00
parent 7cc2a1b49a
commit 7cc4295c63
4 changed files with 15 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1010,7 +1010,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
throw makeRuntimeErrorMsg("scp", "Only works for .script, .lit, and .txt files");
}
let destServer, currServ;
let destServer: BaseServer | null;
let currServ: BaseServer | null;
if (hostname2 != null) {
// 3 Argument version: scriptname, source, destination
@ -1126,7 +1127,13 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
newScript.server = destServer.hostname;
destServer.scripts.push(newScript);
workerScript.log("scp", `File '${scriptname}' copied over to '${destServer.hostname}'.`);
return Promise.resolve(true);
return new Promise((resolve) => {
if (destServer === null) {
resolve(false);
return;
}
newScript.updateRamUsage(destServer.scripts).then(() => resolve(true));
});
},
ls: function (hostname: any, grep: any): any {
updateDynamicRam("ls", getRamCost("ls"));

@ -100,15 +100,15 @@ export function NetscriptFormulas(player: IPlayer, workerScript: WorkerScript, h
},
hackTime: function (server: any, player: any): any {
checkFormulasAccess("basic.hackTime");
return calculateHackingTime(server, player) / 1000;
return calculateHackingTime(server, player) * 1000;
},
growTime: function (server: any, player: any): any {
checkFormulasAccess("basic.growTime");
return calculateGrowTime(server, player) / 1000;
return calculateGrowTime(server, player) * 1000;
},
weakenTime: function (server: any, player: any): any {
checkFormulasAccess("basic.weakenTime");
return calculateWeakenTime(server, player) / 1000;
return calculateWeakenTime(server, player) * 1000;
},
},
hacknetNodes: {