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
@@ -31,9 +31,10 @@
|
||||
- Prefer `UXAssist/Common/GameConstants` for item, tech, logistics, and Dyson sphere constants instead of inline literals.
|
||||
- Persist mod data through `IModCanSave` from DSPModSave.
|
||||
- Use `ModCompatHelper` for external plugin/type/member resolution and preserve legacy public type identities when refactoring reflection targets. Use `DysonSphereReflection` for DSPOptimizations-compatible Dyson sphere fields.
|
||||
- Performance-sensitive Harmony transpilers must include the standard target/fallback header and use `TranspilerGuard` when a matcher can fail; returning original instructions is the fallback.
|
||||
- Performance-sensitive Harmony transpilers must include the standard target/fallback header and use `TranspilerGuard` when a matcher can fail; returning original instructions is the fallback. Match named enum members and semantic calls or fields instead of hard-coded enum values or local-variable slots.
|
||||
- `PatchImpl<T>.Enable(true)` must remain fail-soft: log, unpatch, and leave the patch unset if Harmony application fails so config delegate chains remain consistent.
|
||||
- Overlay UI state must converge from actual game state on periodic updates, not depend only on one-shot event or patch callbacks. Cloned controls must reset runtime state while retaining source styles; use `UXAssist.UI.Util.GetPreferredWidth` for dynamic text and `ResetButton` for cloned buttons.
|
||||
- UI-only options must preserve native progression, statistics, and event delivery. Suppress presentation handlers rather than bypassing authoritative game-state setters.
|
||||
- LiveStreamAssist browser overlays must use single-flight polling and discard stale work after connection changes. Compound queries must reject mixed session IDs; cache only positive production indices so newly tracked items remain discoverable.
|
||||
- LiveStreamAssist production reads must schedule the native extra-info calculator for queried factories independently of the statistics UI. Deduplicate and throttle refreshes, let active native batches finish, and clear pending factory indices and deadlines at session boundaries.
|
||||
- LiveStreamAssist `ReflectionReader` caches bounded per-type member metadata and clears it during API uninitialization; do not cache mutable game values or arbitrary request results.
|
||||
@@ -56,5 +57,6 @@
|
||||
|
||||
## Review Standard
|
||||
|
||||
- Fix root causes with minimal focused changes. Do not alter unrelated behavior, add copyright headers, commit changes, push branches, or create branches unless requested. Use normal pushes; do not rewrite remote history unless explicitly requested.
|
||||
- Fix root causes with minimal focused changes. Do not alter unrelated behavior, add copyright headers, commit changes, push branches, or create branches unless requested. Commit only task-related files and leave unrelated working-tree changes untouched. Use normal pushes; do not rewrite remote history unless explicitly requested.
|
||||
- Before handoff, run the narrowest relevant build or test, then `git diff --check`. Mention unrelated pre-existing failures instead of changing them.
|
||||
- For game updates, also check Harmony target resolution and affected IL patterns against the original game DLL; compilation alone does not validate runtime patches.
|
||||
Binary file not shown.
Binary file not shown.
@@ -3,6 +3,9 @@
|
||||
|
||||
## Changlog
|
||||
|
||||
* Unreleased
|
||||
* Support Dyson Sphere Program 0.10.35.29057. See [compatibility analysis](../docs/GameCompatibility-0.10.35.md).
|
||||
* Update `Terraform anyway` for the separate foundation and Restore Terrain workflows. Preserve soil gains and prevent negative soil balances when resources are insufficient.
|
||||
* 2.4.5
|
||||
* New button `Generate illegal dyson shells for all layers without nodes and shells`, which is used to extend dyson layers.
|
||||
* You must enable `IllegalDysonShellFunctionsEnabled` of `DysonSphere` section in config to see it.
|
||||
|
||||
@@ -5,6 +5,7 @@ using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.ModFeatures;
|
||||
using UXAssist.Common.Patching;
|
||||
|
||||
namespace CheatEnabler.Patches;
|
||||
|
||||
@@ -151,30 +152,34 @@ public static class PlanetPatch
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
// Harmony transpiler: BuildTool_Reform_ReformAction_Patch
|
||||
// Target: BuildTool_Reform.ReformAction
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.DoFlattenExecute))]
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.DoRestoreExecute))]
|
||||
private static void BuildTool_Reform_Execute_Prefix(BuildTool_Reform __instance, ref int needSandCount)
|
||||
{
|
||||
var sandCount = __instance.player.sandCount;
|
||||
if (needSandCount > sandCount)
|
||||
needSandCount = (int)sandCount;
|
||||
}
|
||||
|
||||
// Harmony transpiler: BuildTool_Reform_DoFlattenExecute_Patch
|
||||
// Target: BuildTool_Reform.DoFlattenExecute
|
||||
// Fallback: TranspilerGuard returns original instructions when the foundation count check is not found.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Reform_ReformAction_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.DoFlattenExecute))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Reform_DoFlattenExecute_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(BuildTool_Reform), nameof(BuildTool_Reform.cursorPointCount))),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Blt || ci.opcode == OpCodes.Blt_S)
|
||||
).RemoveInstructions(2).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0)
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.sandCount)))
|
||||
).Advance(1).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Conv_I8),
|
||||
new CodeMatch(OpCodes.Sub)
|
||||
).Advance(2).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I8, 0L),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Math), nameof(Math.Max), [typeof(long), typeof(long)]))
|
||||
);
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, CheatEnabler.Logger, nameof(BuildTool_Reform_DoFlattenExecute_Patch));
|
||||
var labels = matcher.Labels;
|
||||
matcher.RemoveInstructions(2).Insert(new CodeInstruction(OpCodes.Ldc_I4_0).WithLabels(labels));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
## Changlog
|
||||
|
||||
* Unreleased
|
||||
* Support Dyson Sphere Program 0.10.35.29057. See [compatibility analysis](../docs/GameCompatibility-0.10.35.md).
|
||||
* Restore expanded foundation brushes, Restore Terrain support, and player actions in globe view.
|
||||
* Update Ray Receiver buffers and item refunds, vein-depletion alerts, handcrafting shortcuts, and batch technology buyout controls.
|
||||
* Preserve soil progression when hiding soil-change tips and safely restore saved brush sizes when expanded brushes are disabled.
|
||||
* 1.5.9
|
||||
* `Do not render factory entities (except belts and sorters)`: Add sub-option `Hide sorters too` to also hide sorters, leaving only belts visible.
|
||||
* 1.5.8
|
||||
|
||||
@@ -351,9 +351,8 @@ public static class PlanetFunctions
|
||||
var productId = powerGen.productId;
|
||||
var productCount = (int)powerGen.productCount;
|
||||
if (productId != 0 && productCount > 0) AddReturnedItem(productId, productCount, 0, returnedItems);
|
||||
int catalystId = powerGen.catalystId;
|
||||
var catalystPointDiv = powerGen.catalystPoint / 3600;
|
||||
if (catalystId != 0 && catalystPointDiv > 0) AddReturnedItem(catalystId, catalystPointDiv, powerGen.catalystIncPoint / 3600, returnedItems);
|
||||
var catalystId = powerGen.catalystId;
|
||||
if (catalystId != 0 && powerGen.catalystCount > 0) AddReturnedItem(catalystId, powerGen.catalystCount, powerGen.catalystInc, returnedItems);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Reflection.Emit;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.Patching;
|
||||
|
||||
namespace UXAssist.Patches.Factory;
|
||||
|
||||
@@ -163,8 +164,8 @@ internal static class ArchitectModePatch
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
// Harmony transpiler: BuildAreaLimitRemoval_Transpiler
|
||||
// Target: BuildTool_Addon.CheckBuildConditions, BuildTool_Click.CheckBuildConditions, BuildTool_Dismantle.DetermineMoreChainTargets, BuildTool_Dismantle.DeterminePreviews, BuildTool_Inserter.CheckBuildConditions, BuildTool_Path.CheckBuildConditions, BuildTool_Reform.ReformAction, BuildTool_Upgrade.DetermineMoreChainTargets, BuildTool_Upgrade.DeterminePreviews
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
// Target: BuildTool_Addon.CheckBuildConditions, BuildTool_Click.CheckBuildConditions, BuildTool_Dismantle.DetermineMoreChainTargets, BuildTool_Dismantle.DeterminePreviews, BuildTool_Inserter.CheckBuildConditions, BuildTool_Path.CheckBuildConditions, BuildTool_Reform.ExecuteBrushAction, BuildTool_Upgrade.DetermineMoreChainTargets, BuildTool_Upgrade.DeterminePreviews
|
||||
// Fallback: TranspilerGuard returns original instructions when the build-area check is not found.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Addon), nameof(BuildTool_Addon.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
||||
@@ -172,7 +173,7 @@ internal static class ArchitectModePatch
|
||||
[HarmonyPatch(typeof(BuildTool_Dismantle), nameof(BuildTool_Dismantle.DeterminePreviews))]
|
||||
[HarmonyPatch(typeof(BuildTool_Inserter), nameof(BuildTool_Inserter.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ExecuteBrushAction))]
|
||||
[HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DetermineMoreChainTargets))]
|
||||
[HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DeterminePreviews))]
|
||||
private static IEnumerable<CodeInstruction> BuildAreaLimitRemoval_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
@@ -190,6 +191,8 @@ internal static class ArchitectModePatch
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(Mecha), nameof(Mecha.buildArea))),
|
||||
new CodeMatch(OpCodes.Mul)
|
||||
);
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, UXAssist.Logger, nameof(BuildAreaLimitRemoval_Transpiler));
|
||||
matcher.Repeat(m => m.RemoveInstructions(9).InsertAndAdvance(new CodeInstruction(OpCodes.Ldc_R4, 100000000.0f)));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
@@ -216,23 +219,40 @@ internal static class ArchitectModePatch
|
||||
|
||||
internal class LargerAreaForTerraform : PatchImpl<LargerAreaForTerraform>
|
||||
{
|
||||
// Harmony transpiler: BuildTool_Reform_ReformAction_Transpiler
|
||||
// Target: BuildTool_Reform.ReformAction
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
[HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Reform_ReformAction_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private const int MaxBrushSize = 30;
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
var reformTool = GameMain.mainPlayer?.controller?.actionBuild?.reformTool;
|
||||
if (reformTool != null)
|
||||
reformTool.brushSize = Math.Min(reformTool.brushSize, BuildTool_Reform.MAX_BRUSH_SIZE);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.PrepareBrushPoints))]
|
||||
private static void BuildTool_Reform_PrepareBrushPoints_Prefix(BuildTool_Reform __instance)
|
||||
{
|
||||
__instance.brushSize = Math.Max(1, Math.Min(__instance.brushSize, MaxBrushSize));
|
||||
if (__instance.cursorPoints.Length < MaxBrushSize * MaxBrushSize)
|
||||
Array.Resize(ref __instance.cursorPoints, MaxBrushSize * MaxBrushSize);
|
||||
if (__instance.cursorIndices.Length < MaxBrushSize * MaxBrushSize)
|
||||
Array.Resize(ref __instance.cursorIndices, MaxBrushSize * MaxBrushSize);
|
||||
}
|
||||
|
||||
// Harmony transpiler: BuildTool_Reform_ExecuteBrushAction_Transpiler
|
||||
// Target: BuildTool_Reform.ExecuteBrushAction
|
||||
// Fallback: TranspilerGuard returns original instructions when the brush limit is not found.
|
||||
[HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ExecuteBrushAction))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Reform_ExecuteBrushAction_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(BuildTool_Reform), nameof(BuildTool_Reform.brushSize))),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(10))
|
||||
new CodeMatch(ci => ci.LoadsConstant(BuildTool_Reform.MAX_BRUSH_SIZE))
|
||||
);
|
||||
matcher.Repeat(m => m.Advance(1).SetAndAdvance(OpCodes.Ldc_I4_S, 30));
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(10)),
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(BuildTool_Reform), nameof(BuildTool_Reform.brushSize)))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4_S, 30));
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, UXAssist.Logger, nameof(BuildTool_Reform_ExecuteBrushAction_Transpiler));
|
||||
matcher.Advance(1).Set(OpCodes.Ldc_I4, MaxBrushSize);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.Patching;
|
||||
|
||||
namespace UXAssist.Patches.Factory;
|
||||
|
||||
@@ -69,26 +70,22 @@ internal static class BuildingBufferPatch
|
||||
}
|
||||
// Harmony transpiler: PowerGeneratorComponent_GameTick_Gamma_Transpiler
|
||||
// Target: PowerGeneratorComponent.GameTick_Gamma
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
// Fallback: TranspilerGuard returns original instructions when the catalyst buffer check is not found.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.GameTick_Gamma))]
|
||||
private static IEnumerable<CodeInstruction> PowerGeneratorComponent_GameTick_Gamma_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
/*
|
||||
* Patch:
|
||||
* bool flag3 = keyFrame && useIon && (float)this.catalystPoint < 72000f;
|
||||
* To:
|
||||
* bool flag3 = keyFrame && useIon && this.catalystPoint < 3600 * ReceiverBufferCount.Value;
|
||||
*/
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.catalystPoint))),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.catalystCount))),
|
||||
new CodeMatch(OpCodes.Conv_R4),
|
||||
new CodeMatch(OpCodes.Ldc_R4, 72000f),
|
||||
new CodeMatch(OpCodes.Ldc_R4, 20f),
|
||||
new CodeMatch(OpCodes.Clt)
|
||||
);
|
||||
matcher.Advance(2).RemoveInstructions(2).Insert(new CodeInstruction(OpCodes.Ldc_I4, FactoryPatch.ReceiverBufferCount.Value * 3600));
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, UXAssist.Logger, nameof(PowerGeneratorComponent_GameTick_Gamma_Transpiler));
|
||||
matcher.Advance(2).RemoveInstructions(2).Insert(new CodeInstruction(OpCodes.Ldc_I4, FactoryPatch.ReceiverBufferCount.Value));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
// Harmony transpiler: AssemblerComponent_UpdateNeeds_Transpiler
|
||||
|
||||
@@ -138,9 +138,11 @@ internal static class VeinProtectionPatch
|
||||
{
|
||||
var venType = (int)veinPool[veinId].type;
|
||||
var pos = veinPool[veinId].pos;
|
||||
var hasMinerLostAllVeins = GameMain.preferences.mineralExhaustionAlertMode == 2 &&
|
||||
factory.factorySystem.WillMinerLoseAllVeins(veinId);
|
||||
factory.RemoveVeinWithComponents(veinId);
|
||||
factory.RecalculateVeinGroup(groupIndex);
|
||||
factory.NotifyVeinExhausted(venType, groupIndex, pos);
|
||||
factory.NotifyVeinExhausted(venType, groupIndex, pos, hasMinerLostAllVeins);
|
||||
veinCount = __instance.veinCount;
|
||||
}
|
||||
else
|
||||
@@ -242,7 +244,7 @@ internal static class VeinProtectionPatch
|
||||
factory.veinAnimPool[veinId].time = amount >= 25000 ? 0f : 1f - amount * VeinData.oilSpeedMultiplier;
|
||||
if (amount <= 2500)
|
||||
{
|
||||
factory.NotifyVeinExhausted((int)veinPool[veinId].type, groupIndex, veinPool[veinId].pos);
|
||||
factory.NotifyVeinExhausted((int)veinPool[veinId].type, groupIndex, veinPool[veinId].pos, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,16 @@ public class PersistPatch : PatchImpl<PersistPatch>
|
||||
Enable(false);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GamePrefsData), nameof(GamePrefsData.LateRestore))]
|
||||
private static void GamePrefsData_LateRestore_Postfix(GamePrefsData __instance)
|
||||
{
|
||||
if (Factory.ArchitectModePatch.LargerAreaForTerraform.GetHarmony() != null) return;
|
||||
var reformTool = __instance.gameData?.mainPlayer?.controller?.actionBuild?.reformTool;
|
||||
if (reformTool != null)
|
||||
reformTool.brushSize = System.Math.Min(reformTool.brushSize, BuildTool_Reform.MAX_BRUSH_SIZE);
|
||||
}
|
||||
|
||||
// Check for noModifier while pressing hotkeys on build bar
|
||||
// Harmony transpiler: UIBuildMenu__OnUpdate_Transpiler
|
||||
// Target: UIBuildMenu._OnUpdate
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using CommonAPI.Systems;
|
||||
@@ -147,60 +148,28 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 1000));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
// Harmony transpiler: UIReplicatorWindow_OnPlusButtonClick_Transpiler
|
||||
// Target: UIReplicatorWindow.OnPlusButtonClick, UIReplicatorWindow.OnMinusButtonClick
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UIReplicatorWindow), nameof(UIReplicatorWindow.OnPlusButtonClick))]
|
||||
[HarmonyPatch(typeof(UIReplicatorWindow), nameof(UIReplicatorWindow.OnMinusButtonClick))]
|
||||
private static IEnumerable<CodeInstruction> UIReplicatorWindow_OnPlusButtonClick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static bool UIReplicatorWindow_ChangeMultiplier_Prefix(UIReplicatorWindow __instance, RecipeProto ___selectedRecipe, MethodBase __originalMethod)
|
||||
{
|
||||
var label1 = generator.DefineLabel();
|
||||
var label2 = generator.DefineLabel();
|
||||
var label3 = generator.DefineLabel();
|
||||
var label4 = generator.DefineLabel();
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldloc_0),
|
||||
new CodeMatch(OpCodes.Ldc_I4_1),
|
||||
new CodeMatch(o => o.opcode == OpCodes.Add || o.opcode == OpCodes.Sub)
|
||||
).Advance(1).RemoveInstruction().InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(VFInput), nameof(VFInput.control))),
|
||||
new CodeInstruction(OpCodes.Brfalse_S, label1),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_S, 10),
|
||||
new CodeInstruction(OpCodes.Br_S, label4),
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(VFInput), nameof(VFInput.shift))).WithLabels(label1),
|
||||
new CodeInstruction(OpCodes.Brfalse_S, label2),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_S, 100),
|
||||
new CodeInstruction(OpCodes.Br_S, label4),
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(VFInput), nameof(VFInput.alt))).WithLabels(label2),
|
||||
new CodeInstruction(OpCodes.Brfalse_S, label3),
|
||||
new CodeInstruction(OpCodes.Ldc_I4, 1000),
|
||||
new CodeInstruction(OpCodes.Br_S, label4),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1).WithLabels(label3)
|
||||
).Labels.Add(label4);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(10))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 1000));
|
||||
return matcher.InstructionEnumeration();
|
||||
var recipe = ___selectedRecipe;
|
||||
if (recipe == null) return false;
|
||||
var multiplier = __instance.multipliers.TryGetValue(recipe.ID, out var current) ? current : 1;
|
||||
var step = VFInput.control ? 10 : VFInput.shift ? 100 : VFInput.alt ? 1000 : 1;
|
||||
var direction = __originalMethod.Name == nameof(UIReplicatorWindow.OnPlusButtonClick) ? 1 : -1;
|
||||
__instance.multipliers[recipe.ID] = Math.Max(1, Math.Min(1000, multiplier + direction * step));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class HideTipsForSandsChanges : PatchImpl<HideTipsForSandsChanges>
|
||||
{
|
||||
// Harmony transpiler: Player_SetSandCount_Transpiler
|
||||
// Target: Player.SetSandCount
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(Player), nameof(Player.SetSandCount))]
|
||||
private static IEnumerable<CodeInstruction> Player_SetSandCount_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UIGame), nameof(UIGame.OnSandCountChanged))]
|
||||
private static bool UIGame_OnSandCountChanged_Prefix()
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertySetter(typeof(Player), nameof(Player.sandCount)))
|
||||
).Advance(1).Insert(new CodeInstruction(OpCodes.Ret));
|
||||
return matcher.InstructionEnumeration();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.GameConstants;
|
||||
using UXAssist.Common.Patching;
|
||||
using GameLogicProc = UXAssist.Common.GameLogic;
|
||||
|
||||
namespace UXAssist.Patches;
|
||||
@@ -265,23 +266,37 @@ public static class TechPatch
|
||||
{
|
||||
// Harmony transpiler: UITechNode_UpdateInfoDynamic_Transpiler
|
||||
// Target: UITechNode.UpdateInfoDynamic
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
// Fallback: TranspilerGuard returns original instructions when the buyout visibility expression is not found.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UITechNode), nameof(UITechNode.UpdateInfoDynamic))]
|
||||
private static IEnumerable<CodeInstruction> UITechNode_UpdateInfoDynamic_Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(typeof(UITechTree), nameof(UITechTree.showProperty))),
|
||||
new CodeMatch(ci => ci.IsLdloc()),
|
||||
new CodeMatch(OpCodes.And)
|
||||
).Advance(1).SetAndAdvance(OpCodes.Ldloc_3, null).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Ceq)
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(typeof(UITechTree), nameof(UITechTree.showProperty)))
|
||||
);
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, UXAssist.Logger, nameof(UITechNode_UpdateInfoDynamic_Transpiler));
|
||||
var start = matcher.Pos;
|
||||
var labels = matcher.Labels.ToArray();
|
||||
matcher.MatchForward(false, new CodeMatch(instruction => instruction.IsStloc()));
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, UXAssist.Logger, nameof(UITechNode_UpdateInfoDynamic_Transpiler));
|
||||
var count = matcher.Pos - start;
|
||||
matcher.Start().Advance(start).RemoveInstructions(count).Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UITechNode), nameof(UITechNode.techProto))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(BatchBuyoutTech), nameof(CanShowBuyoutButton)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
private static bool CanShowBuyoutButton(TechProto techProto)
|
||||
{
|
||||
return UITechTree.showProperty && !GameMain.sandboxToolsEnabled &&
|
||||
!techProto.IsHiddenTech && !techProto.IsObsolete && !GameMain.history.TechUnlocked(techProto.ID);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UITechNode), nameof(UITechNode.OnBuyoutButtonClick))]
|
||||
private static bool UITechNode_OnBuyoutButtonClick_Prefix(UITechNode __instance)
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
# DSP 0.10.35 Compatibility
|
||||
|
||||
## Scope and sources
|
||||
|
||||
This update adapts UXAssist and CheatEnabler from DSP **0.10.34.28529** to the locally installed **0.10.35.29057**, Steam build **25482430**.
|
||||
|
||||
The comparison uses the original `DSPGAME_Data/Managed/Assembly-CSharp.dll` from the supplied previous-version depot and the Steam installation located through the registry and `steamapps/libraryfolders.vdf`. Version history comes from each installation's `Updates/Versions.txt`. In-game terminology comes from the installed `Locale/Names`, `Locale/1033`, and `Locale/2052` tables.
|
||||
|
||||
The publicized, stripped assemblies in `AssemblyFromGame/` are refreshed for compilation only. They are not used to inspect native method bodies.
|
||||
|
||||
## Assembly changes
|
||||
|
||||
The Assembly-CSharp metadata and IL comparison finds:
|
||||
|
||||
- 69 added types and 9 removed types.
|
||||
- 784 added fields and 78 removed fields.
|
||||
- 663 added method signatures and 46 removed method signatures.
|
||||
- 475 changed bodies among methods whose signatures remain present.
|
||||
|
||||
These counts include compiler-generated members. New code includes `Blackbox*`, `CreativeTool*`, and vehicle-part infrastructure, as well as vegetation collection and terrain restoration. The presence of a type does not establish that its feature is exposed in the current game UI.
|
||||
|
||||
## Compatibility changes
|
||||
|
||||
| Area | Native change | Mod adaptation |
|
||||
| --- | --- | --- |
|
||||
| Terrain tools | `BuildTool_Reform.ReformAction` is removed. Brush input and range checks move to `ExecuteBrushAction`; execution splits into `DoFlattenExecute` and `DoRestoreExecute`. | Retarget UXAssist's range and brush-limit patches. Allocate sufficient preview buffers for 30 x 30 brushes before preparing either terrain operation. Clamp active brushes on disable and oversized saved brushes on restore when the feature is inactive. |
|
||||
| Terraform anyway | Foundation placement and Restore Terrain now have separate soil deductions. | Bypass the foundation-count check in `DoFlattenExecute`. Clamp positive soil costs to the available balance in both execution methods, while retaining negative costs that award soil. Leave native terrain restoration and foundation refunds intact. |
|
||||
| Globe-view actions | `EViewMode.Create` shifts subsequent enum values: Globe is now 4 and Starmap is 5. | Match and emit named enum values. Extend the movement/mining camera-conflict getter results rather than relying on local-variable positions. |
|
||||
| Ray Receiver inventory | Stored catalysts move from accumulated `catalystPoint`/`catalystIncPoint` values to `catalystCount`/`catalystInc`. `catalystPoint` becomes the active catalyst's remaining lifetime. | Apply the configured buffer limit to the stored item count without multiplying by 3,600. Planet initialization returns stored catalysts and their proliferation points, matching native item take-back semantics. |
|
||||
| Mineral exhaustion | `NotifyVeinExhausted` gains `hasMinerLostAllVeins` and honors the new alert preference. | Determine whether a miner loses its last vein before removing the vein. Pass that result to the notification; oil depletion passes false, as in the native implementation. |
|
||||
| Handcrafting counts | Native Shift-click shortcuts bypass the old increment/decrement path. | Replace the count-button handlers while enhanced count control is enabled. Preserve normal steps of 1, Ctrl steps of 10, Shift steps of 100, Alt steps of 1,000, and the 1–1,000 bounds. |
|
||||
| Soil-change tips | `Player.SetSandCount` now updates soil progression before notifying subscribers. | Suppress `UIGame.OnSandCountChanged` instead of returning early from the player setter. Native progression and other subscribers remain intact. |
|
||||
| Batch technology buyout | The technology UI changes local-variable layout and adds prerequisite checks to buyout visibility. | Replace the visibility expression with a semantic predicate for locked, non-hidden, non-obsolete technologies. Preserve the native metadata toggle, sandbox exclusion, and surrounding selected/researching state handling. |
|
||||
|
||||
Affected transpilers use guarded matching and return the original instructions if their required pattern is absent. The mods now target the new terrain API; this is not a dual-version compatibility layer for 0.10.34.
|
||||
|
||||
## Validation
|
||||
|
||||
Both projects build in Release with zero warnings and zero errors after refreshing the game references:
|
||||
|
||||
```powershell
|
||||
dotnet build UpdateGameDlls/UpdateGameDlls.csproj
|
||||
dotnet build UXAssist/UXAssist.csproj -c Release --no-restore
|
||||
dotnet build CheatEnabler/CheatEnabler.csproj -c Release --no-restore
|
||||
git diff --check
|
||||
```
|
||||
|
||||
An ignored standalone check harness in `obj/dsp-compat/` reads the original game DLL and uses the repository's HarmonyX/BepInEx dependencies without installing game detours. It checks:
|
||||
|
||||
- 116 prefix/postfix target and parameter bindings.
|
||||
- 187 transpiler applications: 183 transformations and 4 unchanged results that also occur with the previous DLL. No target, matcher, branch-label, or operand checks fail.
|
||||
- 55 behavior assertions covering handcrafting modifiers, brush bounds and buffer reuse, disabled-feature save restoration, soil shortages and gains, buyout visibility, UI-only soil-tip suppression, and missing-pattern fallbacks.
|
||||
- The two `ExecuteBrushAction` transpilers compose in either order; these assertions are included in the behavior count.
|
||||
|
||||
These automated checks do not verify native detour installation or Unity rendering/input behavior. The user also confirmed that testing passed. Mod versions and package manifests are not changed; the changelog entries remain unreleased.
|
||||
|
||||
## In-game smoke checks
|
||||
|
||||
Use a disposable copy of a save for destructive reset/refund and mineral-depletion checks.
|
||||
|
||||
1. Test foundation placement and Restore Terrain with brush sizes 1, 10, 11, and 30, including line drawing. Disable expanded brushes and reload a save made with a large brush.
|
||||
2. Enable Terraform anyway with insufficient foundations and soil. Check foundation placement, terrain restoration, blueprint foundations, and base-pit removal. Soil must stay nonnegative, and soil gains and native refunds must remain available.
|
||||
3. Feed a Ray Receiver proliferated catalysts, check the configured buffer limit, and verify stored catalyst refunds through planet initialization on the disposable save.
|
||||
4. Exercise the mineral-exhaustion alert modes, globe-view movement/mining, and normal/Ctrl/Shift/Alt handcrafting count changes.
|
||||
5. Check batch buyout with missing prerequisites and verify hidden, obsolete, and already-unlocked technologies remain excluded. Hide soil tips and confirm soil-related progression still advances.
|
||||
Reference in new issue
Block a user