1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-03-28 13:47:19 +08:00

Fix potential bugs in UXAssist and CheatEnabler

UXAssist:
- PlanetFunctions: fix infinite loop in constructStats cleanup (i++ -> i--)
- PlanetFunctions: skip entityPool slot 0 (sentinel) in DismantleAll foreach
- PlanetFunctions: fix belt buffer walk infinite loop when buffer[j]==250,
  add cargoPool bounds check
- FactoryPatch: fix UnfixProto guard condition (< 3 -> < PowerPoleIds.Length)
- FactoryPatch: fix Array.Resize(index*2) -> (index+1)*2 to handle index==0
- LogisticsPatch: fix UpdateStorageMax early-exit to check both local and remote
- LogisticsPatch: fix storage max scan to use Math.Max instead of last-write
- LogisticsPatch: add divide-by-zero guard in station storage ratio calculation
- LogisticsPatch: fix station entry right-click delegates using per-instance
  dictionary instead of shared static array to prevent unsubscribe mismatch
- LogisticsPatch: add null checks for GameObject.Find results in InitGUI
- GamePatch: log exception in previously empty catch block
- GameLogic: invoke event handlers individually with try/catch so one failing
  subscriber does not abort subsequent ones
- DysonSpherePatch/LogisticsPatch/PersistPatch/PlayerPatch: replace
  matcher.Labels = null with matcher.Labels = [] (5 sites)
- UIConfigWindow: remove duplicate I18N.Add for 'Outgoing integration count'
- UIConfigWindow: remove two orphaned y += 36f spacing increments

CheatEnabler:
- GamePatch: add null check for GameMain.gameScenario in AbnormalDisabler.OnEnable
- FactoryPatch: add null check for GameMain.mainPlayer in TakeTailItemsPatch
  and GetItemCountPatch
- FactoryPatch: add null check for GameMain.mainPlayer in
  ConstructionSystem_GameTick_Prefix
- FactoryPatch: fix _portalFrom.Remove(beltId) -> Remove(v) (wrong key)
- FactoryPatch: add null guard for GameMain.data before iterating factories
  in WindTurbinesPowerGlobalCoverage
- DysonSphereFunctions: fix shell pool rebuild loop writing all shells to
  slot 1 (id=1); now uses j+1 per iteration
- DysonSphereFunctions: replace GameMain.gameScenario.NotifyOnPlanDysonShell()
  with null-conditional call (?.) at 4 sites
- DysonSpherePatch: fix SkipAbsorbPatch/QuickAbsorbPatch sharing _instantAbsorb:
  OnDisable now recalculates the flag instead of unconditionally clearing it
- PlayerFunctions: add null check for GameMain.galaxy in TeleportToOuterSpace
- UIConfigWindow: add null guard in UpdateButtons before accessing button fields
- PlanetFunctions: add colliderId bounds check in BuryAllVeins
This commit is contained in:
2026-03-16 19:51:16 +08:00
parent e91271e137
commit f69a90d452
16 changed files with 116 additions and 62 deletions

View File

@@ -1542,7 +1542,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
private static void UnfixProto()
{
if (GetHarmony() == null || OldDragBuild.Count < 3 || DSPGame.IsMenuDemo) return;
if (GetHarmony() == null || OldDragBuild.Count < PowerPoleIds.Length || DSPGame.IsMenuDemo) return;
var i = 0;
foreach (var id in PowerPoleIds)
{
@@ -1860,7 +1860,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
if (index < 0) return null;
if (index >= _signalBelts.Length)
{
Array.Resize(ref _signalBelts, index * 2);
Array.Resize(ref _signalBelts, (index + 1) * 2);
}
else
{
@@ -2540,14 +2540,13 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
{
if (buffer[i] >= 246)
{
i += 250 - buffer[i];
var delta = 250 - buffer[i];
if (delta > 0) i += delta;
var index = buffer[i + 1] - 1 + (buffer[i + 2] - 1) * 100 + (buffer[i + 3] - 1) * 10000 + (buffer[i + 4] - 1) * 1000000;
ref var cargo = ref cargoPath.cargoContainer.cargoPool[index];
var item = cargo.item;
var stack = cargo.stack;
var inc = cargo.inc;
takeOutItems[item] = (takeOutItems.TryGetValue(item, out var value) ? value : 0)
+ ((long)stack | ((long)inc << 32));
+ ((long)cargo.stack | ((long)cargo.inc << 32));
Array.Clear(buffer, i - 4, 10);
i += 6;
if (cargoPath.updateLen < i) cargoPath.updateLen = i;