From e66efefff3ca87c7402c3214b7e39df81bb43ab6 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 13 Nov 2022 00:41:26 -0800 Subject: [PATCH] fix: Removes the old ore info. (#1247) --- .../Items/Resources/Blacksmithing/Ingots.cs | 28 +----- .../Items/Resources/Blacksmithing/Ore.cs | 32 +------ .../UOContent/Items/Resources/Tailor/Hides.cs | 16 +--- .../Items/Resources/Tailor/Leathers.cs | 16 +--- Projects/UOContent/Misc/ResourceInfo.cs | 93 ------------------- 5 files changed, 6 insertions(+), 179 deletions(-) diff --git a/Projects/UOContent/Items/Resources/Blacksmithing/Ingots.cs b/Projects/UOContent/Items/Resources/Blacksmithing/Ingots.cs index acffef1db..3b6fcec7e 100644 --- a/Projects/UOContent/Items/Resources/Blacksmithing/Ingots.cs +++ b/Projects/UOContent/Items/Resources/Blacksmithing/Ingots.cs @@ -39,33 +39,7 @@ namespace Server.Items private void Deserialize(IGenericReader reader, int version) { - switch (version) - { - case 1: - { - _resource = (CraftResource)reader.ReadInt(); - break; - } - case 0: - { - var info = reader.ReadInt() switch - { - 0 => OreInfo.Iron, - 1 => OreInfo.DullCopper, - 2 => OreInfo.ShadowIron, - 3 => OreInfo.Copper, - 4 => OreInfo.Bronze, - 5 => OreInfo.Gold, - 6 => OreInfo.Agapite, - 7 => OreInfo.Verite, - 8 => OreInfo.Valorite, - _ => null - }; - - _resource = CraftResources.GetFromOreInfo(info); - break; - } - } + _resource = (CraftResource)reader.ReadInt(); } public override void AddNameProperty(IPropertyList list) diff --git a/Projects/UOContent/Items/Resources/Blacksmithing/Ore.cs b/Projects/UOContent/Items/Resources/Blacksmithing/Ore.cs index a48084ec7..1f076db1e 100644 --- a/Projects/UOContent/Items/Resources/Blacksmithing/Ore.cs +++ b/Projects/UOContent/Items/Resources/Blacksmithing/Ore.cs @@ -39,35 +39,9 @@ namespace Server.Items private void Deserialize(IGenericReader reader, int version) { - switch (version) - { - case 1: - { - // Use this line instead if you are getting world loading issues - _resource = (CraftResource)reader.ReadByte(); - // _resource = (CraftResource)reader.ReadInt(); - break; - } - case 0: - { - var info = reader.ReadInt() switch - { - 0 => OreInfo.Iron, - 1 => OreInfo.DullCopper, - 2 => OreInfo.ShadowIron, - 3 => OreInfo.Copper, - 4 => OreInfo.Bronze, - 5 => OreInfo.Gold, - 6 => OreInfo.Agapite, - 7 => OreInfo.Verite, - 8 => OreInfo.Valorite, - _ => null - }; - - _resource = CraftResources.GetFromOreInfo(info); - break; - } - } + // Use this line instead if you are getting world loading issues + _resource = (CraftResource)reader.ReadByte(); + // _resource = (CraftResource)reader.ReadInt(); } private static int RandomSize() => diff --git a/Projects/UOContent/Items/Resources/Tailor/Hides.cs b/Projects/UOContent/Items/Resources/Tailor/Hides.cs index e9dbc9cda..4e4b1f6e4 100644 --- a/Projects/UOContent/Items/Resources/Tailor/Hides.cs +++ b/Projects/UOContent/Items/Resources/Tailor/Hides.cs @@ -38,21 +38,7 @@ namespace Server.Items private void Deserialize(IGenericReader reader, int version) { - switch (version) - { - case 1: - { - _resource = (CraftResource)reader.ReadInt(); - break; - } - case 0: - { - var info = new OreInfo(reader.ReadInt(), reader.ReadInt(), reader.ReadString()); - - _resource = CraftResources.GetFromOreInfo(info); - break; - } - } + _resource = (CraftResource)reader.ReadInt(); } public override void AddNameProperty(IPropertyList list) diff --git a/Projects/UOContent/Items/Resources/Tailor/Leathers.cs b/Projects/UOContent/Items/Resources/Tailor/Leathers.cs index 2431b26a7..9af30b92e 100644 --- a/Projects/UOContent/Items/Resources/Tailor/Leathers.cs +++ b/Projects/UOContent/Items/Resources/Tailor/Leathers.cs @@ -38,21 +38,7 @@ namespace Server.Items private void Deserialize(IGenericReader reader, int version) { - switch (version) - { - case 1: - { - _resource = (CraftResource)reader.ReadInt(); - break; - } - case 0: - { - var info = new OreInfo(reader.ReadInt(), reader.ReadInt(), reader.ReadString()); - - _resource = CraftResources.GetFromOreInfo(info); - break; - } - } + _resource = (CraftResource)reader.ReadInt(); } public override void AddNameProperty(IPropertyList list) diff --git a/Projects/UOContent/Misc/ResourceInfo.cs b/Projects/UOContent/Misc/ResourceInfo.cs index 601436d56..838dc1314 100644 --- a/Projects/UOContent/Misc/ResourceInfo.cs +++ b/Projects/UOContent/Misc/ResourceInfo.cs @@ -861,98 +861,5 @@ namespace Server.Items return info == null ? string.Empty : info.Name; } - - /// - /// Returns the value which represents '' -or- CraftResource.None if - /// unable to convert. - /// - public static CraftResource GetFromOreInfo(OreInfo info) - { - if (info.Name.ContainsOrdinal("Spined")) - { - return CraftResource.SpinedLeather; - } - - if (info.Name.ContainsOrdinal("Horned")) - { - return CraftResource.HornedLeather; - } - - if (info.Name.ContainsOrdinal("Barbed")) - { - return CraftResource.BarbedLeather; - } - - if (info.Name.ContainsOrdinal("Leather")) - { - return CraftResource.RegularLeather; - } - - return info.Level switch - { - 0 => CraftResource.Iron, - 1 => CraftResource.DullCopper, - 2 => CraftResource.ShadowIron, - 3 => CraftResource.Copper, - 4 => CraftResource.Bronze, - 5 => CraftResource.Gold, - 6 => CraftResource.Agapite, - 7 => CraftResource.Verite, - 8 => CraftResource.Valorite, - _ => CraftResource.None - }; - } - - /// - /// Returns the value which represents '', using ' - /// ' to help resolve leather OreInfo instances. - /// - public static CraftResource GetFromOreInfo(OreInfo info, ArmorMaterialType material) - { - if (material != ArmorMaterialType.Studded && material != ArmorMaterialType.Leather && - material != ArmorMaterialType.Spined && material != ArmorMaterialType.Horned && - material != ArmorMaterialType.Barbed) - { - return GetFromOreInfo(info); - } - - return info.Level switch - { - 0 => CraftResource.RegularLeather, - 1 => CraftResource.SpinedLeather, - 2 => CraftResource.HornedLeather, - 3 => CraftResource.BarbedLeather, - _ => CraftResource.None - }; - - } - } - - // NOTE: This class is only for compatibility with very old RunUO versions. - // No changes to it should be required for custom resources. - public class OreInfo - { - public static readonly OreInfo Iron = new(0, 0x000, "Iron"); - public static readonly OreInfo DullCopper = new(1, 0x973, "Dull Copper"); - public static readonly OreInfo ShadowIron = new(2, 0x966, "Shadow Iron"); - public static readonly OreInfo Copper = new(3, 0x96D, "Copper"); - public static readonly OreInfo Bronze = new(4, 0x972, "Bronze"); - public static readonly OreInfo Gold = new(5, 0x8A5, "Gold"); - public static readonly OreInfo Agapite = new(6, 0x979, "Agapite"); - public static readonly OreInfo Verite = new(7, 0x89F, "Verite"); - public static readonly OreInfo Valorite = new(8, 0x8AB, "Valorite"); - - public OreInfo(int level, int hue, string name) - { - Level = level; - Hue = hue; - Name = name; - } - - public int Level { get; } - - public int Hue { get; } - - public string Name { get; } } }