From 804fbfa90aa02e3d92a1f3d1ffdb10f604ba95a3 Mon Sep 17 00:00:00 2001 From: Heikki Aitakangas Date: Thu, 6 Jan 2022 19:06:44 +0200 Subject: [PATCH] Make corporation delayed functions check if script has been stopped during delay --- src/NetscriptFunctions/Corporation.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index 67bb16e76..98037706c 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -311,6 +311,9 @@ 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)); }); }, @@ -341,6 +344,9 @@ 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)); }); }, @@ -353,6 +359,9 @@ 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))); }); },