From c9f0c9c553d657d0cf48312ae7c051ec3e025bfe Mon Sep 17 00:00:00 2001 From: TheMas3212 Date: Wed, 5 Jan 2022 22:02:25 +1100 Subject: [PATCH] Fixes 1862 Combat gang members can do hacking tasks via API and vice versa --- src/NetscriptFunctions/Gang.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NetscriptFunctions/Gang.ts b/src/NetscriptFunctions/Gang.ts index c484947be..7d64588b5 100644 --- a/src/NetscriptFunctions/Gang.ts +++ b/src/NetscriptFunctions/Gang.ts @@ -194,6 +194,15 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe helper.updateDynamicRam("setMemberTask", getRamCost(player, "gang", "setMemberTask")); checkGangApiAccess("setMemberTask"); const member = getGangMember("setMemberTask", memberName); + const gang = player.gang; + if (gang === null) throw new Error("Should not be called without Gang"); + if (!gang.getAllTaskNames().includes(taskName)) { + workerScript.log( + "gang.setMemberTask", + () => `Failed to assign Gang Member '${memberName}' to Invalid task '${taskName}'. '${memberName}' is now Unassigned`, + ); + return member.assignToTask('Unassigned'); + } const success = member.assignToTask(taskName); if (success) { workerScript.log(