fix: Removes the old ore info. (#1247)

This commit is contained in:
Kamron Batman 2022-11-13 00:41:26 -08:00 committed by GitHub
parent d8cfb6b935
commit e66efefff3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 179 deletions

View file

@ -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)

View file

@ -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() =>

View file

@ -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)

View file

@ -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)

View file

@ -861,98 +861,5 @@ namespace Server.Items
return info == null ? string.Empty : info.Name;
}
/// <summary>
/// Returns the <see cref="CraftResource" /> value which represents '<paramref name="info" />' -or- CraftResource.None if
/// unable to convert.
/// </summary>
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
};
}
/// <summary>
/// Returns the <see cref="CraftResource" /> value which represents '<paramref name="info" />', using '
/// <paramref name="material" />' to help resolve leather OreInfo instances.
/// </summary>
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; }
}
}