From 61811f9a8c01833f071c25a6d70a6bbdb155deb4 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Wed, 29 Oct 2025 21:51:52 +0800 Subject: [PATCH] crash fix --- LogisticHub/Module/Miner.cs | 4 ++-- LogisticHub/README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LogisticHub/Module/Miner.cs b/LogisticHub/Module/Miner.cs index 23b91ef..13856d2 100644 --- a/LogisticHub/Module/Miner.cs +++ b/LogisticHub/Module/Miner.cs @@ -124,7 +124,7 @@ public class Miner : PatchImpl [HarmonyPrefix] [HarmonyPatch(typeof(GameLogic), nameof(GameLogic.OnFactoryFrameBegin))] - private static void GameData_GameTick_Prefix() + private static void GameLogic_OnFactoryFrameBegin_Prefix() { var main = GameMain.instance; if (main.isMenuDemo) return; @@ -139,7 +139,7 @@ public class Miner : PatchImpl DeepProfiler.BeginSample(DPEntry.Miner); var data = GameMain.data; - if (data.factoryCount > _mineIndex.Length) + if (_mineIndex == null || data.factoryCount > _mineIndex.Length) Array.Resize(ref _mineIndex, data.factoryCount); var factoryStatPool = GameMain.statistics.production.factoryStatPool; for (var factoryIndex = data.factoryCount - 1; factoryIndex >= 0; factoryIndex--) diff --git a/LogisticHub/README.md b/LogisticHub/README.md index a3d9a65..35ec748 100644 --- a/LogisticHub/README.md +++ b/LogisticHub/README.md @@ -6,7 +6,7 @@ ## Usage * Miner(and fuel burning) functions - +Inspired by [PlanetMiner](https://dsp.thunderstore.io/package/blacksnipebiu/PlanetMiner)([github](https://github.com/blacksnipebiu/PlanetMiner)) + + Inspired by [PlanetMiner](https://dsp.thunderstore.io/package/blacksnipebiu/PlanetMiner)([github](https://github.com/blacksnipebiu/PlanetMiner)) But it is heavily optimized to resolve performance, accuracy and other issues in PlanetMiner. + (Optimization to PlanetMiner) Only recalculate count of veins when vein chunks are changed (added/removed by foundations/Sandbox-Mode, or exhausted), so this removes Dictionary allocation on each planet for every frame. + (Optimization to PlanetMiner) More accurate frame counting by use float number.