From b4a5399ad40aacb6db153640368869d12ab87aa5 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 19 May 2024 13:54:52 +1200 Subject: [PATCH] Modify battery assert to avoid floating point errors (#28007) --- Content.Server/Power/Pow3r/BatteryRampPegSolver.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Content.Server/Power/Pow3r/BatteryRampPegSolver.cs b/Content.Server/Power/Pow3r/BatteryRampPegSolver.cs index 5d52bde377..0afd86679b 100644 --- a/Content.Server/Power/Pow3r/BatteryRampPegSolver.cs +++ b/Content.Server/Power/Pow3r/BatteryRampPegSolver.cs @@ -240,7 +240,8 @@ namespace Content.Server.Power.Pow3r } } - if (unmet <= 0 || totalBatterySupply <= 0) + // Return if normal supplies met all demand or there are no supplying batteries + if (unmet <= 0 || totalMaxBatterySupply <= 0) return; // Target output capacity for batteries @@ -275,8 +276,8 @@ namespace Content.Server.Power.Pow3r battery.SupplyRampTarget = battery.MaxEffectiveSupply * relativeTargetBatteryOutput - battery.CurrentReceiving * battery.Efficiency; - DebugTools.Assert(battery.SupplyRampTarget + battery.CurrentReceiving * battery.Efficiency <= battery.LoadingNetworkDemand - || MathHelper.CloseToPercent(battery.SupplyRampTarget + battery.CurrentReceiving * battery.Efficiency, battery.LoadingNetworkDemand, 0.001)); + DebugTools.Assert(battery.MaxEffectiveSupply * relativeTargetBatteryOutput <= battery.LoadingNetworkDemand + || MathHelper.CloseToPercent(battery.MaxEffectiveSupply * relativeTargetBatteryOutput, battery.LoadingNetworkDemand, 0.001)); } } -- 2.51.2