From 3abd27423bfef2dec2bd7215120fb5c3047c9298 Mon Sep 17 00:00:00 2001
From: Lacyway <20912169+Lacyway@users.noreply.github.com>
Date: Thu, 9 Jan 2025 02:18:40 -0800
Subject: [PATCH] Add EnablePrestigeTabPatch (#23)
* Add new transpilers
* Cleanup
* Fix transpiler
* Fix incorrect code instruction
* Add EnablePrestigeTabPatch
---------
Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
---
.../Patches/EnablePrestigeTabPatch.cs | 40 +++++++++++++++++++
project/SPT.Custom/SPTCustomPlugin.cs | 3 ++
2 files changed, 43 insertions(+)
create mode 100644 project/SPT.Custom/Patches/EnablePrestigeTabPatch.cs
diff --git a/project/SPT.Custom/Patches/EnablePrestigeTabPatch.cs b/project/SPT.Custom/Patches/EnablePrestigeTabPatch.cs
new file mode 100644
index 0000000..c9825fb
--- /dev/null
+++ b/project/SPT.Custom/Patches/EnablePrestigeTabPatch.cs
@@ -0,0 +1,40 @@
+using EFT.UI;
+using HarmonyLib;
+using SPT.Reflection.Patching;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace SPT.Custom.Patches
+{
+ ///
+ /// This transpiler removes the call to to determine if it's
+ /// and forces a true instead
+ ///
+ internal class EnablePrestigeTabPatch : ModulePatch
+ {
+ protected override MethodBase GetTargetMethod()
+ {
+ return AccessTools.Method(typeof(InventoryScreen.Class2754), nameof(InventoryScreen.Class2754.MoveNext));
+ }
+
+ [PatchTranspiler]
+ public static IEnumerable Transpile(IEnumerable instructions)
+ {
+ CodeInstruction[] codeInstructions = instructions.ToArray();
+
+ // Remove all instructions that gets the gamemode from iSession
+ codeInstructions[259] = new(OpCodes.Nop);
+ codeInstructions[260] = new(OpCodes.Nop);
+ codeInstructions[261] = new(OpCodes.Nop);
+ codeInstructions[262] = new(OpCodes.Nop);
+ codeInstructions[263] = new(OpCodes.Nop);
+
+ // Force a true on the stack instead
+ codeInstructions[264] = new(OpCodes.Ldc_I4_1);
+
+ return codeInstructions;
+ }
+ }
+}
diff --git a/project/SPT.Custom/SPTCustomPlugin.cs b/project/SPT.Custom/SPTCustomPlugin.cs
index 7dc8df0..9d16734 100644
--- a/project/SPT.Custom/SPTCustomPlugin.cs
+++ b/project/SPT.Custom/SPTCustomPlugin.cs
@@ -48,6 +48,9 @@ namespace SPT.Custom
new AllowAirdropsInPvEPatch().Enable();
new MemoryCollectionPatch().Enable();
+ // 4.0
+ new EnablePrestigeTabPatch().Enable();
+
HookObject.AddComponent();
}
catch (Exception ex)