From 08cb26dbf08417af7a32c64c0f31c3588a0208cf Mon Sep 17 00:00:00 2001 From: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> Date: Sun, 2 Mar 2025 20:40:57 +0100 Subject: [PATCH] Hotfix: Fix uplinks allowing buying conditionally restricted items (#35334) * Initial commit * I just compressed the code * Actually address review --- .../Store/Systems/StoreSystem.Listings.cs | 16 +++++++++++++++- Content.Server/Store/Systems/StoreSystem.Ui.cs | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Content.Server/Store/Systems/StoreSystem.Listings.cs b/Content.Server/Store/Systems/StoreSystem.Listings.cs index 4699ec7b66..412114ce03 100644 --- a/Content.Server/Store/Systems/StoreSystem.Listings.cs +++ b/Content.Server/Store/Systems/StoreSystem.Listings.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using Content.Shared.Mind; using Content.Shared.Store; using Content.Shared.Store.Components; using Robust.Shared.Prototypes; @@ -117,7 +118,7 @@ public sealed partial class StoreSystem if (listing.Conditions != null) { - var args = new ListingConditionArgs(buyer, storeEntity, listing, EntityManager); + var args = new ListingConditionArgs(GetBuyerMind(buyer), storeEntity, listing, EntityManager); var conditionsMet = true; foreach (var condition in listing.Conditions) @@ -137,6 +138,19 @@ public sealed partial class StoreSystem } } + /// + /// Returns the entity's mind entity, if it has one, to be used for listing conditions. + /// If it doesn't have one, or is a mind entity already, it returns itself. + /// + /// The buying entity. + public EntityUid GetBuyerMind(EntityUid buyer) + { + if (!HasComp(buyer) && _mind.TryGetMind(buyer, out var buyerMind, out var _)) + return buyerMind; + + return buyer; + } + /// /// Checks if a listing appears in a list of given categories /// diff --git a/Content.Server/Store/Systems/StoreSystem.Ui.cs b/Content.Server/Store/Systems/StoreSystem.Ui.cs index 3f4ccf696d..93bbd3bd96 100644 --- a/Content.Server/Store/Systems/StoreSystem.Ui.cs +++ b/Content.Server/Store/Systems/StoreSystem.Ui.cs @@ -146,7 +146,7 @@ public sealed partial class StoreSystem //condition checking because why not if (listing.Conditions != null) { - var args = new ListingConditionArgs(component.AccountOwner ?? buyer, uid, listing, EntityManager); + var args = new ListingConditionArgs(component.AccountOwner ?? GetBuyerMind(buyer), uid, listing, EntityManager); var conditionsMet = listing.Conditions.All(condition => condition.Condition(args)); if (!conditionsMet) -- 2.51.2