From: Tom Leys Date: Wed, 17 May 2023 06:37:37 +0000 (+1200) Subject: Firelocks only open on click (not close) (#16516) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=9fce417662117f9449deba6e9758a679b0eb7141;p=space-station-14.git Firelocks only open on click (not close) (#16516) --- diff --git a/Content.Server/Doors/Systems/DoorSystem.cs b/Content.Server/Doors/Systems/DoorSystem.cs index 7ec1413ba5..c263f9c437 100644 --- a/Content.Server/Doors/Systems/DoorSystem.cs +++ b/Content.Server/Doors/Systems/DoorSystem.cs @@ -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 - /// - /// Does the user have the permissions required to open this door? - /// - 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(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) - }; - } /// /// Open a door if a player or door-bumper (PDA, ID-card) collide with the door. Sadly, bullets no longer diff --git a/Content.Server/Remotes/DoorRemoteSystem.cs b/Content.Server/Remotes/DoorRemoteSystem.cs index bbc84eec6e..8bb88abef8 100644 --- a/Content.Server/Remotes/DoorRemoteSystem.cs +++ b/Content.Server/Remotes/DoorRemoteSystem.cs @@ -74,7 +74,7 @@ namespace Content.Server.Remotes } if (TryComp(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); diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index 396f90da5d..af4b9101cf 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -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!; /// /// 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) + + /// + /// Does the user have the permissions required to open this door? + /// + 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(uid, out var airlock) && airlock.EmergencyAccess) + return true; + + // Can't click to close firelocks. + if (Resolve(uid, ref door) && door.State == DoorState.Open && + TryComp(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) + }; } ///