Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Support for upcoming SPT 3.10, using EFT 0.15.2.32678 #571

Closed
wants to merge 40 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e9b9c2c
Proto for upcoming spt release
sailro Sep 4, 2024
8f683dd
Rewrite
sailro Sep 4, 2024
8d66285
Fix instant-reveal
sailro Sep 5, 2024
46d5b52
Remove unused namespaces
sailro Sep 5, 2024
cbd927f
Removve newline
sailro Sep 5, 2024
4b64f36
Only enable when needed
sailro Sep 5, 2024
0036089
Fix wishlist
sailro Sep 6, 2024
c8f9897
Add an option to track the auto-wishlist
sailro Sep 6, 2024
61e341f
Add `spawnhi` command
sailro Sep 6, 2024
d17130f
Reword/consistency, do not use `wallhack` term anymore.
sailro Sep 9, 2024
bc0d583
Update Strings.zh-cn.resx
sailro Sep 9, 2024
35b9861
Update Strings.zh-cn.resx
sailro Sep 10, 2024
0ae1c64
Merge pull request #561 from sailro/wallhack-to-players
sailro Sep 10, 2024
c7b1e1b
Add noflash feature
sailro Sep 10, 2024
0570c89
Update readme
sailro Sep 10, 2024
6cb895b
Merge pull request #562 from sailro/noflash
sailro Sep 11, 2024
4169c94
Refine installer
sailro Sep 11, 2024
c728c4d
Improve prompt
sailro Sep 12, 2024
798cbb0
Bump installer version
sailro Sep 12, 2024
91ded69
Check if the version is supported
sailro Sep 12, 2024
fbf6616
Faster branch check
sailro Sep 12, 2024
0d219d9
Refine implementation
sailro Sep 13, 2024
a78e85d
Merge pull request #563 from sailro/refine-installer
sailro Sep 13, 2024
de3c698
Reword
sailro Sep 16, 2024
8d12206
Detect SPT-AKI install locations from MUI cache
sailro Sep 17, 2024
1691856
handle 'The variable 'e' is declared but never used'
sailro Sep 17, 2024
5ce1bae
Merge pull request #566 from sailro/muicache
sailro Sep 17, 2024
52f2fc4
Bump installer version
sailro Sep 17, 2024
f7e2847
Minor fixes
sailro Sep 23, 2024
532768d
Add extra setup for spawned items
sailro Sep 25, 2024
7533eb4
Merge pull request #570 from sailro/setup-items
sailro Sep 26, 2024
fa1c0f2
Update readme
sailro Sep 27, 2024
bb59f45
Triggers a mortar strike at the player's location
sailro Sep 27, 2024
0ec5e85
Merge pull request #572 from sailro/mortar
sailro Sep 28, 2024
21da983
Improve spawn
sailro Sep 29, 2024
e8be903
Merge pull request #573 from sailro/better-spawn
sailro Sep 30, 2024
f115e22
Triggers an airdrop at the player's location
sailro Sep 30, 2024
0ed1cab
Simplify
sailro Sep 30, 2024
e0f6c0d
Comment is now incorrect
sailro Sep 30, 2024
dc27e4d
Merge pull request #574 from sailro/airdrop
sailro Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix instant-reveal
sailro committed Sep 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8d66285c9564243ae69a4c6b2cd01f3dbbdfafeb
29 changes: 15 additions & 14 deletions Features/Examine.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
using EFT.InventoryLogic;
using System;
using System.Linq;
using EFT.InventoryLogic;
using EFT.InventoryLogic.Operations;
using EFT.Trainer.Extensions;
using EFT.Trainer.Properties;
using GPUInstancer;
using HarmonyLib;
using JetBrains.Annotations;
using UnityEngine.Profiling;
using static EFT.Player;


#nullable enable

@@ -22,32 +31,24 @@ protected static bool ExaminedPrefix(ref bool __result)
return true; // keep using original code, we are not enabled

__result = true;
return false; // skip the original code and all other prefix methods
return false; // skip the original code and all other prefix methods
}

[UsedImplicitly]
protected static bool GetSearchStatePrefix(SearchableItemClass __instance)
protected static bool SinglePlayerInventoryControllerConstructorPrefix(Player player, Profile profile, ref bool examined)
{
var feature = FeatureFactory.GetFeature<Examine>();
if (feature == null || !feature.Enabled)
return true; // keep using original code, we are not enabled

var player = GameState.Current?.LocalPlayer;
if (player == null)
return true;

//__instance.UncoverAll(player.ProfileId);
// this will make the game use the passthrough type implementing IPlayerSearchController, ISearchController with all items known and searched
examined = true;
return true;
}


