From dc303d871e8d66b1e67e4e45a4a55ad057e433c2 Mon Sep 17 00:00:00 2001 From: Spirtix Date: Thu, 26 Jun 2025 21:41:50 +0200 Subject: [PATCH] mission deep copy .net 8 deprecated BinaryFormatter serialization apart from that proper deep copies are ~10x faster --- src/Schema/AchievementReward.cs | 25 ++++++++++++-- src/Schema/BluePrint.cs | 13 ++++++-- src/Schema/BluePrintDeductibleConfig.cs | 14 ++++++-- src/Schema/BluePrintSpecification.cs | 18 +++++++++-- src/Schema/CompletionAction.cs | 11 +++++-- src/Schema/ItemAttribute.cs | 12 +++++-- src/Schema/ItemAvailability.cs | 12 +++++-- src/Schema/ItemData.cs | 43 +++++++++++++++++++++++-- src/Schema/ItemDataCategory.cs | 13 ++++++-- src/Schema/ItemDataRelationship.cs | 15 +++++++-- src/Schema/ItemDataRollover.cs | 12 +++++-- src/Schema/ItemDataTexture.cs | 14 ++++++-- src/Schema/ItemPossibleStatsMap.cs | 14 ++++++-- src/Schema/ItemSaleConfig.cs | 15 +++++++-- src/Schema/ItemStat.cs | 14 ++++++-- src/Schema/ItemState.cs | 16 +++++++-- src/Schema/ItemStateCriteria.cs | 11 +++++-- src/Schema/ItemStateRule.cs | 12 +++++-- src/Schema/ItemStatsMap.cs | 13 ++++++-- src/Schema/Mission.cs | 24 ++++++++++++++ src/Schema/MissionCriteria.cs | 10 ++++++ src/Schema/MissionRule.cs | 7 ++++ src/Schema/Pair.cs | 13 ++++++-- src/Schema/PairData.cs | 6 ++++ src/Schema/PrerequisiteItem.cs | 9 ++++++ src/Schema/RuleItem.cs | 9 ++++++ src/Schema/Stat.cs | 15 +++++++-- src/Schema/StatRangeMap.cs | 15 +++++++-- src/Schema/Task.cs | 11 +++++++ src/Schema/UserItemData.cs | 20 ++++++++++-- src/Services/MissionStoreSingleton.cs | 14 +------- src/sodoff.csproj | 1 - 32 files changed, 368 insertions(+), 83 deletions(-) diff --git a/src/Schema/AchievementReward.cs b/src/Schema/AchievementReward.cs index 821e5c3..20f0a26 100644 --- a/src/Schema/AchievementReward.cs +++ b/src/Schema/AchievementReward.cs @@ -4,9 +4,28 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "AR", Namespace = "")] [Serializable] -public class AchievementReward -{ - [XmlElement(ElementName = "ui", IsNullable = true)] +public class AchievementReward { + public AchievementReward() {} + + public AchievementReward(AchievementReward other) { + if (other.UserItem != null) + UserItem = new UserItemData(other.UserItem); + + Amount = other.Amount; + PointTypeID = other.PointTypeID; + ItemID = other.ItemID; + EntityID = other.EntityID; + EntityTypeID = other.EntityTypeID; + RewardID = other.RewardID; + AchievementID = other.AchievementID; + AllowMultiple = other.AllowMultiple; + MinAmount = other.MinAmount; + MaxAmount = other.MaxAmount; + Date = other.Date; + CommonInventoryID = other.CommonInventoryID; + } + + [XmlElement(ElementName = "ui", IsNullable = true)] public UserItemData UserItem { get; set; } [XmlElement(ElementName = "a")] diff --git a/src/Schema/BluePrint.cs b/src/Schema/BluePrint.cs index 3c5aeda..e7f81b8 100644 --- a/src/Schema/BluePrint.cs +++ b/src/Schema/BluePrint.cs @@ -5,9 +5,16 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "BP", Namespace = "", IsNullable = true)] [Serializable] -public class BluePrint -{ - [XmlElement(ElementName = "BPDC", IsNullable = true)] +public class BluePrint { + public BluePrint() {} + + public BluePrint(BluePrint other) { + Deductibles = other.Deductibles.Select(d => new BluePrintDeductibleConfig(d)).ToList(); + Ingredients = other.Ingredients.Select(i => new BluePrintSpecification(i)).ToList(); + Outputs = other.Outputs.Select(o => new BluePrintSpecification(o)).ToList(); + } + + [XmlElement(ElementName = "BPDC", IsNullable = true)] public List Deductibles { get; set; } [XmlElement(ElementName = "ING", IsNullable = false)] diff --git a/src/Schema/BluePrintDeductibleConfig.cs b/src/Schema/BluePrintDeductibleConfig.cs index e42025d..a83012c 100644 --- a/src/Schema/BluePrintDeductibleConfig.cs +++ b/src/Schema/BluePrintDeductibleConfig.cs @@ -4,9 +4,17 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "BPDC", Namespace = "", IsNullable = true)] [Serializable] -public class BluePrintDeductibleConfig -{ - [XmlElement(ElementName = "BPIID", IsNullable = false)] +public class BluePrintDeductibleConfig { + public BluePrintDeductibleConfig() {} + + public BluePrintDeductibleConfig(BluePrintDeductibleConfig other) { + BluePrintItemID = other.BluePrintItemID; + DeductibleType = other.DeductibleType; + ItemID = other.ItemID; + Quantity = other.Quantity; + } + + [XmlElement(ElementName = "BPIID", IsNullable = false)] public int BluePrintItemID { get; set; } [XmlElement(ElementName = "DT", IsNullable = false)] diff --git a/src/Schema/BluePrintSpecification.cs b/src/Schema/BluePrintSpecification.cs index 6f235b7..2851c8c 100644 --- a/src/Schema/BluePrintSpecification.cs +++ b/src/Schema/BluePrintSpecification.cs @@ -2,9 +2,21 @@ using System.Xml.Serialization; namespace sodoff.Schema; -public class BluePrintSpecification -{ - [XmlElement(ElementName = "BPSID", IsNullable = false)] +public class BluePrintSpecification { + public BluePrintSpecification() {} + + public BluePrintSpecification(BluePrintSpecification other) { + BluePrintSpecID = other.BluePrintSpecID; + BluePrintItemID = other.BluePrintItemID; + ItemID = other.ItemID; + CategoryID = other.CategoryID; + ItemRarity = other.ItemRarity; + Tier = other.Tier; + Quantity = other.Quantity; + SpecificationType = other.SpecificationType; + } + + [XmlElement(ElementName = "BPSID", IsNullable = false)] public int BluePrintSpecID { get; set; } [XmlElement(ElementName = "BPIID", IsNullable = false)] diff --git a/src/Schema/CompletionAction.cs b/src/Schema/CompletionAction.cs index b318f64..8e9e9e2 100644 --- a/src/Schema/CompletionAction.cs +++ b/src/Schema/CompletionAction.cs @@ -3,8 +3,13 @@ using System.Xml.Serialization; namespace sodoff.Schema; [Serializable] -public class CompletionAction -{ - [XmlElement(ElementName = "Transition")] +public class CompletionAction { + public CompletionAction() {} + + public CompletionAction(CompletionAction other) { + Transition = other.Transition; + } + + [XmlElement(ElementName = "Transition")] public StateTransition Transition; } diff --git a/src/Schema/ItemAttribute.cs b/src/Schema/ItemAttribute.cs index e62801a..a5c3056 100644 --- a/src/Schema/ItemAttribute.cs +++ b/src/Schema/ItemAttribute.cs @@ -4,9 +4,15 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "AT", Namespace = "")] [Serializable] -public class ItemAttribute -{ - [XmlElement(ElementName = "k")] +public class ItemAttribute { + public ItemAttribute() {} + + public ItemAttribute(ItemAttribute other) { + Key = other.Key; + Value = other.Value; + } + + [XmlElement(ElementName = "k")] public string Key; [XmlElement(ElementName = "v")] diff --git a/src/Schema/ItemAvailability.cs b/src/Schema/ItemAvailability.cs index 9b10bab..898a666 100644 --- a/src/Schema/ItemAvailability.cs +++ b/src/Schema/ItemAvailability.cs @@ -4,9 +4,15 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "Availability", Namespace = "")] [Serializable] -public class ItemAvailability -{ - [XmlElement(ElementName = "sdate", IsNullable = true)] +public class ItemAvailability { + public ItemAvailability() {} + + public ItemAvailability(ItemAvailability other) { + StartDate = other.StartDate; + EndDate = other.EndDate; + } + + [XmlElement(ElementName = "sdate", IsNullable = true)] public DateTime? StartDate; [XmlElement(ElementName = "edate", IsNullable = true)] diff --git a/src/Schema/ItemData.cs b/src/Schema/ItemData.cs index fc18947..c8b591a 100644 --- a/src/Schema/ItemData.cs +++ b/src/Schema/ItemData.cs @@ -3,9 +3,46 @@ using System.Xml.Serialization; namespace sodoff.Schema; [XmlRoot(ElementName = "I", Namespace = "", IsNullable = true)] -public class ItemData -{ - [XmlElement(ElementName = "is")] +public class ItemData { + public ItemData() {} + + public ItemData(ItemData other) { + ItemStates = other.ItemStates.Select(s => new ItemState(s)).ToList(); + ItemRarity = other.ItemRarity; + PossibleStatsMap = new ItemPossibleStatsMap(other.PossibleStatsMap); + ItemStatsMap = new ItemStatsMap(other.ItemStatsMap); + ItemSaleConfigs = other.ItemSaleConfigs.Select(cfg => new ItemSaleConfig(cfg)).ToArray(); + BluePrint = new BluePrint(other.BluePrint); + AssetName = other.AssetName; + Attribute = other.Attribute.Select(attr => new ItemAttribute(attr)).ToArray(); + Category = other.Category.Select(cat => new ItemDataCategory(cat)).ToArray(); + Cost = other.Cost; + CashCost = other.CashCost; + CreativePoints = other.CreativePoints; + Description = other.Description; + IconName = other.IconName; + InventoryMax = other.InventoryMax; + ItemID = other.ItemID; + ItemName = other.ItemName; + ItemNamePlural = other.ItemNamePlural; + Locked = other.Locked; + Geometry2 = other.Geometry2; + Rollover = new ItemDataRollover(other.Rollover); + RankId = other.RankId; + Relationship = other.Relationship.Select(r => new ItemDataRelationship(r)).ToArray(); + Stackable = other.Stackable; + AllowStacking = other.AllowStacking; + SaleFactor = other.SaleFactor; + Texture = other.Texture.Select(t => new ItemDataTexture(t)).ToArray(); + Uses = other.Uses; + Availability = other.Availability.Select(a => new ItemAvailability(a)).ToArray(); + RewardTypeID = other.RewardTypeID; + Points = other.Points; + NormalDiscoutModifier = other.NormalDiscoutModifier; + MemberDiscountModifier = other.MemberDiscountModifier; + } + + [XmlElement(ElementName = "is")] public List ItemStates { get; set; } [XmlElement(ElementName = "ir", IsNullable = true)] diff --git a/src/Schema/ItemDataCategory.cs b/src/Schema/ItemDataCategory.cs index de91e1d..6e5cb55 100644 --- a/src/Schema/ItemDataCategory.cs +++ b/src/Schema/ItemDataCategory.cs @@ -4,9 +4,16 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "IC", Namespace = "")] [Serializable] -public class ItemDataCategory -{ - [XmlElement(ElementName = "cid")] +public class ItemDataCategory { + public ItemDataCategory() {} + + public ItemDataCategory(ItemDataCategory other) { + CategoryId = other.CategoryId; + CategoryName = other.CategoryName; + IconName = other.IconName; + } + + [XmlElement(ElementName = "cid")] public int CategoryId; [XmlElement(ElementName = "cn")] diff --git a/src/Schema/ItemDataRelationship.cs b/src/Schema/ItemDataRelationship.cs index c15424b..f340ecf 100644 --- a/src/Schema/ItemDataRelationship.cs +++ b/src/Schema/ItemDataRelationship.cs @@ -4,9 +4,18 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "IRE", Namespace = "")] [Serializable] -public class ItemDataRelationship -{ - [XmlElement(ElementName = "t")] +public class ItemDataRelationship { + public ItemDataRelationship() {} + + public ItemDataRelationship(ItemDataRelationship other) { + Type = other.Type; + ItemId = other.ItemId; + Weight = other.Weight; + Quantity = other.Quantity; + MaxQuantity = other.MaxQuantity; + } + + [XmlElement(ElementName = "t")] public string Type; [XmlElement(ElementName = "id")] diff --git a/src/Schema/ItemDataRollover.cs b/src/Schema/ItemDataRollover.cs index e4b1e33..baee86f 100644 --- a/src/Schema/ItemDataRollover.cs +++ b/src/Schema/ItemDataRollover.cs @@ -4,9 +4,15 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "IRO", Namespace = "")] [Serializable] -public class ItemDataRollover -{ - [XmlElement(ElementName = "d")] +public class ItemDataRollover { + public ItemDataRollover() {} + + public ItemDataRollover(ItemDataRollover other) { + DialogName = other.DialogName; + Bundle = other.Bundle; + } + + [XmlElement(ElementName = "d")] public string DialogName; [XmlElement(ElementName = "b")] diff --git a/src/Schema/ItemDataTexture.cs b/src/Schema/ItemDataTexture.cs index 35e155e..1650352 100644 --- a/src/Schema/ItemDataTexture.cs +++ b/src/Schema/ItemDataTexture.cs @@ -4,9 +4,17 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "IT", Namespace = "")] [Serializable] -public class ItemDataTexture -{ - [XmlElement(ElementName = "n")] +public class ItemDataTexture { + public ItemDataTexture() {} + + public ItemDataTexture(ItemDataTexture other) { + TextureName = other.TextureName; + TextureTypeName = other.TextureTypeName; + OffsetX = other.OffsetX; + OffsetY = other.OffsetY; + } + + [XmlElement(ElementName = "n")] public string TextureName; [XmlElement(ElementName = "t")] diff --git a/src/Schema/ItemPossibleStatsMap.cs b/src/Schema/ItemPossibleStatsMap.cs index 6087d5a..ac577b0 100644 --- a/src/Schema/ItemPossibleStatsMap.cs +++ b/src/Schema/ItemPossibleStatsMap.cs @@ -4,9 +4,17 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "IPSM", Namespace = "", IsNullable = false)] [Serializable] -public class ItemPossibleStatsMap -{ - [XmlElement(ElementName = "IID", IsNullable = false)] +public class ItemPossibleStatsMap { + public ItemPossibleStatsMap() {} + + public ItemPossibleStatsMap(ItemPossibleStatsMap other) { + ItemID = other.ItemID; + ItemStatsCount = other.ItemStatsCount; + SetID = other.SetID; + Stats = other.Stats.Select(s => new Stat(s)).ToList(); + } + + [XmlElement(ElementName = "IID", IsNullable = false)] public int ItemID { get; set; } [XmlElement(ElementName = "SC", IsNullable = false)] diff --git a/src/Schema/ItemSaleConfig.cs b/src/Schema/ItemSaleConfig.cs index 0495ed7..0528167 100644 --- a/src/Schema/ItemSaleConfig.cs +++ b/src/Schema/ItemSaleConfig.cs @@ -4,9 +4,18 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "ISC", Namespace = "", IsNullable = true)] [Serializable] -public class ItemSaleConfig -{ - [XmlElement(ElementName = "IID", IsNullable = true)] +public class ItemSaleConfig { + public ItemSaleConfig() {} + + public ItemSaleConfig(ItemSaleConfig other) { + ItemID = other.ItemID; + CategoryID = other.CategoryID; + RarityID = other.RarityID; + Quantity = other.Quantity; + RewardItemID = other.RewardItemID; + } + + [XmlElement(ElementName = "IID", IsNullable = true)] public int? ItemID { get; set; } [XmlElement(ElementName = "CID", IsNullable = true)] diff --git a/src/Schema/ItemStat.cs b/src/Schema/ItemStat.cs index e7431e2..3a1b9c0 100644 --- a/src/Schema/ItemStat.cs +++ b/src/Schema/ItemStat.cs @@ -4,9 +4,17 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "IS", Namespace = "")] [Serializable] -public class ItemStat -{ - [XmlElement(ElementName = "ID")] +public class ItemStat { + public ItemStat() {} + + public ItemStat(ItemStat other) { + ItemStatID = other.ItemStatID; + Name = other.Name; + Value = other.Value; + DataType = other.DataType; + } + + [XmlElement(ElementName = "ID")] public int ItemStatID { get; set; } [XmlElement(ElementName = "N")] diff --git a/src/Schema/ItemState.cs b/src/Schema/ItemState.cs index a8d1351..a39af77 100644 --- a/src/Schema/ItemState.cs +++ b/src/Schema/ItemState.cs @@ -4,9 +4,19 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "ItemState", Namespace = "")] [Serializable] -public class ItemState -{ - [XmlElement(ElementName = "ItemStateID")] +public class ItemState { + public ItemState() { } + + public ItemState(ItemState other) { + ItemStateID = other.ItemStateID; + Name = other.Name; + Rule = new ItemStateRule(other.Rule); + Order = other.Order; + AchievementID = other.AchievementID; + Rewards = other.Rewards.Select(r => new AchievementReward(r)).ToArray(); + } + + [XmlElement(ElementName = "ItemStateID")] public int ItemStateID; [XmlElement(ElementName = "Name")] diff --git a/src/Schema/ItemStateCriteria.cs b/src/Schema/ItemStateCriteria.cs index 9510796..715946f 100644 --- a/src/Schema/ItemStateCriteria.cs +++ b/src/Schema/ItemStateCriteria.cs @@ -10,8 +10,13 @@ namespace sodoff.Schema; [XmlInclude(typeof(ItemStateCriteriaSpeedUpItem))] [XmlInclude(typeof(ItemStateCriteriaExpiry))] [Serializable] -public class ItemStateCriteria -{ - [XmlElement(ElementName = "Type")] +public class ItemStateCriteria { + public ItemStateCriteria() {} + + public ItemStateCriteria(ItemStateCriteria other) { + Type = other.Type; + } + + [XmlElement(ElementName = "Type")] public ItemStateCriteriaType Type; } diff --git a/src/Schema/ItemStateRule.cs b/src/Schema/ItemStateRule.cs index 2685c40..162efb4 100644 --- a/src/Schema/ItemStateRule.cs +++ b/src/Schema/ItemStateRule.cs @@ -4,9 +4,15 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "ItemStateRule", Namespace = "")] [Serializable] -public class ItemStateRule -{ - [XmlElement(ElementName = "Criterias")] +public class ItemStateRule { + public ItemStateRule() {} + + public ItemStateRule(ItemStateRule other) { + Criterias = other.Criterias.Select(c => new ItemStateCriteria(c)).ToList(); + CompletionAction = new CompletionAction(other.CompletionAction); + } + + [XmlElement(ElementName = "Criterias")] public List Criterias; [XmlElement(ElementName = "CompletionAction")] diff --git a/src/Schema/ItemStatsMap.cs b/src/Schema/ItemStatsMap.cs index 0c090bc..280500a 100644 --- a/src/Schema/ItemStatsMap.cs +++ b/src/Schema/ItemStatsMap.cs @@ -4,9 +4,16 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "ISM", Namespace = "", IsNullable = false)] [Serializable] -public class ItemStatsMap -{ - [XmlElement(ElementName = "IID", IsNullable = false)] +public class ItemStatsMap { + public ItemStatsMap() {} + + public ItemStatsMap(ItemStatsMap other) { + ItemID = other.ItemID; + ItemTier = other.ItemTier; + ItemStats = other.ItemStats.Select(s => new ItemStat(s)).ToArray(); + } + + [XmlElement(ElementName = "IID", IsNullable = false)] public int ItemID { get; set; } [XmlElement(ElementName = "IT", IsNullable = false)] diff --git a/src/Schema/Mission.cs b/src/Schema/Mission.cs index 43ecb21..1e49c29 100644 --- a/src/Schema/Mission.cs +++ b/src/Schema/Mission.cs @@ -5,6 +5,30 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "Mission", Namespace = "")] [Serializable] // FIXME: Remove serializable once we have a different way of deep copying than BinaryFormatter public class Mission { + public Mission() {} + + public Mission(Mission other) { + if (other == null) throw new ArgumentNullException(nameof(other)); + MissionID = other.MissionID; + Name = other.Name; + GroupID = other.GroupID; + ParentID = other.ParentID; + Static = other.Static; + Accepted = other.Accepted; + Completed = other.Completed; + Rule = other.Rule; + VersionID = other.VersionID; + AchievementID = other.AchievementID; + AcceptanceAchievementID = other.AcceptanceAchievementID; + Repeatable = other.Repeatable; + MissionRule = new MissionRule(other.MissionRule); + + Missions = other.Missions.Select(m => new Mission(m)).ToList(); + Tasks = other.Tasks.Select(t => new Task(t)).ToList(); + Rewards = other.Rewards.Select(r => new AchievementReward(r)).ToList(); + AcceptanceRewards = other.AcceptanceRewards.Select(a => new AchievementReward(a)).ToList(); + } + [XmlElement(ElementName = "I")] public int MissionID; diff --git a/src/Schema/MissionCriteria.cs b/src/Schema/MissionCriteria.cs index 5ff9d2d..29c867f 100644 --- a/src/Schema/MissionCriteria.cs +++ b/src/Schema/MissionCriteria.cs @@ -5,6 +5,16 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "MissionCriteria", Namespace = "")] [Serializable] public class MissionCriteria { + public MissionCriteria() {} + + public MissionCriteria(MissionCriteria other) { + Type = other.Type; + Ordered = other.Ordered; + Min = other.Min; + Repeat = other.Repeat; + RuleItems = other.RuleItems.Select(r => new RuleItem(r)).ToList(); + } + [XmlElement(ElementName = "Type")] public string Type; diff --git a/src/Schema/MissionRule.cs b/src/Schema/MissionRule.cs index 2a1877f..3a9e6a5 100644 --- a/src/Schema/MissionRule.cs +++ b/src/Schema/MissionRule.cs @@ -5,6 +5,13 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "MissionRule", Namespace = "")] [Serializable] public class MissionRule { + public MissionRule() {} + + public MissionRule(MissionRule other) { + Prerequisites = other.Prerequisites.Select(p => new PrerequisiteItem(p)).ToList(); + Criteria = new MissionCriteria(other.Criteria); + } + [XmlElement(ElementName = "Prerequisites")] public List Prerequisites; diff --git a/src/Schema/Pair.cs b/src/Schema/Pair.cs index c14b803..485d3d8 100644 --- a/src/Schema/Pair.cs +++ b/src/Schema/Pair.cs @@ -4,9 +4,16 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "Pair", Namespace = "")] [Serializable] -public class Pair -{ - [XmlElement(ElementName = "PairKey")] +public class Pair { + public Pair() {} + + public Pair(Pair other) { + PairKey = other.PairKey; + PairValue = other.PairValue; + UpdateDate = other.UpdateDate; + } + + [XmlElement(ElementName = "PairKey")] public string PairKey; [XmlElement(ElementName = "PairValue")] diff --git a/src/Schema/PairData.cs b/src/Schema/PairData.cs index ffb862f..46438ff 100644 --- a/src/Schema/PairData.cs +++ b/src/Schema/PairData.cs @@ -5,6 +5,12 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "Pairs", Namespace = "", IsNullable = true)] [Serializable] public class PairData { + public PairData() {} + + public PairData(PairData other) { + Pairs = other.Pairs.Select(p => new Pair(p)).ToArray(); + } + [XmlElement("Pair", IsNullable = true)] public Pair[] Pairs { get; set; } } \ No newline at end of file diff --git a/src/Schema/PrerequisiteItem.cs b/src/Schema/PrerequisiteItem.cs index 69cb33d..8d555a4 100644 --- a/src/Schema/PrerequisiteItem.cs +++ b/src/Schema/PrerequisiteItem.cs @@ -5,6 +5,15 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "PrerequisiteItem", Namespace = "")] [Serializable] public class PrerequisiteItem { + public PrerequisiteItem() {} + + public PrerequisiteItem(PrerequisiteItem other) { + Type = other.Type; + Value = other.Value; + Quantity = other.Quantity; + ClientRule = other.ClientRule; + } + [XmlElement(ElementName = "Type")] public PrerequisiteRequiredType Type; diff --git a/src/Schema/RuleItem.cs b/src/Schema/RuleItem.cs index 5c106d9..3478454 100644 --- a/src/Schema/RuleItem.cs +++ b/src/Schema/RuleItem.cs @@ -5,6 +5,15 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "RuleItem", Namespace = "")] [Serializable] public class RuleItem { + public RuleItem() {} + + public RuleItem(RuleItem other) { + Type = other.Type; + MissionID = other.MissionID; + ID = other.ID; + Complete = other.Complete; + } + [XmlElement(ElementName = "Type")] public RuleItemType Type; diff --git a/src/Schema/Stat.cs b/src/Schema/Stat.cs index f85fd4b..ea9fc3a 100644 --- a/src/Schema/Stat.cs +++ b/src/Schema/Stat.cs @@ -4,9 +4,18 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "STAT", Namespace = "", IsNullable = false)] [Serializable] -public class Stat -{ - [XmlElement(ElementName = "IID", IsNullable = false)] +public class Stat { + public Stat() {} + + public Stat(Stat other) { + ItemID = other.ItemID; + ItemStatsID = other.ItemStatsID; + SetID = other.SetID; + Probability = other.Probability; + ItemStatsRangeMaps = other.ItemStatsRangeMaps.Select(s => new StatRangeMap(s)).ToList(); + } + + [XmlElement(ElementName = "IID", IsNullable = false)] public int ItemID { get; set; } [XmlElement(ElementName = "ISID", IsNullable = false)] diff --git a/src/Schema/StatRangeMap.cs b/src/Schema/StatRangeMap.cs index 7c74a6b..6b8c7c5 100644 --- a/src/Schema/StatRangeMap.cs +++ b/src/Schema/StatRangeMap.cs @@ -4,9 +4,18 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "SRM", Namespace = "", IsNullable = false)] [Serializable] -public class StatRangeMap -{ - [XmlElement(ElementName = "ISID", IsNullable = false)] +public class StatRangeMap { + public StatRangeMap() {} + + public StatRangeMap(StatRangeMap other) { + ItemStatsID = other.ItemStatsID; + ItemStatsName = other.ItemStatsName; + ItemTierID = other.ItemTierID; + StartRange = other.StartRange; + EndRange = other.EndRange; + } + + [XmlElement(ElementName = "ISID", IsNullable = false)] public int ItemStatsID { get; set; } [XmlElement(ElementName = "ISN", IsNullable = false)] diff --git a/src/Schema/Task.cs b/src/Schema/Task.cs index 1f66a0b..f0f19b6 100644 --- a/src/Schema/Task.cs +++ b/src/Schema/Task.cs @@ -8,6 +8,17 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "Task", Namespace = "")] [Serializable] public class Task { + public Task() {} + + public Task(Task other) { + TaskID = other.TaskID; + Name = other.Name; + Static = other.Static; + Completed = other.Completed; + Failed = other.Failed; + Payload = other.Payload; + } + [XmlElement(ElementName = "I")] public int TaskID; diff --git a/src/Schema/UserItemData.cs b/src/Schema/UserItemData.cs index 4c908e7..1e52f1c 100644 --- a/src/Schema/UserItemData.cs +++ b/src/Schema/UserItemData.cs @@ -4,9 +4,23 @@ namespace sodoff.Schema; [XmlRoot(ElementName = "UserItem", Namespace = "")] [Serializable] -public class UserItemData -{ - [XmlElement(ElementName = "iid")] +public class UserItemData { + public UserItemData() {} + + public UserItemData(UserItemData other) { + ItemID = other.ItemID; + ModifiedDate = other.ModifiedDate; + UserItemAttributes = new PairData(other.UserItemAttributes); + ItemStats = other.ItemStats.Select(stat => new ItemStat(stat)).ToArray(); + ItemTier = other.ItemTier; + CreatedDate = other.CreatedDate; + UserInventoryID = other.UserInventoryID; + Quantity = other.Quantity; + Uses = other.Uses; + Item = new ItemData(other.Item); + } + + [XmlElement(ElementName = "iid")] public int ItemID { get; set; } [XmlElement(ElementName = "md", IsNullable = true)] diff --git a/src/Services/MissionStoreSingleton.cs b/src/Services/MissionStoreSingleton.cs index 09da06f..f25532e 100644 --- a/src/Services/MissionStoreSingleton.cs +++ b/src/Services/MissionStoreSingleton.cs @@ -119,20 +119,8 @@ public class MissionStoreSingleton { } } - // FIXME: Don't use BinaryFormatter for deep copying - // FIXME: Remove flag from the project file once we have a different way of deep copying public static Mission DeepCopy(Mission original) { - using (MemoryStream memoryStream = new MemoryStream()) { - BinaryFormatter formatter = new BinaryFormatter(); - - formatter.Serialize(memoryStream, original); - - memoryStream.Position = 0; - - Mission clone = (Mission)formatter.Deserialize(memoryStream); - - return clone; - } + return new Mission(original); } } diff --git a/src/sodoff.csproj b/src/sodoff.csproj index 83633a9..151699d 100644 --- a/src/sodoff.csproj +++ b/src/sodoff.csproj @@ -4,7 +4,6 @@ net9.0 enable enable - true USE_SQLITE;$(DefineConstants) USE_POSTGRESQL;$(DefineConstants)