From 5e74afc72c743e30fcd778e117ec4a9cd99d18a3 Mon Sep 17 00:00:00 2001 From: Alfred Baumann <93665570+CheesePlated@users.noreply.github.com> Date: Mon, 14 Apr 2025 17:02:27 +0200 Subject: [PATCH] Fix IDs without station records not being able to have nonstandard contents (#34921) * fix ID console resetting to passenger * review * whoopsie! whitespace --------- Co-authored-by: Milon --- Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs | 3 ++- Content.Server/Access/Systems/IdCardConsoleSystem.cs | 11 +++++++++-- Content.Shared/Access/Components/IdCardComponent.cs | 7 +++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs b/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs index 82f6ebd8b5..c133e0b107 100644 --- a/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs +++ b/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs @@ -174,7 +174,8 @@ namespace Content.Client.Access.UI new List>()); var jobIndex = _jobPrototypeIds.IndexOf(state.TargetIdJobPrototype); - // If the job index is < 0 that means they don't have a job registered in the station records. + // If the job index is < 0 that means they don't have a job registered in the station records + // or the IdCardComponent's JobPrototype field. // For example, a new ID from a box would have no job index. if (jobIndex < 0) { diff --git a/Content.Server/Access/Systems/IdCardConsoleSystem.cs b/Content.Server/Access/Systems/IdCardConsoleSystem.cs index 2d6e8a1238..9fd30ffcb1 100644 --- a/Content.Server/Access/Systems/IdCardConsoleSystem.cs +++ b/Content.Server/Access/Systems/IdCardConsoleSystem.cs @@ -98,9 +98,9 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem var targetIdComponent = EntityManager.GetComponent(targetId); var targetAccessComponent = EntityManager.GetComponent(targetId); - var jobProto = new ProtoId(string.Empty); + var jobProto = targetIdComponent.JobPrototype ?? new ProtoId(string.Empty); if (TryComp(targetId, out var keyStorage) - && keyStorage.Key is {} key + && keyStorage.Key is { } key && _record.TryGetRecord(key, out var record)) { jobProto = record.JobPrototype; @@ -151,6 +151,13 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem } UpdateStationRecord(uid, targetId, newFullName, newJobTitle, job); + if ((!TryComp(targetId, out var keyStorage) + || keyStorage.Key is not { } key + || !_record.TryGetRecord(key, out _)) + && newJobProto != string.Empty) + { + Comp(targetId).JobPrototype = newJobProto; + } if (!newAccessList.TrueForAll(x => component.AccessLevels.Contains(x))) { diff --git a/Content.Shared/Access/Components/IdCardComponent.cs b/Content.Shared/Access/Components/IdCardComponent.cs index 3b8322671b..9ca82b67b4 100644 --- a/Content.Shared/Access/Components/IdCardComponent.cs +++ b/Content.Shared/Access/Components/IdCardComponent.cs @@ -36,6 +36,13 @@ public sealed partial class IdCardComponent : Component [AutoNetworkedField] public ProtoId JobIcon = "JobIconUnknown"; + /// + /// Holds the job prototype when the ID card has no associated station record + /// + [DataField] + [AutoNetworkedField] + public ProtoId? JobPrototype; + /// /// The proto IDs of the departments associated with the job ///