1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-08 18:53:29 +08:00

fix crashes

This commit is contained in:
2025-10-30 00:12:47 +08:00
parent c99c59a117
commit 8d5bb140e1
2 changed files with 7 additions and 3 deletions

View File

@@ -148,15 +148,19 @@ public class Miner : PatchImpl<Miner>
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<Miner>
{
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;

View File

@@ -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)
{