From f4ccfc5e35eca560826342167fbae091bb06eba0 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Mon, 6 Mar 2023 11:10:35 -0800 Subject: [PATCH] Fix access mispredicts when having a remote in hand (#14451) --- Content.Server/Access/Systems/AgentIDCardSystem.cs | 13 ++++++++----- Content.Server/Access/Systems/IdCardSystem.cs | 8 ++++++-- Content.Shared/Access/Systems/SharedAccessSystem.cs | 2 ++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Content.Server/Access/Systems/AgentIDCardSystem.cs b/Content.Server/Access/Systems/AgentIDCardSystem.cs index bf70cd75cc..118a29ba87 100644 --- a/Content.Server/Access/Systems/AgentIDCardSystem.cs +++ b/Content.Server/Access/Systems/AgentIDCardSystem.cs @@ -1,10 +1,9 @@ -using Content.Shared.Access.Components; using Content.Server.Access.Components; -using Content.Shared.Access.Systems; -using Content.Shared.Interaction; using Content.Server.Popups; using Content.Server.UserInterface; -using Robust.Shared.Player; +using Content.Shared.Access.Components; +using Content.Shared.Access.Systems; +using Content.Shared.Interaction; using Robust.Server.GameObjects; namespace Content.Server.Access.Systems @@ -42,11 +41,15 @@ namespace Content.Server.Access.Systems _popupSystem.PopupEntity(Loc.GetString("agent-id-no-new", ("card", args.Target)), args.Target.Value, args.User); return; } - else if (addedLength == 1) + + Dirty(access); + + if (addedLength == 1) { _popupSystem.PopupEntity(Loc.GetString("agent-id-new-1", ("card", args.Target)), args.Target.Value, args.User); return; } + _popupSystem.PopupEntity(Loc.GetString("agent-id-new", ("number", addedLength), ("card", args.Target)), args.Target.Value, args.User); } diff --git a/Content.Server/Access/Systems/IdCardSystem.cs b/Content.Server/Access/Systems/IdCardSystem.cs index de8f707ccf..cebc23aca2 100644 --- a/Content.Server/Access/Systems/IdCardSystem.cs +++ b/Content.Server/Access/Systems/IdCardSystem.cs @@ -1,3 +1,4 @@ +using System.Linq; using Content.Server.Administration.Logs; using Content.Server.Kitchen.Components; using Content.Server.Popups; @@ -6,10 +7,8 @@ using Content.Shared.Access.Components; using Content.Shared.Access.Systems; using Content.Shared.Database; using Content.Shared.Popups; -using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; -using System.Linq; namespace Content.Server.Access.Systems { @@ -57,7 +56,10 @@ namespace Content.Server.Access.Systems if (randomPick <= 0.25f) { _popupSystem.PopupEntity(Loc.GetString("id-card-component-microwave-bricked", ("id", uid)), uid); + access.Tags.Clear(); + Dirty(access); + _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(args.Microwave)} cleared access on {ToPrettyString(uid):entity}"); } @@ -68,7 +70,9 @@ namespace Content.Server.Access.Systems // Give them a wonderful new access to compensate for everything var random = _random.Pick(_prototypeManager.EnumeratePrototypes().ToArray()); + access.Tags.Add(random.ID); + Dirty(access); _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(args.Microwave)} added {random.ID} access to {ToPrettyString(uid):entity}"); diff --git a/Content.Shared/Access/Systems/SharedAccessSystem.cs b/Content.Shared/Access/Systems/SharedAccessSystem.cs index efa062692a..85b1cbe37c 100644 --- a/Content.Shared/Access/Systems/SharedAccessSystem.cs +++ b/Content.Shared/Access/Systems/SharedAccessSystem.cs @@ -48,6 +48,7 @@ namespace Content.Shared.Access.Systems continue; component.Tags.UnionWith(proto.Tags); + Dirty(component); } } @@ -111,6 +112,7 @@ namespace Content.Shared.Access.Systems access.Tags.Clear(); access.Tags.UnionWith(prototype.Access); + Dirty(access); TryAddGroups(uid, prototype.AccessGroups, access); -- 2.52.0