]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix gas filters (#41567)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Mon, 24 Nov 2025 16:01:38 +0000 (17:01 +0100)
committerGitHub <noreply@github.com>
Mon, 24 Nov 2025 16:01:38 +0000 (16:01 +0000)
fix gas filters

Content.Client/Atmos/UI/GasFilterBoundUserInterface.cs
Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs
Content.Shared/Atmos/Piping/Trinary/Components/SharedGasFilterComponent.cs

index 2b8020924cf3bbee16708a579ae336519a10f90b..ecaaca3005576fe58d667781702c650bd7e17b73 100644 (file)
@@ -52,14 +52,18 @@ namespace Content.Client.Atmos.UI
 
         private void OnSelectGasPressed()
         {
-            if (_window is null) return;
+            if (_window is null)
+                return;
+
             if (_window.SelectedGas is null)
             {
                 SendMessage(new GasFilterSelectGasMessage(null));
             }
             else
             {
-                if (!int.TryParse(_window.SelectedGas, out var gas)) return;
+                if (!Enum.TryParse<Gas>(_window.SelectedGas, out var gas))
+                    return;
+
                 SendMessage(new GasFilterSelectGasMessage(gas));
             }
         }
index 8d0fb8ad2cfd280ed039c871cda3b16a4dd05bd2..a889fd15b5ccdc996b6ca5c48f7b43dc5f2cb467 100644 (file)
@@ -156,18 +156,18 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
 
         private void OnSelectGasMessage(EntityUid uid, GasFilterComponent filter, GasFilterSelectGasMessage args)
         {
-            if (args.ID.HasValue)
+            if (args.Gas.HasValue)
             {
-                if (Enum.TryParse<Gas>(args.ID.ToString(), true, out var parsedGas))
+                if (Enum.IsDefined(typeof(Gas), args.Gas))
                 {
-                    filter.FilteredGas = parsedGas;
+                    filter.FilteredGas = args.Gas;
                     _adminLogger.Add(LogType.AtmosFilterChanged, LogImpact.Medium,
-                        $"{ToPrettyString(args.Actor):player} set the filter on {ToPrettyString(uid):device} to {parsedGas.ToString()}");
+                        $"{ToPrettyString(args.Actor):player} set the filter on {ToPrettyString(uid):device} to {args.Gas.ToString()}");
                     DirtyUI(uid, filter);
                 }
                 else
                 {
-                    Log.Warning($"{ToPrettyString(uid)} received GasFilterSelectGasMessage with an invalid ID: {args.ID}");
+                    Log.Warning($"{ToPrettyString(uid)} received GasFilterSelectGasMessage with an invalid ID: {args.Gas}");
                 }
             }
             else
index 947ad01e1bda4eb1f7757667affb57bdab242476..e6e1f85a389bfd474175993f04afc4093d4c64ee 100644 (file)
@@ -1,4 +1,6 @@
-using Robust.Shared.Serialization;
+using Content.Shared.Atmos.Prototypes;
+using Robust.Shared.Prototypes;
+using Robust.Shared.Serialization;
 
 namespace Content.Shared.Atmos.Piping.Trinary.Components
 {
@@ -48,13 +50,8 @@ namespace Content.Shared.Atmos.Piping.Trinary.Components
     }
 
     [Serializable, NetSerializable]
-    public sealed class GasFilterSelectGasMessage : BoundUserInterfaceMessage
+    public sealed class GasFilterSelectGasMessage(Gas? gas) : BoundUserInterfaceMessage
     {
-        public int? ID { get; }
-
-        public GasFilterSelectGasMessage(int? id)
-        {
-            ID = id;
-        }
+        public readonly Gas? Gas = gas;
     }
 }