mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-08 20:13:29 +08:00
fix crashes
This commit is contained in:
@@ -148,15 +148,19 @@ public class Miner : PatchImpl<Miner>
|
|||||||
var planetTransport = factory.transport;
|
var planetTransport = factory.transport;
|
||||||
var productRegister = factoryStatPool[factoryIndex]?.productRegister;
|
var productRegister = factoryStatPool[factoryIndex]?.productRegister;
|
||||||
var demands = stations.StorageIndices[1];
|
var demands = stations.StorageIndices[1];
|
||||||
|
if (demands == null) continue;
|
||||||
foreach (var (itemIndex, itemId) in VeinList)
|
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];
|
var station = planetTransport.stationPool[storageIndex / 100];
|
||||||
if (station == null)
|
if (station == null)
|
||||||
continue;
|
continue;
|
||||||
ref var storage = ref station.storage[storageIndex % 100];
|
ref var storage = ref station.storage[storageIndex % 100];
|
||||||
|
if (storage.count >= storage.max) continue;
|
||||||
int amount;
|
int amount;
|
||||||
long energyConsume;
|
long energyConsume;
|
||||||
var miningScale = MiningScale.Value;
|
var miningScale = MiningScale.Value;
|
||||||
@@ -164,7 +168,6 @@ public class Miner : PatchImpl<Miner>
|
|||||||
{
|
{
|
||||||
miningScale = _advancedMiningMachineUnlocked ? 300 : 100;
|
miningScale = _advancedMiningMachineUnlocked ? 300 : 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (miningScale > 100 && storage.count * 2 > storage.max)
|
if (miningScale > 100 && storage.count * 2 > storage.max)
|
||||||
{
|
{
|
||||||
miningScale = 100 + ((miningScale - 100) * (storage.max - storage.count) * 2 + storage.max - 1) / storage.max;
|
miningScale = 100 + ((miningScale - 100) * (storage.max - storage.count) * 2 + storage.max - 1) / storage.max;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class PlanetStations
|
|||||||
|
|
||||||
public void AddStationStorage(bool demand, int id, int stationId, int storageIdx)
|
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];
|
var stations = StorageIndices[demand ? 1 : 0];
|
||||||
if (stations == null || id >= stations.Length)
|
if (stations == null || id >= stations.Length)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user