]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix IDs without station records not being able to have nonstandard contents (#34921)
authorAlfred Baumann <93665570+CheesePlated@users.noreply.github.com>
Mon, 14 Apr 2025 15:02:27 +0000 (17:02 +0200)
committerGitHub <noreply@github.com>
Mon, 14 Apr 2025 15:02:27 +0000 (17:02 +0200)
* fix ID console resetting to passenger

* review

* whoopsie! whitespace

---------

Co-authored-by: Milon <milonpl.git@proton.me>
Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs
Content.Server/Access/Systems/IdCardConsoleSystem.cs
Content.Shared/Access/Components/IdCardComponent.cs

index 82f6ebd8b59cb0d4c31ee12a3a130ac9829aaf69..c133e0b107a802311c0f4e458dd2ca98a0767b99 100644 (file)
@@ -174,7 +174,8 @@ namespace Content.Client.Access.UI
                                        new List<ProtoId<AccessLevelPrototype>>());
 
             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)
             {
index 2d6e8a1238c66ff3e51ed4c6451a7c2a467b7b39..9fd30ffcb1f2e891b175f62d7a70b00f7e4d8e78 100644 (file)
@@ -98,9 +98,9 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
             var targetIdComponent = EntityManager.GetComponent<IdCardComponent>(targetId);
             var targetAccessComponent = EntityManager.GetComponent<AccessComponent>(targetId);
 
-            var jobProto = new ProtoId<AccessLevelPrototype>(string.Empty);
+            var jobProto = targetIdComponent.JobPrototype ?? new ProtoId<AccessLevelPrototype>(string.Empty);
             if (TryComp<StationRecordKeyStorageComponent>(targetId, out var keyStorage)
-                && keyStorage.Key is {} key
+                && keyStorage.Key is { } key
                 && _record.TryGetRecord<GeneralStationRecord>(key, out var record))
             {
                 jobProto = record.JobPrototype;
@@ -151,6 +151,13 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
         }
 
         UpdateStationRecord(uid, targetId, newFullName, newJobTitle, job);
+        if ((!TryComp<StationRecordKeyStorageComponent>(targetId, out var keyStorage)
+            || keyStorage.Key is not { } key
+            || !_record.TryGetRecord<GeneralStationRecord>(key, out _))
+            && newJobProto != string.Empty)
+        {
+            Comp<IdCardComponent>(targetId).JobPrototype = newJobProto;
+        }
 
         if (!newAccessList.TrueForAll(x => component.AccessLevels.Contains(x)))
         {
index 3b8322671bebb0ec51687dada33f35cbe1918614..9ca82b67b4a527a03cfc44f99c261280fdbb8ea4 100644 (file)
@@ -36,6 +36,13 @@ public sealed partial class IdCardComponent : Component
     [AutoNetworkedField]
     public ProtoId<JobIconPrototype> JobIcon = "JobIconUnknown";
 
+    /// <summary>
+    /// Holds the job prototype when the ID card has no associated station record
+    /// </summary>
+    [DataField]
+    [AutoNetworkedField]
+    public ProtoId<AccessLevelPrototype>? JobPrototype;
+
     /// <summary>
     /// The proto IDs of the departments associated with the job
     /// </summary>