From 543cd6a2368cb379618f0c56cfaf3414044ba012 Mon Sep 17 00:00:00 2001 From: themias <89101928+themias@users.noreply.github.com> Date: Sat, 10 Feb 2024 04:17:25 -0500 Subject: [PATCH] Fix crew manifest department bugs (#24975) --- .../Access/Systems/AgentIDCardSystem.cs | 20 +++++++++++++++++++ .../Access/Systems/IdCardConsoleSystem.cs | 1 + Content.Server/Access/Systems/IdCardSystem.cs | 1 + 3 files changed, 22 insertions(+) diff --git a/Content.Server/Access/Systems/AgentIDCardSystem.cs b/Content.Server/Access/Systems/AgentIDCardSystem.cs index 4d242e8f81..29657b509a 100644 --- a/Content.Server/Access/Systems/AgentIDCardSystem.cs +++ b/Content.Server/Access/Systems/AgentIDCardSystem.cs @@ -7,6 +7,8 @@ using Content.Shared.Interaction; using Content.Shared.StatusIcon; using Robust.Server.GameObjects; using Robust.Shared.Prototypes; +using Content.Shared.Roles; +using System.Diagnostics.CodeAnalysis; namespace Content.Server.Access.Systems { @@ -98,6 +100,24 @@ namespace Content.Server.Access.Systems } _cardSystem.TryChangeJobIcon(uid, jobIcon, idCard); + + if (TryFindJobProtoFromIcon(jobIcon, out var job)) + _cardSystem.TryChangeJobDepartment(uid, job, idCard); + } + + private bool TryFindJobProtoFromIcon(StatusIconPrototype jobIcon, [NotNullWhen(true)] out JobPrototype? job) + { + foreach (var jobPrototype in _prototypeManager.EnumeratePrototypes()) + { + if(jobPrototype.Icon == jobIcon.ID) + { + job = jobPrototype; + return true; + } + } + + job = null; + return false; } } } diff --git a/Content.Server/Access/Systems/IdCardConsoleSystem.cs b/Content.Server/Access/Systems/IdCardConsoleSystem.cs index b3b2baf28e..791159f972 100644 --- a/Content.Server/Access/Systems/IdCardConsoleSystem.cs +++ b/Content.Server/Access/Systems/IdCardConsoleSystem.cs @@ -131,6 +131,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem && _prototype.TryIndex(job.Icon, out var jobIcon)) { _idCard.TryChangeJobIcon(targetId, jobIcon, player: player); + _idCard.TryChangeJobDepartment(targetId, job); } if (!newAccessList.TrueForAll(x => component.AccessLevels.Contains(x))) diff --git a/Content.Server/Access/Systems/IdCardSystem.cs b/Content.Server/Access/Systems/IdCardSystem.cs index 1c1e687417..def5e950d2 100644 --- a/Content.Server/Access/Systems/IdCardSystem.cs +++ b/Content.Server/Access/Systems/IdCardSystem.cs @@ -149,6 +149,7 @@ public sealed class IdCardSystem : SharedIdCardSystem if (!Resolve(uid, ref id)) return false; + id.JobDepartments.Clear(); foreach (var department in _prototypeManager.EnumeratePrototypes()) { if (department.Roles.Contains(job.ID)) -- 2.52.0