diff --git a/LogisticHub/Module/Miner.cs b/LogisticHub/Module/Miner.cs index 3141ef8..364160f 100644 --- a/LogisticHub/Module/Miner.cs +++ b/LogisticHub/Module/Miner.cs @@ -148,15 +148,19 @@ public class Miner : PatchImpl var planetTransport = factory.transport; var productRegister = factoryStatPool[factoryIndex]?.productRegister; var demands = stations.StorageIndices[1]; + if (demands == null) continue; foreach (var (itemIndex, itemId) in VeinList) { - foreach (var storageIndex in demands[itemIndex]) + if (itemIndex >= demands.Length) continue; + var demandList = demands[itemIndex]; + if (demandList == null) continue; + foreach (var storageIndex in demandList) { - LogisticHub.Logger.LogDebug($"StorageIndex: {storageIndex}"); var station = planetTransport.stationPool[storageIndex / 100]; if (station == null) continue; ref var storage = ref station.storage[storageIndex % 100]; + if (storage.count >= storage.max) continue; int amount; long energyConsume; var miningScale = MiningScale.Value; @@ -164,7 +168,6 @@ public class Miner : PatchImpl { miningScale = _advancedMiningMachineUnlocked ? 300 : 100; } - if (miningScale > 100 && storage.count * 2 > storage.max) { miningScale = 100 + ((miningScale - 100) * (storage.max - storage.count) * 2 + storage.max - 1) / storage.max; diff --git a/LogisticHub/Module/StationManager.cs b/LogisticHub/Module/StationManager.cs index 8b75631..1ed1ab1 100644 --- a/LogisticHub/Module/StationManager.cs +++ b/LogisticHub/Module/StationManager.cs @@ -12,6 +12,7 @@ public class PlanetStations public void AddStationStorage(bool demand, int id, int stationId, int storageIdx) { + LogisticHub.Logger.LogDebug($"AddStationStorage: demand={demand}, id={id}, stationId={stationId}, storageIdx={storageIdx}"); var stations = StorageIndices[demand ? 1 : 0]; if (stations == null || id >= stations.Length) {