From 55586c782823a7430d47e4f341c5b726bbc1d9eb Mon Sep 17 00:00:00 2001 From: CWX Date: Mon, 12 Feb 2024 13:31:09 +0000 Subject: [PATCH] Profile is now on its own interface, added new interfaceType to patchConstants and fixed the two scav patches (!80) PR to fix transpiler patches, GInterface144 that was originally targeted no longer has get_Profile and has moved to GInterface146, so added patchconstants for it and fixed patches, get_ProfileOfPet has also moved there. Tested on both PMC and scav getting into raid, works fine, error was originally coming up on game start Co-authored-by: CWXDEV Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Modules/pulls/80 Co-authored-by: CWX Co-committed-by: CWX --- project/Aki.Reflection/Utils/PatchConstants.cs | 2 ++ .../Patches/ScavMode/ScavPrefabLoadPatch.cs | 6 +++--- .../Patches/ScavMode/ScavProfileLoadPatch.cs | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/project/Aki.Reflection/Utils/PatchConstants.cs b/project/Aki.Reflection/Utils/PatchConstants.cs index 3c8f7ce..39a1f07 100644 --- a/project/Aki.Reflection/Utils/PatchConstants.cs +++ b/project/Aki.Reflection/Utils/PatchConstants.cs @@ -19,6 +19,7 @@ namespace Aki.Reflection.Utils public static Type ExfilPointManagerType { get; private set; } public static Type SessionInterfaceType { get; private set; } public static Type BackendSessionInterfaceType { get; private set; } + public static Type BackendProfileInterfaceType { get; private set; } private static ISession _backEndSession; public static ISession BackEndSession @@ -47,6 +48,7 @@ namespace Aki.Reflection.Utils ExfilPointManagerType = EftTypes.SingleCustom(x => x.GetMethod("InitAllExfiltrationPoints") != null); SessionInterfaceType = EftTypes.SingleCustom(x => x.GetMethods().Select(y => y.Name).Contains("GetPhpSessionId") && x.IsInterface); BackendSessionInterfaceType = EftTypes.SingleCustom(x => x.GetMethods().Select(y => y.Name).Contains("ChangeProfileStatus") && x.IsInterface); + BackendProfileInterfaceType = EftTypes.SingleCustom(x => x.GetMethods().Length == 2 && x.GetMethods().Select(y => y.Name).Contains("get_Profile") && x.IsInterface); } /// diff --git a/project/Aki.SinglePlayer/Patches/ScavMode/ScavPrefabLoadPatch.cs b/project/Aki.SinglePlayer/Patches/ScavMode/ScavPrefabLoadPatch.cs index 026eca5..6a586d8 100644 --- a/project/Aki.SinglePlayer/Patches/ScavMode/ScavPrefabLoadPatch.cs +++ b/project/Aki.SinglePlayer/Patches/ScavMode/ScavPrefabLoadPatch.cs @@ -36,7 +36,7 @@ namespace Aki.SinglePlayer.Patches.ScavMode var codes = new List(instructions); // Search for code where backend.Session.getProfile() is called. - var searchCode = new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(PatchConstants.BackendSessionInterfaceType, "get_Profile")); + var searchCode = new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(PatchConstants.BackendProfileInterfaceType, "get_Profile")); var searchIndex = -1; for (var i = 0; i < codes.Count; i++) @@ -69,9 +69,9 @@ namespace Aki.SinglePlayer.Patches.ScavMode new Code(OpCodes.Ldfld, typeof(TarkovApplication), "_raidSettings"), new Code(OpCodes.Callvirt, typeof(RaidSettings), "get_IsPmc"), new Code(OpCodes.Brfalse, brFalseLabel), - new Code(OpCodes.Callvirt, PatchConstants.BackendSessionInterfaceType, "get_Profile"), + new Code(OpCodes.Callvirt, PatchConstants.BackendProfileInterfaceType, "get_Profile"), new Code(OpCodes.Br, brLabel), - new CodeWithLabel(OpCodes.Callvirt, brFalseLabel, PatchConstants.SessionInterfaceType, "get_ProfileOfPet"), + new CodeWithLabel(OpCodes.Callvirt, brFalseLabel, PatchConstants.BackendProfileInterfaceType, "get_ProfileOfPet"), new CodeWithLabel(OpCodes.Ldc_I4_1, brLabel) }); diff --git a/project/Aki.SinglePlayer/Patches/ScavMode/ScavProfileLoadPatch.cs b/project/Aki.SinglePlayer/Patches/ScavMode/ScavProfileLoadPatch.cs index b457a90..5e7556e 100644 --- a/project/Aki.SinglePlayer/Patches/ScavMode/ScavProfileLoadPatch.cs +++ b/project/Aki.SinglePlayer/Patches/ScavMode/ScavProfileLoadPatch.cs @@ -37,7 +37,7 @@ namespace Aki.SinglePlayer.Patches.ScavMode var codes = new List(instructions); // Search for code where backend.Session.getProfile() is called. - var searchCode = new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(PatchConstants.BackendSessionInterfaceType, "get_Profile")); + var searchCode = new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(PatchConstants.BackendProfileInterfaceType, "get_Profile")); var searchIndex = -1; for (var i = 0; i < codes.Count; i++) @@ -69,9 +69,9 @@ namespace Aki.SinglePlayer.Patches.ScavMode new Code(OpCodes.Ldfld, typeof(TarkovApplication), "_raidSettings"), new Code(OpCodes.Callvirt, typeof(RaidSettings), "get_IsPmc"), new Code(OpCodes.Brfalse, brFalseLabel), - new Code(OpCodes.Callvirt, PatchConstants.BackendSessionInterfaceType, "get_Profile"), + new Code(OpCodes.Callvirt, PatchConstants.BackendProfileInterfaceType, "get_Profile"), new Code(OpCodes.Br, brLabel), - new CodeWithLabel(OpCodes.Callvirt, brFalseLabel, PatchConstants.SessionInterfaceType, "get_ProfileOfPet"), + new CodeWithLabel(OpCodes.Callvirt, brFalseLabel, PatchConstants.BackendProfileInterfaceType, "get_ProfileOfPet"), new CodeWithLabel(OpCodes.Stfld, brLabel, typeof(TarkovApplication).GetNestedTypes(BindingFlags.Public).SingleCustom(IsTargetNestedType), "profile") });