mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
fix(uxassist): prevent mining speed corruption with extended power
Keep the extended mining-speed calculation integer-valued so the native handler writes a valid speed. Guard the complete native arithmetic pattern and document the slider range and recovery steps.
This commit is contained in:
1 parent
0015c16f0c
commit
a7ddb395b2
4 files changed
+35
-17
No files matched your search
@@ -4,6 +4,7 @@
|
||||
## Changlog
|
||||
|
||||
* 1.6.2 - Unrelease
|
||||
* `Increase maximum power usage in Logistic Stations and Advanced Mining Machines`: Fix zero or corrupted mining speeds when adjusting an Advanced Mining Machine's speed slider with the option enabled.
|
||||
* `Tweak building buffers`: Restore the Ray Receiver Graviton Lens buffer setting on DSP 0.10.35.29104 and later, and correct the displayed native buffer value to 2.
|
||||
* `Drag building power poles`: Fix invalid alternating previews when enabling the option after loading a save, and restore original spacing when disabling it.
|
||||
* Close building and belt hover popups when opening the pause menu so they cannot obscure menu controls.
|
||||
@@ -434,6 +435,7 @@
|
||||
## 更新日志
|
||||
|
||||
* 1.6.2 - Unreleased
|
||||
* `提升物流塔和大型采矿机的最大功耗`:修复启用后调整大型采矿机开采速度时出现 0% 或异常速度的问题。
|
||||
* `调整建筑输入缓冲`:修复 DSP 0.10.35.29104 及后续版本中射线接收器透镜缓冲设置不生效的问题,并将显示的游戏原始值更正为 2。
|
||||
* `拖建电线杆`:修复载入存档后才启用功能时交替放置的预览异常,并在关闭时恢复原有间距。
|
||||
* 打开暂停菜单时关闭建筑和传送带的悬浮提示,避免提示遮挡菜单。
|
||||
|
||||
@@ -8,6 +8,7 @@ using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.GameConstants;
|
||||
using UXAssist.Common.Patching;
|
||||
|
||||
namespace UXAssist.Patches.Logistics;
|
||||
|
||||
@@ -360,32 +361,38 @@ internal class GreaterPowerUsageInLogistics : PatchImpl<GreaterPowerUsageInLogis
|
||||
}
|
||||
// Harmony transpiler: UIStationWindow_OnMaxMiningSpeedChange_Transpiler
|
||||
// Target: UIStationWindow.OnMaxMiningSpeedChange
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
// Fallback: Return the original instructions if the native mining-speed calculation is not found.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UIStationWindow), nameof(UIStationWindow.OnMaxMiningSpeedChange))]
|
||||
private static IEnumerable<CodeInstruction> UIStationWindow_OnMaxMiningSpeedChange_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
var original = instructions.ToList();
|
||||
var matcher = new CodeMatcher(original, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4 && ci.OperandIs(LogisticsConstants.MinMiningSpeedBase)),
|
||||
new CodeMatch(OpCodes.Ldarg_1)
|
||||
new CodeMatch(ci => ci.LoadsConstant(LogisticsConstants.MinMiningSpeedBase)),
|
||||
new CodeMatch(OpCodes.Ldarg_1),
|
||||
new CodeMatch(OpCodes.Ldc_R4, 0.5f),
|
||||
new CodeMatch(OpCodes.Add),
|
||||
new CodeMatch(OpCodes.Conv_I4),
|
||||
new CodeMatch(ci => ci.LoadsConstant(LogisticsConstants.MiningSpeedFineStep)),
|
||||
new CodeMatch(OpCodes.Mul),
|
||||
new CodeMatch(OpCodes.Add),
|
||||
new CodeMatch(ci => ci.IsStloc())
|
||||
);
|
||||
var pos = matcher.Pos;
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Stloc_1)
|
||||
);
|
||||
var pos2 = matcher.Pos;
|
||||
matcher.Start().Advance(pos);
|
||||
var labels = matcher.Labels;
|
||||
matcher.RemoveInstructions(pos2 - pos);
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(original, UXAssist.Logger, nameof(UIStationWindow_OnMaxMiningSpeedChange_Transpiler));
|
||||
var loadValue = new CodeInstruction(OpCodes.Ldarg_1).WithLabels(matcher.Labels);
|
||||
loadValue.blocks.AddRange(matcher.Instruction.blocks);
|
||||
matcher.RemoveInstructions(8);
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_1).WithLabels(labels),
|
||||
Transpilers.EmitDelegate((float value) =>
|
||||
loadValue,
|
||||
Transpilers.EmitDelegate<Func<float, int>>(value =>
|
||||
{
|
||||
var intval = (int)(value + 0.5f);
|
||||
if (intval <= LogisticsConstants.MiningSpeedSliderMaxDefault)
|
||||
var defaultMax = (int)LogisticsConstants.MiningSpeedSliderMaxDefault;
|
||||
if (intval <= defaultMax)
|
||||
return intval * LogisticsConstants.MiningSpeedFineStep + LogisticsConstants.MinMiningSpeedBase;
|
||||
return (intval - LogisticsConstants.MiningSpeedSliderMaxDefault) * LogisticsConstants.MiningSpeedCoarseStep + LogisticsConstants.MaxMiningSpeedBase;
|
||||
return (intval - defaultMax) * LogisticsConstants.MiningSpeedCoarseStep + LogisticsConstants.MaxMiningSpeedBase;
|
||||
})
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
|
||||
@@ -104,6 +104,8 @@
|
||||
* `Ejector Solar Sails buffer count`: Range 5-400 (step by 5); the game's original buffer holds 20
|
||||
* `Silo Rockets buffer count`: Range 1-40; the game's original buffer holds 20
|
||||
* Logistics
|
||||
* Increase maximum power usage in Logistic Stations and Advanced Mining Machines
|
||||
* Extend the Advanced Mining Machine's speed slider from 100%–300% to 100%–1,000%, retaining 10-percentage-point steps through 300% and using 100-percentage-point steps above it.
|
||||
* Enhanced control for logistic storage capacities
|
||||
* Logistic storage capacities are not scaled on upgrading `Logistics Carrier Capacity`, if they are not set to maximum capacity or already greater than maximum capacity.
|
||||
* You can use arrow keys to adjust logistic storage capacities gracefully.
|
||||
@@ -294,6 +296,8 @@
|
||||
* `弹射太阳帆缓冲区数量`:范围 5 至 400(步进值为 5);游戏原始缓冲数量为 20
|
||||
* `发射井火箭缓冲区数量`:范围 1 至 40;游戏原始缓冲数量为 20
|
||||
* 物流
|
||||
* 提升物流塔和大型采矿机的最大功耗
|
||||
* 将大型采矿机开采速度滑条的范围从 100%–300% 扩展为 100%–1,000%;300% 以内每档增加 10 个百分点,之后每档增加 100 个百分点。
|
||||
* 物流塔存储数量限制控制改进
|
||||
* 当升级`运输机舱扩容`时,不会对各种物流塔的存储限制按比例提升,除非设置为最大允许容量或者已经超过升级后的最大容量。
|
||||
* 你可以使用方向键微调物流塔存储限制
|
||||
|
||||
@@ -11,7 +11,7 @@ Method bodies and metadata come from the original `DSPGAME_Data/Managed/Assembly
|
||||
|
||||
Versions come from each installation's `Updates/Versions.txt` and the installed `appmanifest_1366540.acf`. `AssemblyFromGame/Assembly-CSharp.dll` is refreshed only for compilation.
|
||||
|
||||
## Findings and fix
|
||||
## Findings and fixes
|
||||
|
||||
The native assembly has 67 changed method bodies, 11 added fields, 3 removed fields, and two replaced method signatures. No types are added or removed. Eight changed methods are directly targeted by maintained mod patches:
|
||||
|
||||
@@ -31,6 +31,10 @@ The fix replaces the integer constant in the current catalyst-count comparison w
|
||||
|
||||
The bilingual help text and README now show the native threshold as **2**. UXAssist's existing **1.6.2** unreleased changelog includes the fix; mod versions are unchanged.
|
||||
|
||||
A subsequent mining-speed regression check finds an existing type error in `Increase maximum power usage in Logistic Stations and Advanced Mining Machines`. A floating-point slider constant makes the injected conversion delegate return `Single`, but native `OnMaxMiningSpeedChange` stores that result in an `Int32` local and then in `MinerComponent.speed`. This invalid IL corrupts the actual speed, rather than only its displayed percentage. A check using the original handler and the pre-fix package DLL reproduces invalid integer values; the exact result of the invalid IL depends on the runtime.
|
||||
|
||||
The conversion now explicitly returns `Int32`, preserves native rounding, and retains 100%–300% in 10-percentage-point steps and 400%–1,000% in 100-percentage-point steps. Its transpiler matches the complete native calculation without depending on a fixed local slot and returns the original instructions when that calculation is absent. For miners whose speed has already been corrupted, adjust the slider after installing the fix; the previous intended setting cannot be recovered reliably from the corrupted value.
|
||||
|
||||
LiveStreamAssist's offline text generator also fails on both game versions because it asks the type-tree generator for the removed `CreationPartProtoSet`; the original DLL and asset script metadata contain `VehiclePartProtoSet`. Its extraction map now uses the current type while preserving the public `creationPart` dictionary group. Text and icons are regenerated from the current installation, including item 1211, technology 1509, recipe 162, signal 519, updated English guide text, and current localized vegetation names. The offline layers retain their existing behavior and make no WebSocket requests.
|
||||
|
||||
## Validation
|
||||
@@ -41,6 +45,7 @@ LiveStreamAssist's offline text generator also fails on both game versions becau
|
||||
- Dustbin's actual preloader injects the two expected Boolean fields into a temporary copy of the original game assembly; its mod checks pass against that copy.
|
||||
- The receiver regression check fails before the fix because configuration value 1 leaves the native threshold at 2. After the fix, 21 assertions pass on each game version, covering thresholds 1, 2, 7, and 20, below/equal/above boundaries, emitted comparison types, preservation of surrounding instructions, and missing-pattern fallback.
|
||||
- 55 existing behavior assertions pass, including terrain buffer bounds, soil guards, saved brush restoration, and composition of both `ExecuteBrushAction` transpilers in either order.
|
||||
- 75 mining-speed assertions pass. The check executes the original handler with the injected conversion against real game data types, replacing only the Unity text setter with a recording function. It verifies actual miner-speed assignments and displayed percentages, every slider position, rounding boundaries, reopening readback, native event/station guards, the unpatched path, and complete/partial missing-pattern fallbacks. This check covers the return/local type mismatch that the earlier structural transpiler checks did not detect.
|
||||
- LiveStreamAssist's text and icon generators succeed against the current original game files; the dictionary includes 175 items and 315 technologies. Repacking the JS bundle produces no source changes.
|
||||
- 42 JS client/query/text/overlay checks and the Python locale/format checks pass. The full JS suite also includes seven pre-existing dashboard failures: its `FakeQuery` omits `getClusterString`, which the unchanged dashboard calls. The same seven failures reproduce in an isolated copy of the files from `HEAD`. These tests use their own mocked text data, independent of the regenerated dictionary.
|
||||
- `git diff --check` passes.
|
||||
|
||||
Reference in new issue
Block a user