Make shuttle launch use ID card entity name (#9405)

This commit is contained in:
metalgearsloth
2022-07-04 23:09:10 +10:00
committed by GitHub
parent 6f76c95a36
commit 76e4766d65

View File

@@ -1,4 +1,5 @@
using System.Threading;
using Content.Server.Access.Systems;
using Content.Server.Popups;
using Content.Server.RoundEnd;
using Content.Server.Shuttles.Components;
@@ -25,6 +26,7 @@ public sealed partial class ShuttleSystem
*/
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IdCardSystem _idSystem = default!;
[Dependency] private readonly AccessReaderSystem _reader = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly RoundEndSystem _roundEnd = default!;
@@ -154,6 +156,7 @@ public sealed partial class ShuttleSystem
if (component.AuthorizedEntities.Count == 0) return;
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch REPEAL ALL by {args.Session:user}");
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-console-auth-revoked", ("remaining", component.AuthorizationsRequired)));
component.AuthorizedEntities.Clear();
UpdateAllEmergencyConsoles();
}
@@ -163,14 +166,14 @@ public sealed partial class ShuttleSystem
var player = args.Session.AttachedEntity;
if (player == null) return;
if (!_reader.IsAllowed(player.Value, uid))
if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard.Owner, uid))
{
_popup.PopupCursor("Access denied", Filter.Entities(player.Value));
_popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), Filter.Entities(player.Value));
return;
}
// TODO: This is fucking bad
if (!component.AuthorizedEntities.Remove(MetaData(player.Value).EntityName)) return;
if (!component.AuthorizedEntities.Remove(MetaData(idCard.Owner).EntityName)) return;
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch REPEAL by {args.Session:user}");
var remaining = component.AuthorizationsRequired - component.AuthorizedEntities.Count;
@@ -184,14 +187,14 @@ public sealed partial class ShuttleSystem
var player = args.Session.AttachedEntity;
if (player == null) return;
if (!_reader.IsAllowed(player.Value, uid))
if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard.Owner, uid))
{
_popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), Filter.Entities(player.Value));
return;
}
// TODO: This is fucking bad
if (!component.AuthorizedEntities.Add(MetaData(player.Value).EntityName)) return;
if (!component.AuthorizedEntities.Add(MetaData(idCard.Owner).EntityName)) return;
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch AUTH by {args.Session:user}");
var remaining = component.AuthorizationsRequired - component.AuthorizedEntities.Count;