0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 08:30:45 -05:00

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>
This commit is contained in:
Lacyway 2025-01-09 02:18:40 -08:00 committed by GitHub
parent 77aa9496a0
commit 3abd27423b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 0 deletions

View File

@ -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
{
/// <summary>
/// This transpiler removes the call to <see cref="IBackEndSession.SessionMode"/> to determine if it's <see cref="ESessionMode.Regular"/> <br/>
/// and forces a true instead
/// </summary>
internal class EnablePrestigeTabPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(InventoryScreen.Class2754), nameof(InventoryScreen.Class2754.MoveNext));
}
[PatchTranspiler]
public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> 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;
}
}
}

View File

@ -48,6 +48,9 @@ namespace SPT.Custom
new AllowAirdropsInPvEPatch().Enable(); new AllowAirdropsInPvEPatch().Enable();
new MemoryCollectionPatch().Enable(); new MemoryCollectionPatch().Enable();
// 4.0
new EnablePrestigeTabPatch().Enable();
HookObject.AddComponent<MenuNotificationManager>(); HookObject.AddComponent<MenuNotificationManager>();
} }
catch (Exception ex) catch (Exception ex)