Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix access configurator debug assert #34330

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Content.Server/Access/Systems/AccessOverriderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ private void UpdateUserInterface(EntityUid uid, AccessOverriderComponent compone
targetLabel = Loc.GetString("access-overrider-window-target-label") + " " + EntityManager.GetComponent<MetaDataComponent>(component.TargetAccessReaderId).EntityName;
targetLabelColor = Color.White;

if (!_accessReader.GetMainAccessReader(accessReader, out var accessReaderComponent))
if (!_accessReader.GetMainAccessReader(accessReader, out var accessReaderEnt))
return;

var currentAccessHashsets = accessReaderComponent.AccessLists;
var currentAccessHashsets = accessReaderEnt.Value.Comp.AccessLists;
currentAccess = ConvertAccessHashSetsToList(currentAccessHashsets).ToArray();
}

Expand Down Expand Up @@ -210,10 +210,10 @@ private void TryWriteToTargetAccessReaderId(EntityUid uid,
return;
}

if (!_accessReader.GetMainAccessReader(component.TargetAccessReaderId, out var accessReader))
if (!_accessReader.GetMainAccessReader(component.TargetAccessReaderId, out var accessReaderEnt))
return;

var oldTags = ConvertAccessHashSetsToList(accessReader.AccessLists);
var oldTags = ConvertAccessHashSetsToList(accessReaderEnt.Value.Comp.AccessLists);
var privilegedId = component.PrivilegedIdSlot.Item;

if (oldTags.SequenceEqual(newAccessList))
Expand Down Expand Up @@ -242,10 +242,10 @@ private void TryWriteToTargetAccessReaderId(EntityUid uid,
var removedTags = oldTags.Except(newAccessList).Select(tag => "-" + tag).ToList();

_adminLogger.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(player):player} has modified {ToPrettyString(component.TargetAccessReaderId):entity} with the following allowed access level holders: [{string.Join(", ", addedTags.Union(removedTags))}] [{string.Join(", ", newAccessList)}]");
$"{ToPrettyString(player):player} has modified {ToPrettyString(accessReaderEnt.Value):entity} with the following allowed access level holders: [{string.Join(", ", addedTags.Union(removedTags))}] [{string.Join(", ", newAccessList)}]");

accessReader.AccessLists = ConvertAccessListToHashSet(newAccessList);
Dirty(component.TargetAccessReaderId, accessReader);
accessReaderEnt.Value.Comp.AccessLists = ConvertAccessListToHashSet(newAccessList);
Dirty(accessReaderEnt.Value);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/StationEvents/Events/GreytideVirusRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ protected override void Started(EntityUid uid, GreytideVirusRuleComponent virusC
continue;

// use the access reader from the door electronics if they exist
if (!_access.GetMainAccessReader(airlockUid, out var accessComp))
if (!_access.GetMainAccessReader(airlockUid, out var accessEnt))
continue;

// check access
if (!_access.AreAccessTagsAllowed(accessIds, accessComp) || _access.AreAccessTagsAllowed(virusComp.Blacklist, accessComp))
if (!_access.AreAccessTagsAllowed(accessIds, accessEnt.Value.Comp) || _access.AreAccessTagsAllowed(virusComp.Blacklist, accessEnt.Value.Comp))
continue;

// open and bolt airlocks
Expand Down
16 changes: 8 additions & 8 deletions Content.Shared/Access/Systems/AccessReaderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,25 @@ public bool IsAllowed(EntityUid user, EntityUid target, AccessReaderComponent? r
return false;
}

public bool GetMainAccessReader(EntityUid uid, [NotNullWhen(true)] out AccessReaderComponent? component)
public bool GetMainAccessReader(EntityUid uid, [NotNullWhen(true)] out Entity<AccessReaderComponent>? ent)
{
component = null;
if (!TryComp(uid, out AccessReaderComponent? accessReader))
ent = null;
if (!TryComp<AccessReaderComponent>(uid, out var accessReader))
return false;

component = accessReader;
ent = (uid, accessReader);

if (component.ContainerAccessProvider == null)
if (ent.Value.Comp.ContainerAccessProvider == null)
return true;

if (!_containerSystem.TryGetContainer(uid, component.ContainerAccessProvider, out var container))
if (!_containerSystem.TryGetContainer(uid, ent.Value.Comp.ContainerAccessProvider, out var container))
return true;

foreach (var entity in container.ContainedEntities)
{
if (TryComp(entity, out AccessReaderComponent? containedReader))
if (TryComp<AccessReaderComponent>(entity, out var containedReader))
{
component = containedReader;
ent = (entity, containedReader);
return true;
}
}
Expand Down
Loading