From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 19 May 2024 01:54:52 +0000 (+1200) Subject: Modify battery assert to avoid floating point errors (#28007) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=b4a5399ad40aacb6db153640368869d12ab87aa5;p=space-station-14.git Modify battery assert to avoid floating point errors (#28007) --- 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)); } }