From c6ff982b1d53124cbc9f66d5638b24a821ccd158 Mon Sep 17 00:00:00 2001 From: Heikki Aitakangas Date: Sat, 8 Jan 2022 22:04:01 +0200 Subject: [PATCH] Remove stopFlag checks made redundant by the netscriptDelay change --- src/NetscriptFunctions.ts | 7 ------- src/NetscriptFunctions/Corporation.ts | 9 --------- src/NetscriptFunctions/Singularity.ts | 3 --- src/NetscriptFunctions/Stanek.ts | 3 --- 4 files changed, 22 deletions(-) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index cfafff2d4..3c67ef6fc 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -342,9 +342,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { ); return netscriptDelay(hackingTime * 1000, workerScript).then(function () { - if (workerScript.env.stopFlag) { - return Promise.reject(workerScript); - } const hackChance = calculateHackingChance(server, Player); const rand = Math.random(); let expGainedOnSuccess = calculateHackingExpGain(server, Player) * threads; @@ -614,9 +611,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { )} (t=${numeralWrapper.formatThreads(threads)}).`, ); return netscriptDelay(growTime * 1000, workerScript).then(function () { - if (workerScript.env.stopFlag) { - return Promise.reject(workerScript); - } const moneyBefore = server.moneyAvailable <= 0 ? 1 : server.moneyAvailable; processSingleServerGrowth(server, threads, Player, host.cpuCores); const moneyAfter = server.moneyAvailable; @@ -685,7 +679,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { )} (t=${numeralWrapper.formatThreads(threads)})`, ); return netscriptDelay(weakenTime * 1000, workerScript).then(function () { - if (workerScript.env.stopFlag) return Promise.reject(workerScript); const host = GetServer(workerScript.hostname); if (host === null) { workerScript.log("weaken", () => "Server is null, did it die?"); diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index 98037706c..67bb16e76 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -311,9 +311,6 @@ export function NetscriptCorporation( const job = helper.string("assignJob", "job", ajob); const employee = getEmployee(divisionName, cityName, employeeName); return netscriptDelay(1000, workerScript).then(function () { - if (workerScript.env.stopFlag) { - return Promise.reject(workerScript); - } return Promise.resolve(AssignJob(employee, job)); }); }, @@ -344,9 +341,6 @@ export function NetscriptCorporation( (60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)), workerScript, ).then(function () { - if (workerScript.env.stopFlag) { - return Promise.reject(workerScript); - } return Promise.resolve(ThrowParty(corporation, office, costPerEmployee)); }); }, @@ -359,9 +353,6 @@ export function NetscriptCorporation( (60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)), workerScript, ).then(function () { - if (workerScript.env.stopFlag) { - return Promise.reject(workerScript); - } return Promise.resolve(BuyCoffee(corporation, getDivision(divisionName), getOffice(divisionName, cityName))); }); }, diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index f2e2e0542..2f8f3f7ef 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -611,9 +611,6 @@ export function NetscriptSingularity( ); return netscriptDelay(installTime, workerScript).then(function () { - if (workerScript.env.stopFlag) { - return Promise.reject(workerScript); - } workerScript.log("installBackdoor", () => `Successfully installed backdoor on '${server.hostname}'`); server.backdoorInstalled = true; diff --git a/src/NetscriptFunctions/Stanek.ts b/src/NetscriptFunctions/Stanek.ts index 94dd6d24b..66e084655 100644 --- a/src/NetscriptFunctions/Stanek.ts +++ b/src/NetscriptFunctions/Stanek.ts @@ -38,9 +38,6 @@ export function NetscriptStanek(player: IPlayer, workerScript: WorkerScript, hel if (!fragment) throw helper.makeRuntimeErrorMsg("stanek.charge", `No fragment with root (${rootX}, ${rootY}).`); const time = staneksGift.inBonus() ? 200 : 1000; return netscriptDelay(time, workerScript).then(function () { - if (workerScript.env.stopFlag) { - return Promise.reject(workerScript); - } const charge = staneksGift.charge(player, fragment, workerScript.scriptRef.threads); workerScript.log("stanek.charge", () => `Charged fragment for ${charge} charge.`); return Promise.resolve();