]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix crew manifest department bugs (#24975)
authorthemias <89101928+themias@users.noreply.github.com>
Sat, 10 Feb 2024 09:17:25 +0000 (04:17 -0500)
committerGitHub <noreply@github.com>
Sat, 10 Feb 2024 09:17:25 +0000 (01:17 -0800)
Content.Server/Access/Systems/AgentIDCardSystem.cs
Content.Server/Access/Systems/IdCardConsoleSystem.cs
Content.Server/Access/Systems/IdCardSystem.cs

index 4d242e8f81d4ae5499edec3bd6e668b1a0e14434..29657b509a96a839fa010cb538701ee1f1025957 100644 (file)
@@ -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<JobPrototype>())
+            {
+                if(jobPrototype.Icon == jobIcon.ID)
+                {
+                    job = jobPrototype;
+                    return true;
+                }
+            }
+
+            job = null;
+            return false;
         }
     }
 }
index b3b2baf28e78c984879d51fc9c4ad35c69d5c67f..791159f972b072dea4d3dc442675d5aab0c2c94d 100644 (file)
@@ -131,6 +131,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
             && _prototype.TryIndex<StatusIconPrototype>(job.Icon, out var jobIcon))
         {
             _idCard.TryChangeJobIcon(targetId, jobIcon, player: player);
+            _idCard.TryChangeJobDepartment(targetId, job);
         }
 
         if (!newAccessList.TrueForAll(x => component.AccessLevels.Contains(x)))
index 1c1e68741720375304c240e67a8a104b70b35780..def5e950d2ceee5f44e40107c5bb3c5354e9abce 100644 (file)
@@ -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<DepartmentPrototype>())
         {
             if (department.Roles.Contains(job.ID))