Hotfix: Fix uplinks allowing buying conditionally restricted items (#35334)
* Initial commit * I just compressed the code * Actually address review
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using Content.Shared.Mind;
|
||||||
using Content.Shared.Store;
|
using Content.Shared.Store;
|
||||||
using Content.Shared.Store.Components;
|
using Content.Shared.Store.Components;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -117,7 +118,7 @@ public sealed partial class StoreSystem
|
|||||||
|
|
||||||
if (listing.Conditions != null)
|
if (listing.Conditions != null)
|
||||||
{
|
{
|
||||||
var args = new ListingConditionArgs(buyer, storeEntity, listing, EntityManager);
|
var args = new ListingConditionArgs(GetBuyerMind(buyer), storeEntity, listing, EntityManager);
|
||||||
var conditionsMet = true;
|
var conditionsMet = true;
|
||||||
|
|
||||||
foreach (var condition in listing.Conditions)
|
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>
|
/// <summary>
|
||||||
/// Checks if a listing appears in a list of given categories
|
/// Checks if a listing appears in a list of given categories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public sealed partial class StoreSystem
|
|||||||
//condition checking because why not
|
//condition checking because why not
|
||||||
if (listing.Conditions != null)
|
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));
|
var conditionsMet = listing.Conditions.All(condition => condition.Condition(args));
|
||||||
|
|
||||||
if (!conditionsMet)
|
if (!conditionsMet)
|
||||||
|
|||||||
Reference in New Issue
Block a user