]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Hotfix: Fix uplinks allowing buying conditionally restricted items (#35334)
authorSlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>
Sun, 2 Mar 2025 19:40:57 +0000 (20:40 +0100)
committerGitHub <noreply@github.com>
Sun, 2 Mar 2025 19:40:57 +0000 (20:40 +0100)
* Initial commit

* I just compressed the code

* Actually address review

Content.Server/Store/Systems/StoreSystem.Listings.cs
Content.Server/Store/Systems/StoreSystem.Ui.cs

index 4699ec7b669bf5950e88b5e76468f5dbf09c7d97..412114ce03b19d609985ec96583b4debcb587540 100644 (file)
@@ -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
         }
     }
 
+    /// <summary>
+    /// 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.
+    /// </summary>
+    /// <param name="buyer">The buying entity.</param>
+    public EntityUid GetBuyerMind(EntityUid buyer)
+    {
+        if (!HasComp<MindComponent>(buyer) && _mind.TryGetMind(buyer, out var buyerMind, out var _))
+            return buyerMind;
+
+        return buyer;
+    }
+
     /// <summary>
     /// Checks if a listing appears in a list of given categories
     /// </summary>
index 3f4ccf696dff8d34dee13feb978f52c3d7ac192b..93bbd3bd966737bf0b11343f59b91082d570a50e 100644 (file)
@@ -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)