From ac3a91eac107637b962698527638e08716edaa17 Mon Sep 17 00:00:00 2001
From: EchoOfNothing <52498373+EchoOfNothing@users.noreply.github.com>
Date: Mon, 29 Dec 2025 10:53:18 +0200
Subject: [PATCH] Fix possible bug in my fix of IFF console. Add documentation
to HideOnInit. (#42122)
* Refactor OnIFFShow and OnInitIFFConsole by extracting AddAllSupportedIFFFlags method. Fix possible addition of unallowed flags.
Fix posible addition of unallowed flags in OnInitIFFConsole by performing AllowedFlags check in the extracted function.
* Add documentation to HideOnInit
* Update IFFConsoleComponent.cs
---------
Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>
---
.../Components/IFFConsoleComponent.cs | 3 ++
.../Shuttles/Systems/ShuttleSystem.IFF.cs | 44 +++++++++++--------
2 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/Content.Server/Shuttles/Components/IFFConsoleComponent.cs b/Content.Server/Shuttles/Components/IFFConsoleComponent.cs
index 8db81dc1fd..c2cf913c2c 100644
--- a/Content.Server/Shuttles/Components/IFFConsoleComponent.cs
+++ b/Content.Server/Shuttles/Components/IFFConsoleComponent.cs
@@ -12,6 +12,9 @@ public sealed partial class IFFConsoleComponent : Component
[ViewVariables(VVAccess.ReadWrite), DataField("allowedFlags")]
public IFFFlags AllowedFlags = IFFFlags.HideLabel;
+ ///
+ /// If true, automatically applies all supported IFF flags to the console's grid on MapInitEvent.
+ ///
[DataField]
public bool HideOnInit = false;
}
diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.IFF.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.IFF.cs
index e8d2e13e80..738fb765e1 100644
--- a/Content.Server/Shuttles/Systems/ShuttleSystem.IFF.cs
+++ b/Content.Server/Shuttles/Systems/ShuttleSystem.IFF.cs
@@ -42,28 +42,14 @@ public sealed partial class ShuttleSystem
return;
}
- // Merged toggle controls both HideLabel and Hide flags
if (!args.Show)
{
- if ((component.AllowedFlags & IFFFlags.HideLabel) != 0x0)
- {
- AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
- }
- if ((component.AllowedFlags & IFFFlags.Hide) != 0x0)
- {
- AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
- }
+ AddAllSupportedIFFFlags(xform, component);
}
else
{
- if ((component.AllowedFlags & IFFFlags.HideLabel) != 0x0)
- {
- RemoveIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
- }
- if ((component.AllowedFlags & IFFFlags.Hide) != 0x0)
- {
- RemoveIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
- }
+ RemoveIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
+ RemoveIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
}
}
@@ -76,8 +62,7 @@ public sealed partial class ShuttleSystem
if (component.HideOnInit)
{
- AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
- AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
+ AddAllSupportedIFFFlags(xform, component);
}
}
@@ -121,4 +106,25 @@ public sealed partial class ShuttleSystem
});
}
}
+
+ // Made this method to avoid copy and pasting.
+ ///
+ /// Adds all IFF flags that are allowed by AllowedFlags to the grid.
+ ///
+ private void AddAllSupportedIFFFlags(TransformComponent xform, IFFConsoleComponent component)
+ {
+ if (xform.GridUid == null)
+ {
+ return;
+ }
+
+ if ((component.AllowedFlags & IFFFlags.HideLabel) != 0x0)
+ {
+ AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
+ }
+ if ((component.AllowedFlags & IFFFlags.Hide) != 0x0)
+ {
+ AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
+ }
+ }
}
--
2.52.0