]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix alerts mispredict + log spam (#36004)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sat, 22 Mar 2025 11:41:16 +0000 (22:41 +1100)
committerGitHub <noreply@github.com>
Sat, 22 Mar 2025 11:41:16 +0000 (12:41 +0100)
tstalker alerted me to it and noticed the classic case of shallow copies.

Content.Client/Alerts/ClientAlertsSystem.cs
Content.Server/Alert/ServerAlertsSystem.cs

index c5ec254c0ccc5e05b1209480675a63d3cb9edddb..b77bc9e4bcdc4bea2f77924bedc107e530423bbb 100644 (file)
@@ -52,7 +52,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
         if (args.Current is not AlertComponentState cast)
             return;
 
-        alerts.Comp.Alerts = cast.Alerts;
+        alerts.Comp.Alerts = new(cast.Alerts);
 
         UpdateHud(alerts);
     }
index 5af2b0621883ba616d43d5decb6ec1abc3580301..cf15265561dd1ba860e52dbd7ab477b5fe3e5902 100644 (file)
@@ -14,6 +14,7 @@ internal sealed class ServerAlertsSystem : AlertsSystem
 
     private void OnGetState(Entity<AlertsComponent> alerts, ref ComponentGetState args)
     {
-        args.State = new AlertComponentState(alerts.Comp.Alerts);
+        // TODO: Use sourcegen when clone-state bug fixed.
+        args.State = new AlertComponentState(new(alerts.Comp.Alerts));
     }
 }