]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Firelocks only open on click (not close) (#16516)
authorTom Leys <tom@crump-leys.com>
Wed, 17 May 2023 06:37:37 +0000 (18:37 +1200)
committerGitHub <noreply@github.com>
Wed, 17 May 2023 06:37:37 +0000 (23:37 -0700)
Content.Server/Doors/Systems/DoorSystem.cs
Content.Server/Remotes/DoorRemoteSystem.cs
Content.Shared/Doors/Systems/SharedDoorSystem.cs

index 7ec1413ba5e2a9fd314c9e90fd0459b653ae0670..c263f9c437b8384ffc361ebae73a462bfdc7d416 100644 (file)
@@ -27,7 +27,6 @@ namespace Content.Server.Doors.Systems;
 
 public sealed class DoorSystem : SharedDoorSystem
 {
-    [Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
     [Dependency] private readonly AirlockSystem _airlock = default!;
     [Dependency] private readonly AirtightSystem _airtightSystem = default!;
     [Dependency] private readonly SharedToolSystem _toolSystem = default!;
@@ -208,34 +207,6 @@ public sealed class DoorSystem : SharedDoorSystem
     }
 #endregion
 
-    /// <summary>
-    ///     Does the user have the permissions required to open this door?
-    /// </summary>
-    public override bool HasAccess(EntityUid uid, EntityUid? user = null, AccessReaderComponent? access = null)
-    {
-        // TODO network AccessComponent for predicting doors
-
-        // if there is no "user" we skip the access checks. Access is also ignored in some game-modes.
-        if (user == null || AccessType == AccessTypes.AllowAll)
-            return true;
-
-        // If the door is on emergency access we skip the checks.
-        if (TryComp<AirlockComponent>(uid, out var airlock) && airlock.EmergencyAccess)
-            return true;
-
-        if (!Resolve(uid, ref access, false))
-            return true;
-
-        var isExternal = access.AccessLists.Any(list => list.Contains("External"));
-
-        return AccessType switch
-        {
-            // Some game modes modify access rules.
-            AccessTypes.AllowAllIdExternal => !isExternal || _accessReaderSystem.IsAllowed(user.Value, access),
-            AccessTypes.AllowAllNoExternal => !isExternal,
-            _ => _accessReaderSystem.IsAllowed(user.Value, access)
-        };
-    }
 
     /// <summary>
     ///     Open a door if a player or door-bumper (PDA, ID-card) collide with the door. Sadly, bullets no longer
index bbc84eec6e973e6935a3372fac4c0b33ea3f3058..8bb88abef86b3b3457b2f18840799b49533fe991 100644 (file)
@@ -74,7 +74,7 @@ namespace Content.Server.Remotes
             }
 
             if (TryComp<AccessReaderComponent>(args.Target, out var accessComponent) &&
-                !_doorSystem.HasAccess(args.Target.Value, args.Used, accessComponent))
+                !_doorSystem.HasAccess(args.Target.Value, args.Used, doorComp, accessComponent))
             {
                 _doorSystem.Deny(args.Target.Value, doorComp, args.User);
                 ShowPopupToUser("door-remote-denied", args.User);
index 396f90da5d4dc1b63fdd2f4177d8934135a4202b..af4b9101cfcb6f6bc9e74f085ffea9d23c1df607 100644 (file)
@@ -1,5 +1,6 @@
 using System.Linq;
 using Content.Shared.Access.Components;
+using Content.Shared.Access.Systems;
 using Content.Shared.Damage;
 using Content.Shared.DoAfter;
 using Content.Shared.Doors.Components;
@@ -29,6 +30,7 @@ public abstract class SharedDoorSystem : EntitySystem
     [Dependency] private readonly EntityLookupSystem _entityLookup = default!;
     [Dependency] protected readonly SharedAppearanceSystem AppearanceSystem = default!;
     [Dependency] private readonly OccluderSystem _occluder = default!;
+    [Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
 
     /// <summary>
     ///     A body must have an intersection percentage larger than this in order to be considered as colliding with a
@@ -252,7 +254,7 @@ public abstract class SharedDoorSystem : EntitySystem
         if (ev.Cancelled)
             return false;
 
-        if (!HasAccess(uid, user))
+        if (!HasAccess(uid, user, door))
         {
             if (!quiet)
                 Deny(uid, door);
@@ -325,7 +327,7 @@ public abstract class SharedDoorSystem : EntitySystem
         if (ev.Cancelled)
             return false;
 
-        if (!HasAccess(uid, user))
+        if (!HasAccess(uid, user, door))
             return false;
 
         return !ev.PerformCollisionCheck || !GetColliding(uid).Any();
@@ -476,13 +478,39 @@ public abstract class SharedDoorSystem : EntitySystem
     #endregion
 
     #region Access
-    public virtual bool HasAccess(EntityUid uid, EntityUid? user = null, AccessReaderComponent? access = null)
+
+    /// <summary>
+    ///     Does the user have the permissions required to open this door?
+    /// </summary>
+    public bool HasAccess(EntityUid uid, EntityUid? user = null, DoorComponent? door = null, AccessReaderComponent? access = null)
     {
         // TODO network AccessComponent for predicting doors
 
-        // Currently all door open/close & door-bumper collision stuff is done server side.
-        // so this return value means nothing.
-        return true;
+        // if there is no "user" we skip the access checks. Access is also ignored in some game-modes.
+        if (user == null || AccessType == AccessTypes.AllowAll)
+            return true;
+
+        // If the door is on emergency access we skip the checks.
+        if (TryComp<AirlockComponent>(uid, out var airlock) && airlock.EmergencyAccess)
+            return true;
+
+        // Can't click to close firelocks.
+        if (Resolve(uid, ref door) && door.State == DoorState.Open &&
+            TryComp<FirelockComponent>(uid, out var firelock))
+            return false;
+
+        if (!Resolve(uid, ref access, false))
+            return true;
+
+        var isExternal = access.AccessLists.Any(list => list.Contains("External"));
+
+        return AccessType switch
+        {
+            // Some game modes modify access rules.
+            AccessTypes.AllowAllIdExternal => !isExternal || _accessReaderSystem.IsAllowed(user.Value, access),
+            AccessTypes.AllowAllNoExternal => !isExternal,
+            _ => _accessReaderSystem.IsAllowed(user.Value, access)
+        };
     }
 
     /// <summary>