From 0e5e3b46c40d39f280849a4fb03148117f55eb16 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Thu, 25 Aug 2022 09:40:35 -0400 Subject: [PATCH] store system prototype modification oversight (#10801) --- .../Store/Systems/StoreSystem.Listings.cs | 4 ++- Content.Shared/Store/ListingPrototype.cs | 25 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) 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, + }; + } } //