Modernization Fixes & Updates to Default Values (#3)

This commit is contained in:
Kamron Batman 2018-10-28 00:33:16 -07:00 • committed by GitHub
parent 445eddff68
commit dcf64091b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
768 changed files with 10507 additions and 14196 deletions

View file

@ -1,6 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Server.Commands.Generic;
using Server.Network;
@ -125,7 +125,7 @@ namespace Server.Gumps
private static Type typeofCPA = typeof(CPA);
private static Type typeofObject = typeof(object);
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -162,7 +162,7 @@ namespace Server.Gumps
Initialize(0);
}
public PropertiesGump(Mobile mobile, object o, Stack<StackEntry> stack, ArrayList list, int page) : base(GumpOffsetX,
public PropertiesGump(Mobile mobile, object o, Stack<StackEntry> stack, List<object> list, int page) : base(GumpOffsetX,
GumpOffsetY)
{
m_Mobile = mobile;
@ -385,7 +385,7 @@ namespace Server.Gumps
else if (IsType(type, typeofMap))
{
from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List,
Map.GetMapNames(), Map.GetMapValues()));
Map.GetMapNames(), Map.GetMapValues().ToArray<object>()));
}
else if (IsType(type, typeofSkills) && m_Object is Mobile mobile)
{
@ -513,30 +513,29 @@ namespace Server.Gumps
return o.ToString();
}
private ArrayList BuildList()
private List<object> BuildList()
{
ArrayList list = new ArrayList();
List<object> list = new List<object>();
if (m_Type == null)
return list;
PropertyInfo[] props = m_Type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);
ArrayList groups = GetGroups(m_Type, props);
List<KeyValuePair<Type, List<PropertyInfo>>> groups = GetGroups(m_Type, props);
for (int i = 0; i < groups.Count; ++i)
{
DictionaryEntry de = (DictionaryEntry)groups[i];
ArrayList groupList = (ArrayList)de.Value;
KeyValuePair<Type, List<PropertyInfo>> kvp = groups[i];
if (!HasAttribute((Type)de.Key, typeofNoSort, false))
groupList.Sort(PropertySorter.Instance);
if (!HasAttribute(kvp.Key, typeofNoSort, false))
kvp.Value.Sort(PropertySorter.Instance);
if (i != 0)
list.Add(null);
list.Add(de.Key);
list.AddRange(groupList);
list.Add(kvp.Key);
list.AddRange(kvp.Value);
}
return list;
@ -551,9 +550,9 @@ namespace Server.Gumps
return null;
}
private ArrayList GetGroups(Type objectType, PropertyInfo[] props)
private List<KeyValuePair<Type, List<PropertyInfo>>> GetGroups(Type objectType, PropertyInfo[] props)
{
Hashtable groups = new Hashtable();
Dictionary<Type, List<PropertyInfo>> groups = new Dictionary<Type, List<PropertyInfo>>();
for (int i = 0; i < props.Length; ++i)
{
@ -569,32 +568,24 @@ namespace Server.Gumps
while (true)
{
Type baseType = type.BaseType;
Type baseType = type?.BaseType;
if (baseType == null || baseType == typeofObject)
break;
if (baseType.GetProperty(prop.Name, prop.PropertyType) != null)
type = baseType;
else
if (baseType == typeofObject || baseType?.GetProperty(prop.Name, prop.PropertyType) == null)
break;
type = baseType;
}
ArrayList list = (ArrayList)groups[type];
if (list == null)
groups[type] = list = new ArrayList();
list.Add(prop);
if (type != null && !groups.ContainsKey(type))
groups[type] = new List<PropertyInfo>{ prop };
}
}
}
ArrayList sorted = new ArrayList(groups);
List<KeyValuePair<Type, List<PropertyInfo>>> list = groups.ToList();
list.Sort(new GroupComparer(objectType));
sorted.Sort(new GroupComparer(objectType));
return sorted;
return list;
}
public static object GetObjectFromString(Type t, string s)
@ -652,7 +643,7 @@ namespace Server.Gumps
return o.ToString();
}
private class PropertySorter : IComparer
private class PropertySorter : IComparer<PropertyInfo>
{
public static readonly PropertySorter Instance = new PropertySorter();
@ -660,28 +651,19 @@ namespace Server.Gumps
{
}
public int Compare(object x, object y)
public int Compare(PropertyInfo x, PropertyInfo y)
{
if (x == null && y == null)
return 0;
if (x == null)
return -1;
if (y == null)
return 1;
PropertyInfo a = x as PropertyInfo;
PropertyInfo b = y as PropertyInfo;
if (a == null || b == null)
throw new ArgumentException();
return a.Name.CompareTo(b.Name);
return y == null ? 1 : x.Name.CompareTo(x.Name);
}
}
private class GroupComparer : IComparer
{
private static Type typeofObject = typeof(object);
private class GroupComparer : IComparer<KeyValuePair<Type, List<PropertyInfo>>>
{
private Type m_Start;
public GroupComparer(Type start)
@ -689,22 +671,9 @@ namespace Server.Gumps
m_Start = start;
}
public int Compare(object x, object y)
public int Compare(KeyValuePair<Type, List<PropertyInfo>> x, KeyValuePair<Type, List<PropertyInfo>> y)
{
if (x == null && y == null)
return 0;
if (x == null)
return -1;
if (y == null)
return 1;
if (!(x is DictionaryEntry) || !(y is DictionaryEntry))
throw new ArgumentException();
DictionaryEntry de1 = (DictionaryEntry)x;
DictionaryEntry de2 = (DictionaryEntry)y;
return GetDistance((Type)de1.Key).CompareTo(GetDistance((Type)de2.Key));
return GetDistance(x.Key).CompareTo(GetDistance(y.Key));
}
private int GetDistance(Type type)

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -13,24 +12,19 @@ namespace Server.Gumps
private const int SelectedColor32 = 0x8080FF;
private const int TextColor32 = 0xFFFFFF;
private static ArrayList m_Monster, m_Animal, m_Sea, m_Human;
private ArrayList m_List;
private static List<InternalEntry> m_Monster, m_Animal, m_Sea, m_Human;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private ArrayList m_OurList;
private List<InternalEntry> m_OurList;
private int m_OurPage;
private ModelBodyType m_OurType;
private int m_Page;
private PropertyInfo m_Property;
private Stack<StackEntry> m_Stack;
public SetBodyGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list)
: this(prop, mobile, o, stack, page, list, 0, null, ModelBodyType.Invalid)
{
}
public SetBodyGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list,
int ourPage, ArrayList ourList, ModelBodyType ourType)
public SetBodyGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list,
int ourPage = 0, List<InternalEntry> ourList = null, ModelBodyType ourType = ModelBodyType.Invalid)
: base(20, 30)
{
m_Property = prop;
@ -73,7 +67,7 @@ namespace Server.Gumps
{
for (int i = 0, index = ourPage * 12; i < 12 && index >= 0 && index < ourList.Count; ++i, ++index)
{
InternalEntry entry = (InternalEntry)ourList[index];
InternalEntry entry = ourList[index];
int itemID = entry.ItemID;
Rectangle2D bounds = ItemBounds.Table[itemID & 0x3FFF];
@ -134,7 +128,7 @@ namespace Server.Gumps
LoadLists();
ModelBodyType type;
ArrayList list;
List<InternalEntry> list;
switch (index)
{
@ -181,7 +175,7 @@ namespace Server.Gumps
{
try
{
InternalEntry entry = (InternalEntry)m_OurList[index];
InternalEntry entry = m_OurList[index];
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, entry.Body.ToString());
m_Property.SetValue(m_Object, entry.Body, null);
@ -201,10 +195,10 @@ namespace Server.Gumps
private static void LoadLists()
{
m_Monster = new ArrayList();
m_Animal = new ArrayList();
m_Sea = new ArrayList();
m_Human = new ArrayList();
m_Monster = new List<InternalEntry>();
m_Animal = new List<InternalEntry>();
m_Sea = new List<InternalEntry>();
m_Human = new List<InternalEntry>();
List<BodyEntry> entries = Docs.LoadBodies();
@ -216,10 +210,11 @@ namespace Server.Gumps
if (((Body)bodyID).IsEmpty)
continue;
ArrayList list = null;
List<InternalEntry> list;
switch (oldEntry.BodyType)
{
default: continue;
case ModelBodyType.Monsters:
list = m_Monster;
break;
@ -234,9 +229,6 @@ namespace Server.Gumps
break;
}
if (list == null)
continue;
int itemID = ShrinkTable.Lookup(bodyID, -1);
if (itemID != -1)
@ -249,7 +241,7 @@ namespace Server.Gumps
m_Human.Sort();
}
private class InternalEntry : IComparable
public class InternalEntry : IComparable<InternalEntry>
{
private static string[] m_GroupNames =
{
@ -296,10 +288,8 @@ namespace Server.Gumps
public string DisplayName{ get; }
public int CompareTo(object obj)
public int CompareTo(InternalEntry comp)
{
InternalEntry comp = (InternalEntry)obj;
int v = Name.CompareTo(comp.Name);
if (v == 0)

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -12,7 +11,7 @@ namespace Server.Gumps
private string[] m_Names;
public SetCustomEnumGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int propspage,
ArrayList list, string[] names) : base(prop, mobile, o, stack, propspage, list, names, null)
List<object> list, string[] names) : base(prop, mobile, o, stack, propspage, list, names, null)
{
m_Names = names;
}
@ -26,7 +25,7 @@ namespace Server.Gumps
{
MethodInfo info = m_Property.PropertyType.GetMethod("Parse", new[] { typeof(string) });
string result = "";
string result;
if (info != null)
result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name,
@ -34,6 +33,8 @@ namespace Server.Gumps
else if (m_Property.PropertyType == typeof(Enum) || m_Property.PropertyType.IsSubclassOf(typeof(Enum)))
result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name,
Enum.Parse(m_Property.PropertyType, m_Names[index], false), true);
else
result = "";
m_Mobile.SendMessage(result);

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -50,14 +49,14 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
private PropertyInfo m_Property;
private Stack<StackEntry> m_Stack;
public SetGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list) : base(
public SetGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list) : base(
GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
@ -246,7 +245,7 @@ namespace Server.Gumps
private class InternalPicker : HuePicker
{
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -254,7 +253,7 @@ namespace Server.Gumps
private Stack<StackEntry> m_Stack;
public InternalPicker(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
ArrayList list) : base(((IHued)o).HuedItemID)
List<object> list) : base(((IHued)o).HuedItemID)
{
m_Property = prop;
m_Mobile = mobile;

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -56,17 +55,17 @@ namespace Server.Gumps
private static readonly int NextLabelOffsetX = -29;
private static readonly int NextLabelOffsetY = 0;
protected ArrayList m_List;
protected List<object> m_List;
protected Mobile m_Mobile;
protected object m_Object;
protected int m_Page;
protected PropertyInfo m_Property;
protected Stack<StackEntry> m_Stack;
protected object[] m_Values;
private object[] m_Values;
public SetListOptionGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int propspage,
ArrayList list, string[] names, object[] values) : base(GumpOffsetX, GumpOffsetY)
List<object> list, string[] names, object[] values) : base(GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
m_Mobile = mobile;

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -52,7 +51,7 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -61,7 +60,7 @@ namespace Server.Gumps
private Type m_Type;
public SetObjectGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
ArrayList list) : base(GumpOffsetX, GumpOffsetY)
List<object> list) : base(GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
m_Mobile = mobile;
@ -204,7 +203,7 @@ namespace Server.Gumps
private class InternalPrompt : Prompt
{
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -213,7 +212,7 @@ namespace Server.Gumps
private Type m_Type;
public InternalPrompt(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
ArrayList list)
List<object> list)
{
m_Property = prop;
m_Mobile = mobile;
@ -233,7 +232,7 @@ namespace Server.Gumps
{
try
{
int serial = Utility.ToInt32(text);
uint serial = Utility.ToUInt32(text);
IEntity toSet = World.FindEntity(serial);

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -10,7 +9,7 @@ namespace Server.Gumps
{
public class SetObjectTarget : Target
{
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -19,7 +18,7 @@ namespace Server.Gumps
private Type m_Type;
public SetObjectTarget(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
ArrayList list) : base(-1, false, TargetFlags.None)
List<object> list) : base(-1, false, TargetFlags.None)
{
m_Property = prop;
m_Mobile = mobile;
@ -37,8 +36,8 @@ namespace Server.Gumps
if (m_Type == typeof(Type))
targeted = targeted.GetType();
else if ((m_Type == typeof(BaseAddon) || m_Type.IsAssignableFrom(typeof(BaseAddon))) &&
targeted is AddonComponent)
targeted = ((AddonComponent)targeted).Addon;
targeted is AddonComponent addonComponent)
targeted = addonComponent.Addon;
if (m_Type.IsInstanceOfType(targeted))
{

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -51,14 +50,14 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
private PropertyInfo m_Property;
private Stack<StackEntry> m_Stack;
public SetPoint2DGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list)
public SetPoint2DGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list)
: base(GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
@ -190,7 +189,7 @@ namespace Server.Gumps
private class InternalTarget : Target
{
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -198,7 +197,7 @@ namespace Server.Gumps
private Stack<StackEntry> m_Stack;
public InternalTarget(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
ArrayList list) : base(-1, true, TargetFlags.None)
List<object> list) : base(-1, true, TargetFlags.None)
{
m_Property = prop;
m_Mobile = mobile;

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -51,14 +50,14 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
private PropertyInfo m_Property;
private Stack<StackEntry> m_Stack;
public SetPoint3DGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list)
public SetPoint3DGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list)
: base(GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
@ -197,7 +196,7 @@ namespace Server.Gumps
private class InternalTarget : Target
{
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -205,7 +204,7 @@ namespace Server.Gumps
private Stack<StackEntry> m_Stack;
public InternalTarget(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
ArrayList list) : base(-1, true, TargetFlags.None)
List<object> list) : base(-1, true, TargetFlags.None)
{
m_Property = prop;
m_Mobile = mobile;

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -50,14 +49,14 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
private PropertyInfo m_Property;
private Stack<StackEntry> m_Stack;
public SetTimeSpanGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list)
public SetTimeSpanGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list)
: base(GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
@ -127,7 +126,7 @@ namespace Server.Gumps
{
bool successfulParse = false;
if (h != null && m != null && s != null)
successfulParse = TimeSpan.TryParse(h.Text + ":" + m.Text + ":" + s.Text, out toSet);
successfulParse = TimeSpan.TryParse($"{h.Text}:{m.Text}:{s.Text}", out toSet);
else
toSet = TimeSpan.Zero;
@ -148,6 +147,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
toSet = TimeSpan.Zero;
@ -169,6 +169,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
toSet = TimeSpan.Zero;
@ -190,6 +191,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
toSet = TimeSpan.Zero;