diff --git a/Content.Server/Store/Systems/StoreSystem.Listings.cs b/Content.Server/Store/Systems/StoreSystem.Listings.cs index 36b1a4b8c5..9dd1ec96a8 100644 --- a/Content.Server/Store/Systems/StoreSystem.Listings.cs +++ b/Content.Server/Store/Systems/StoreSystem.Listings.cs @@ -26,7 +26,9 @@ public sealed partial class StoreSystem : EntitySystem var allData = new HashSet(); foreach (var listing in allListings) - allData.Add(listing); + { + allData.Add((ListingData) listing.Clone()); + } return allData; } diff --git a/Content.Shared/Store/ListingPrototype.cs b/Content.Shared/Store/ListingPrototype.cs index 5be7d00675..70e93b37c1 100644 --- a/Content.Shared/Store/ListingPrototype.cs +++ b/Content.Shared/Store/ListingPrototype.cs @@ -17,7 +17,7 @@ namespace Content.Shared.Store; /// [Serializable, NetSerializable] [Virtual, DataDefinition] -public class ListingData : IEquatable +public class ListingData : IEquatable, ICloneable { /// /// The name of the listing. If empty, uses the entity's name (if present) @@ -116,6 +116,29 @@ public class ListingData : IEquatable return true; } + + /// + /// Creates a unique instance of a listing. ALWAWYS USE THIS WHEN ENUMERATING LISTING PROTOTYPES + /// DON'T BE DUMB AND MODIFY THE PROTOTYPES + /// + /// A unique copy of the listing data. + public object Clone() + { + return new ListingData + { + Name = Name, + Description = Description, + Categories = Categories, + Cost = Cost, + Conditions = Conditions, + Icon = Icon, + Priority = Priority, + ProductEntity = ProductEntity, + ProductAction = ProductAction, + ProductEvent = ProductEvent, + PurchaseAmount = PurchaseAmount, + }; + } } //