From d6dd573e88f9fa35526838f57c393b2ba82b91b5 Mon Sep 17 00:00:00 2001 From: Kaeno Date: Fri, 24 May 2024 07:12:44 +0000 Subject: [PATCH] Safeguard ScavRepAdjustmentpatch to only run when its your player doing the killing. Added notes so Gclass ref doesnt get updated incorrectly (!132) Reviewed-on: https://dev.sp-tarkov.com/SPT/Modules/pulls/132 --- .../Patches/ScavMode/ScavRepAdjustmentPatch.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/project/SPT.SinglePlayer/Patches/ScavMode/ScavRepAdjustmentPatch.cs b/project/SPT.SinglePlayer/Patches/ScavMode/ScavRepAdjustmentPatch.cs index d425cc9..f4ac2b4 100644 --- a/project/SPT.SinglePlayer/Patches/ScavMode/ScavRepAdjustmentPatch.cs +++ b/project/SPT.SinglePlayer/Patches/ScavMode/ScavRepAdjustmentPatch.cs @@ -12,14 +12,22 @@ namespace SPT.SinglePlayer.Patches.ScavMode // TODO: REMAP/UPDATE GCLASS REF protected override MethodBase GetTargetMethod() { - return AccessTools.Method(typeof(GClass1798), nameof(GClass1798.OnEnemyKill)); + // Correct Gclass has sessionCounters + return AccessTools.Method(typeof(GClass1800), nameof(GClass1800.OnEnemyKill)); } [PatchPrefix] - private static void PatchPrefix(string playerProfileId, out Tuple __state) + private static void PatchPrefix(DamageInfo damage, string playerProfileId, out Tuple __state) { - var player = Singleton.Instance.MainPlayer; __state = new Tuple(null, false); + var player = (Player)damage.Player.iPlayer; + + // Add safeguards to make sure no calculations happen from other bots + if (!player.IsYourPlayer) + { + Logger.LogError("This shouldn't be happening. Are you sure we are using the correct GClass?"); + return; + } if (player.Profile.Side != EPlayerSide.Savage) {