From ebdd6e817cb59a8610d8bf9627b155a033cac977 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Thu, 23 Dec 2021 01:21:57 +0100 Subject: [PATCH] Use float.IsFinite in some appropriate places previously using IsNan || IsInfinity --- Content.Server/Atmos/GasMixture.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Content.Server/Atmos/GasMixture.cs b/Content.Server/Atmos/GasMixture.cs index bafb44608f..4a3700f77b 100644 --- a/Content.Server/Atmos/GasMixture.cs +++ b/Content.Server/Atmos/GasMixture.cs @@ -116,7 +116,7 @@ namespace Content.Server.Atmos [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetMoles(int gasId, float quantity) { - if (float.IsInfinity(quantity) || float.IsNaN(quantity) || float.IsNegative(quantity)) + if (!float.IsFinite(quantity) || float.IsNegative(quantity)) throw new ArgumentException($"Invalid quantity \"{quantity}\" specified!", nameof(quantity)); if (!Immutable) @@ -134,14 +134,14 @@ namespace Content.Server.Atmos { if (!Immutable) { - if (float.IsInfinity(quantity) || float.IsNaN(quantity)) + if (!float.IsFinite(quantity)) throw new ArgumentException($"Invalid quantity \"{quantity}\" specified!", nameof(quantity)); Moles[gasId] += quantity; var moles = Moles[gasId]; - if (float.IsInfinity(moles) || float.IsNaN(moles) || float.IsNegative(moles)) + if (!float.IsFinite(moles) || float.IsNegative(moles)) throw new Exception($"Invalid mole quantity \"{moles}\" in gas Id {gasId} after adjusting moles with \"{quantity}\"!"); } }