From a9a6b98f99dae05e3c037cbd403f74b15458f700 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 22 Mar 2025 22:41:16 +1100 Subject: [PATCH] Fix alerts mispredict + log spam (#36004) tstalker alerted me to it and noticed the classic case of shallow copies. --- Content.Client/Alerts/ClientAlertsSystem.cs | 2 +- Content.Server/Alert/ServerAlertsSystem.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Content.Client/Alerts/ClientAlertsSystem.cs b/Content.Client/Alerts/ClientAlertsSystem.cs index c5ec254c0c..b77bc9e4bc 100644 --- a/Content.Client/Alerts/ClientAlertsSystem.cs +++ b/Content.Client/Alerts/ClientAlertsSystem.cs @@ -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); } diff --git a/Content.Server/Alert/ServerAlertsSystem.cs b/Content.Server/Alert/ServerAlertsSystem.cs index 5af2b06218..cf15265561 100644 --- a/Content.Server/Alert/ServerAlertsSystem.cs +++ b/Content.Server/Alert/ServerAlertsSystem.cs @@ -14,6 +14,7 @@ internal sealed class ServerAlertsSystem : AlertsSystem private void OnGetState(Entity 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)); } }