mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
fix(compat): support DSP 0.10.35.29057
Adapt UXAssist and CheatEnabler to the new terrain workflows, view modes, receiver inventory, and mineral-depletion API. Preserve crafting shortcuts, batch buyout visibility, soil progression, and saved brush safety. Refresh game references and document compatibility changes. Release builds, static compatibility checks, behavior assertions, and diff checks pass; user testing is also confirmed.
This commit is contained in:
1 parent
367a72b375
commit
ac4210fe5d
15 files changed
+214
-131
No files matched your search
@@ -3,6 +3,7 @@ using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.Patching;
|
||||
|
||||
namespace UXAssist.Patches;
|
||||
|
||||
@@ -29,21 +30,19 @@ public static class PlanetPatch
|
||||
{
|
||||
// Harmony transpiler: VFInput_UpdateGameStates_Transpiler
|
||||
// Target: VFInput.UpdateGameStates
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
// Fallback: TranspilerGuard returns original instructions when the globe-view checks are not found.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(VFInput), nameof(VFInput.UpdateGameStates))]
|
||||
private static IEnumerable<CodeInstruction> VFInput_UpdateGameStates_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* remove UIGame.viewMode != EViewMode.Globe in two places:
|
||||
* so search for:
|
||||
* ldsfld bool VFInput::viewMode
|
||||
* ldc.i4.3
|
||||
*/
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(typeof(UIGame), nameof(UIGame.viewMode))),
|
||||
new CodeMatch(OpCodes.Ldc_I4_3)
|
||||
new CodeMatch(instruction => instruction.LoadsConstant((int)EViewMode.Globe)),
|
||||
new CodeMatch(instruction => instruction.Branches(out _))
|
||||
);
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, UXAssist.Logger, nameof(VFInput_UpdateGameStates_Transpiler));
|
||||
matcher.Repeat(codeMatcher =>
|
||||
{
|
||||
var labels = codeMatcher.Labels;
|
||||
@@ -54,54 +53,46 @@ public static class PlanetPatch
|
||||
}
|
||||
// Harmony transpiler: PlayerController_GetInput_Transpiler
|
||||
// Target: PlayerController.GetInput
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
// Fallback: TranspilerGuard returns original instructions when the view-mode input limit is not found.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlayerController), nameof(PlayerController.GetInput))]
|
||||
private static IEnumerable<CodeInstruction> PlayerController_GetInput_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
// replace `UIGame.viewMode >= EViewMode.Globe` with `UIGame.viewMode >= EViewMode.Starmap`
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(typeof(UIGame), nameof(UIGame.viewMode))),
|
||||
new CodeMatch(OpCodes.Ldc_I4_3)
|
||||
).Advance(1).Opcode = OpCodes.Ldc_I4_4;
|
||||
new CodeMatch(instruction => instruction.LoadsConstant((int)EViewMode.Globe))
|
||||
);
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, UXAssist.Logger, nameof(PlayerController_GetInput_Transpiler));
|
||||
matcher.Advance(1).Set(OpCodes.Ldc_I4, (int)EViewMode.Starmap);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
// Harmony transpiler: PlayerAction_Rts_GameTick_Transpiler
|
||||
// Target: PlayerAction_Rts.GameTick
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
// Fallback: TranspilerGuard returns original instructions when the camera-conflict getters are not found.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlayerAction_Rts), nameof(PlayerAction_Rts.GameTick))]
|
||||
private static IEnumerable<CodeInstruction> PlayerAction_Rts_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
var local1 = generator.DeclareLocal(typeof(bool));
|
||||
// var local1 = UIGame.viewMode == 3;
|
||||
var moveConflict = AccessTools.PropertyGetter(typeof(VFInput), nameof(VFInput.rtsMoveCameraConflict));
|
||||
var mineConflict = AccessTools.PropertyGetter(typeof(VFInput), nameof(VFInput.rtsMineCameraConflict));
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(VFInput), nameof(VFInput.rtsMoveCameraConflict))),
|
||||
new CodeMatch(OpCodes.Stloc_1)
|
||||
);
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = [];
|
||||
matcher.InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(UIGame), nameof(UIGame.viewMode))).WithLabels(labels),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_3),
|
||||
new CodeInstruction(OpCodes.Ceq),
|
||||
new CodeInstruction(OpCodes.Stloc, local1)
|
||||
);
|
||||
// Add extra condition:
|
||||
// VFInput.rtsMoveCameraConflict / VFInput.rtsMineCameraConflict `|| local1`
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Ldloc_1 || instr.opcode == OpCodes.Ldloc_2)
|
||||
new CodeMatch(instruction => instruction.Calls(moveConflict) || instruction.Calls(mineConflict))
|
||||
);
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, UXAssist.Logger, nameof(PlayerAction_Rts_GameTick_Transpiler));
|
||||
matcher.Repeat(codeMatcher =>
|
||||
{
|
||||
codeMatcher.Advance(1).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldloc, local1),
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(UIGame), nameof(UIGame.viewMode))),
|
||||
new CodeInstruction(OpCodes.Ldc_I4, (int)EViewMode.Globe),
|
||||
new CodeInstruction(OpCodes.Ceq),
|
||||
new CodeInstruction(OpCodes.Or)
|
||||
);
|
||||
});
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user