From 538a440b7e47ed28873f67ee2db01f91bd49d791 Mon Sep 17 00:00:00 2001 From: TheMas3212 Date: Wed, 5 Jan 2022 21:36:09 +1100 Subject: [PATCH 1/2] Fixes #1860 donate to gang faction possible via singularity also fixes bug i found while testing this where its possible to donate to a faction you arent a member of --- src/NetscriptFunctions/Singularity.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index e903c7dc6..9e03e6efa 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -1175,7 +1175,20 @@ export function NetscriptSingularity( helper.updateDynamicRam("donateToFaction", getRamCost(player, "donateToFaction")); helper.checkSingularityAccess("donateToFaction"); const faction = getFaction("donateToFaction", name); - + if (!player.factions.includes(faction.name)) { + workerScript.log( + "donateToFaction", + () => `You can't donate to '${name}' because you aren't a member`, + ); + return false; + } + if (faction.name === player.getGangFaction().name) { + workerScript.log( + "donateToFaction", + () => `You can't donate to '${name}' because youre managing a gang for it`, + ); + return false; + } if (typeof amt !== "number" || amt <= 0) { workerScript.log("donateToFaction", () => `Invalid donation amount: '${amt}'.`); return false; From 860e77f10935be93041839c8473203f5fb7f3ce3 Mon Sep 17 00:00:00 2001 From: TheMas3212 Date: Wed, 5 Jan 2022 21:41:04 +1100 Subject: [PATCH 2/2] Add check to see if player is in gang before getting Gang Faction --- src/NetscriptFunctions/Singularity.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index 9e03e6efa..d2deacfec 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -1182,7 +1182,7 @@ export function NetscriptSingularity( ); return false; } - if (faction.name === player.getGangFaction().name) { + if (player.inGang() && faction.name === player.getGangFaction().name) { workerScript.log( "donateToFaction", () => `You can't donate to '${name}' because youre managing a gang for it`,