From 94e5c7884bef60ff0524a3193f260d68c40c1148 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Mon, 19 Oct 2026 22:59:08 +0800 Subject: [PATCH] fix(uxassist): restore vein protection patch activation Pass the miner window's struct value to a matching helper while retaining ref parameters for statistics. This prevents invalid IL from rolling back the entire vein-protection patch group. --- UXAssist/Patches/Factory/VeinProtectionUIPatch.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/UXAssist/Patches/Factory/VeinProtectionUIPatch.cs b/UXAssist/Patches/Factory/VeinProtectionUIPatch.cs index d4308da..e31d500 100644 --- a/UXAssist/Patches/Factory/VeinProtectionUIPatch.cs +++ b/UXAssist/Patches/Factory/VeinProtectionUIPatch.cs @@ -31,6 +31,11 @@ internal static partial class VeinProtectionPatch return count; } + private static int GetMiningVeinCountForWindow(MinerComponent miner, PlanetFactory factory) + { + return GetMiningVeinCount(ref miner, factory); + } + private static int GetMiningVeinAmount(ref VeinData vein, PlanetFactory factory) { return IsProtectedVein(ref vein, FactoryPatch.GetMiningCostRate(factory.gameData.history)) ? 0 : vein.amount; @@ -55,7 +60,11 @@ internal static partial class VeinProtectionPatch new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(MinerComponent), nameof(MinerComponent.veinCount))), new CodeMatch(ci => ci.opcode == OpCodes.Conv_R8 || ci.opcode == OpCodes.Conv_R4)); if (matcher.IsInvalid) return matcher.Finish(original, UXAssist.Logger, nameof(MiningSpeed_Transpiler)); - matcher.Repeat(m => ReplaceRead(m, factoryLoad, nameof(GetMiningVeinCount))); + // The window loads a struct value; the statistics paths load managed references. + var veinCountHelper = __originalMethod.DeclaringType == typeof(UIMinerWindow) + ? nameof(GetMiningVeinCountForWindow) + : nameof(GetMiningVeinCount); + matcher.Repeat(m => ReplaceRead(m, factoryLoad, veinCountHelper)); matcher.Start().MatchForward(false, new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(VeinData), nameof(VeinData.amount))),