diff --git a/Content.Server/Power/Pow3r/BatteryRampPegSolver.cs b/Content.Server/Power/Pow3r/BatteryRampPegSolver.cs index ec003daf95..e2399d8f77 100644 --- a/Content.Server/Power/Pow3r/BatteryRampPegSolver.cs +++ b/Content.Server/Power/Pow3r/BatteryRampPegSolver.cs @@ -194,7 +194,7 @@ namespace Content.Server.Power.Pow3r foreach (var batteryId in network.BatteryLoads) { var battery = state.Batteries[batteryId]; - if (!battery.Enabled || battery.DesiredPower == 0 || battery.Paused) + if (!battery.Enabled || battery.DesiredPower == 0 || battery.Paused || !battery.CanCharge) continue; battery.LoadingMarked = true; @@ -240,7 +240,7 @@ namespace Content.Server.Power.Pow3r foreach (var batteryId in network.BatterySupplies) { var battery = state.Batteries[batteryId]; - if (!battery.Enabled || battery.Paused) + if (!battery.Enabled || battery.Paused || !battery.CanDischarge) continue; battery.SupplyingMarked = true; diff --git a/Content.Server/Power/Pow3r/PowerState.cs b/Content.Server/Power/Pow3r/PowerState.cs index 5b9949a7f2..2b94af97b2 100644 --- a/Content.Server/Power/Pow3r/PowerState.cs +++ b/Content.Server/Power/Pow3r/PowerState.cs @@ -151,6 +151,7 @@ namespace Content.Server.Power.Pow3r slot.Generation = id.Generation; slot.Value = value; + slot.NextSlot = -1; } // Go through empty slots and build the free chain. @@ -159,7 +160,7 @@ namespace Content.Server.Power.Pow3r { ref var slot = ref storage._storage[i]; - if (slot.Generation != 0) + if (slot.NextSlot == -1) // Slot in use. continue; @@ -170,8 +171,7 @@ namespace Content.Server.Power.Pow3r storage.Count = cache.Length; storage._nextFree = nextFree; - // I think there is some issue with Pow3er's Save & Load to json leading to it constructing invalid GenIdStorages from json? - // If you get this error, clear out your data.json + // Sanity check for a former bug with save/load. DebugTools.Assert(storage.Values.Count() == storage.Count); return storage; diff --git a/Pow3r/Program.UI.cs b/Pow3r/Program.UI.cs index af14a36f90..aaa02f7135 100644 --- a/Pow3r/Program.UI.cs +++ b/Pow3r/Program.UI.cs @@ -237,6 +237,8 @@ namespace Pow3r Begin($"Battery {battery.Id}##Bat{battery.Id}"); Checkbox("Enabled", ref battery.Enabled); + Checkbox("CanDischarge", ref battery.CanDischarge); + Checkbox("CanCharge", ref battery.CanCharge); SliderFloat("Capacity", ref battery.Capacity, 0, 100000, "%.0f J"); SliderFloat("Max charge rate", ref battery.MaxChargeRate, 0, 1000, "%.0f W"); SliderFloat("Max supply", ref battery.MaxSupply, 0, 1000, "%.0f W");