protected override void UpdateWhenEnabled()
{
HarmonyPatchOnce(harmony =>
{
HarmonyPrefix(harmony, typeof(Profile), nameof(Profile.Examined), nameof(ExaminedPrefix), [typeof(string)]);
HarmonyPrefix(harmony, typeof(Profile), nameof(Profile.Examined), nameof(ExaminedPrefix), [typeof(Item)]);
//HarmonyPrefix(harmony, typeof(SearchableItemClass), nameof(SearchableItemClass.GetSearchState), nameof(GetSearchStatePrefix));
HarmonyConstructorPrefix(harmony, typeof(SinglePlayerInventoryController), nameof(SinglePlayerInventoryControllerConstructorPrefix), [typeof(Player), typeof(Profile), typeof(bool)]);
});
}
}
65 changes: 38 additions & 27 deletions Features/Feature.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Reflection;
using EFT.InputSystem;
using EFT.UI;
using Newtonsoft.Json;
@@ -30,48 +31,58 @@ public void HarmonyPatchOnce(Action<HarmonyLib.Harmony> action)
action(harmony);
}

public void HarmonyPrefix(HarmonyLib.Harmony harmony, Type originalType, string originalMethod, string newMethod, Type[]? parameters = null)
public void HarmonyDispatch(HarmonyLib.Harmony harmony, Type originalType, string? originalMethod, string? newPrefixMethod, string? newPostfixMethod, Type[]? parameters = null)
{
var original = HarmonyLib.AccessTools.Method(originalType, originalMethod, parameters);
MethodBase original = originalMethod == null
? HarmonyLib.AccessTools.Constructor(originalType, parameters)
: HarmonyLib.AccessTools.Method(originalType, originalMethod, parameters);

if (original == null)
{
AddConsoleLog(string.Format(Properties.Strings.ErrorCannotFindOriginalMethodFormat, $"{originalType}.{originalMethod}"));
AddConsoleLog(string.Format(Properties.Strings.ErrorCannotFindOriginalMethodFormat, $"{originalType}.{originalMethod ?? "ctor"}").Red());
return;
}

var prefix = HarmonyLib.AccessTools.Method(GetType(), newMethod);
if (prefix == null)
{
AddConsoleLog(string.Format(Properties.Strings.ErrorCannotFindPrefixMethodFormat, newMethod));
var prefix = GetTargetMethod(newPrefixMethod, Properties.Strings.ErrorCannotFindPrefixMethodFormat);
var postfix = GetTargetMethod(newPostfixMethod, Properties.Strings.ErrorCannotFindPostfixMethodFormat);

if (prefix != null && postfix != null)
return;

if (prefix == null && postfix == null)
return;
}

harmony.Patch(original, prefix: new HarmonyLib.HarmonyMethod(prefix));
harmony.Patch(original, prefix: prefix, postfix: postfix);
#if DEBUG
AddConsoleLog(string.Format(Properties.Strings.DebugPatchedMethodFormat, $"{originalType}.{originalMethod}", $"{GetType()}.{newMethod}"));
AddConsoleLog(string.Format(Properties.Strings.DebugPatchedMethodFormat, $"{originalType}.{originalMethod}", $"{GetType()}.{newPrefixMethod ?? newPostfixMethod}"));
#endif
}

public void HarmonyPostfix(HarmonyLib.Harmony harmony, Type originalType, string originalMethod, string newMethod)
private HarmonyLib.HarmonyMethod? GetTargetMethod(string? methodName, string errorFormat)
{
var original = HarmonyLib.AccessTools.Method(originalType, originalMethod);
if (original == null)
{
AddConsoleLog(string.Format(Properties.Strings.ErrorCannotFindOriginalMethodFormat, $"{originalType}.{originalMethod}"));
return;
}
if (methodName == null)
return null;

var postfix = HarmonyLib.AccessTools.Method(GetType(), newMethod);
if (postfix == null)
{
AddConsoleLog(string.Format(Properties.Strings.ErrorCannotFindPostfixMethodFormat, newMethod));
return;
}
var method = HarmonyLib.AccessTools.Method(GetType(), methodName);
if (method == null)
AddConsoleLog(string.Format(errorFormat, methodName).Red());

harmony.Patch(original, postfix: new HarmonyLib.HarmonyMethod(postfix));
#if DEBUG
AddConsoleLog(string.Format(Properties.Strings.DebugPatchedMethodFormat, $"{originalType}.{originalMethod}", $"{GetType()}.{newMethod}"));
#endif
return new HarmonyLib.HarmonyMethod(method);
}

public void HarmonyPrefix(HarmonyLib.Harmony harmony, Type originalType, string originalMethod, string newMethod, Type[]? parameters = null)
{
HarmonyDispatch(harmony, originalType, originalMethod, newPrefixMethod: newMethod, newPostfixMethod: null, parameters);
}

public void HarmonyConstructorPrefix(HarmonyLib.Harmony harmony, Type originalType, string newMethod, Type[]? parameters)
{
HarmonyDispatch(harmony, originalType, null, newPrefixMethod: newMethod, newPostfixMethod: null, parameters);
}

public void HarmonyPostfix(HarmonyLib.Harmony harmony, Type originalType, string originalMethod, string newMethod, Type[]? parameters = null)
{
HarmonyDispatch(harmony, originalType, originalMethod, newPrefixMethod: null, newPostfixMethod: newMethod, parameters);
}

protected void AddConsoleLog(string log)