]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix VGRoid grid spam (#29946)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sat, 27 Jul 2024 01:54:38 +0000 (11:54 +1000)
committerGitHub <noreply@github.com>
Sat, 27 Jul 2024 01:54:38 +0000 (11:54 +1000)
Specifically if a grid splits under the cvar size it doesn't get a label. This also stops stuff like shuttles splitting in half creating new entries for the new grids. Splitting code leaves the largest grid as the existing one so this will always prefer to keep it large (but if there's multiple splits it won't adjust).

Content.Server/Shuttles/Systems/ShuttleSystem.IFF.cs
Content.Shared/CCVar/CCVars.cs

index ed5d109e852e054f64b864202ca1f53b27ae91d4..5e746fd49538ddba6cb96918a6d09c06a0681f1a 100644 (file)
@@ -1,4 +1,5 @@
 using Content.Server.Shuttles.Components;
+using Content.Shared.CCVar;
 using Content.Shared.Shuttles.BUIStates;
 using Content.Shared.Shuttles.Components;
 using Content.Shared.Shuttles.Events;
@@ -12,6 +13,26 @@ public sealed partial class ShuttleSystem
         SubscribeLocalEvent<IFFConsoleComponent, AnchorStateChangedEvent>(OnIFFConsoleAnchor);
         SubscribeLocalEvent<IFFConsoleComponent, IFFShowIFFMessage>(OnIFFShow);
         SubscribeLocalEvent<IFFConsoleComponent, IFFShowVesselMessage>(OnIFFShowVessel);
+        SubscribeLocalEvent<GridSplitEvent>(OnGridSplit);
+    }
+
+    private void OnGridSplit(ref GridSplitEvent ev)
+    {
+        var splitMass = _cfg.GetCVar(CCVars.HideSplitGridsUnder);
+
+        if (splitMass < 0)
+            return;
+
+        foreach (var grid in ev.NewGrids)
+        {
+            if (!_physicsQuery.TryGetComponent(grid, out var physics) ||
+                physics.Mass > splitMass)
+            {
+                continue;
+            }
+
+            AddIFFFlag(grid, IFFFlags.HideLabel);
+        }
     }
 
     private void OnIFFShow(EntityUid uid, IFFConsoleComponent component, IFFShowIFFMessage args)
index a0e9157e922d9c1388ed11004ff23a4458ecd88f..082d9c80338bebeb0fa2088ca61d066b229e6d8b 100644 (file)
@@ -1495,6 +1495,13 @@ namespace Content.Shared.CCVar
         public static readonly CVarDef<bool> GodmodeArrivals =
             CVarDef.Create("shuttle.godmode_arrivals", false, CVar.SERVERONLY);
 
+        /// <summary>
+        /// If a grid is split then hide any smaller ones under this mass (kg) from the map.
+        /// This is useful to avoid split grids spamming out labels.
+        /// </summary>
+        public static readonly CVarDef<int> HideSplitGridsUnder =
+            CVarDef.Create("shuttle.hide_split_grids_under", 30, CVar.SERVERONLY);
+
         /// <summary>
         /// Whether to automatically spawn escape shuttles.
         /// </summary>