Fixes dupe exception (#258)

- [X] Cleans up ActivatorUtil
- [X] Fixes dupe exception
- [X] Fixes a bug in BasePotion
- [X] Fixes a few possible memory leaks

Bumps release version
This commit is contained in:
Kamron Batman 2020-09-19 15:46:07 -07:00 • committed by GitHub
parent 4d6e584b6c
commit e9c1e4cbba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 597 additions and 496 deletions

View file

@ -5,7 +5,7 @@ using Server.Utilities;
namespace Server.Commands
{
public class Dupe
public static class Dupe
{
public static void Initialize()
{
@ -111,7 +111,7 @@ namespace Server.Commands
pack = from.Backpack;
}
var c = ActivatorUtil.GetConstructor(copy.GetType());
var c = copy.GetType().GetConstructor();
if (c != null)
{
var paramList = c.GetParameters();
@ -128,7 +128,7 @@ namespace Server.Commands
{
if (c.Invoke(args) is Item newItem)
{
CopyProperties(newItem, copy); // copy.Dupe( item, copy.Amount );
CopyProperties(newItem, copy);
copy.OnAfterDuped(newItem);
newItem.Parent = null;
@ -166,7 +166,7 @@ namespace Server.Commands
if (!done)
{
from.SendMessage("Unable to dupe. Item must have a 0 parameter constructor.");
from.SendMessage("Unable to dupe. Item must have a constructor with zero required parameters.");
}
}
}

View file

@ -563,7 +563,7 @@ namespace Server.Commands.Generic
var conditionalType = typeBuilder.CreateType();
return (IConditional)ActivatorUtil.CreateInstance(conditionalType);
return conditionalType.CreateInstance<IConditional>();
}
}
}

View file

@ -248,7 +248,7 @@ namespace Server.Commands.Generic
var comparerType = typeBuilder.CreateType();
return (IComparer<T>)ActivatorUtil.CreateInstance(comparerType);
return comparerType.CreateInstance<IComparer<T>>();
}
}
}

View file

@ -161,7 +161,7 @@ namespace Server.Commands.Generic
}
var comparerType = typeBuilder.CreateType();
return (IComparer<T>)ActivatorUtil.CreateInstance(comparerType);
return comparerType.CreateInstance<IComparer<T>>();
}
}
}

View file

@ -300,7 +300,7 @@ namespace Server.Commands
public CategoryTypeEntry(Type type)
{
Type = type;
Object = ActivatorUtil.CreateInstance(type);
Object = type.CreateInstance<object>();
}
public Type Type { get; }

View file

@ -405,11 +405,11 @@ namespace Server.Commands
if (fill)
{
item = (Item)ActivatorUtil.CreateInstance(m_Type, content);
item = m_Type.CreateInstance<Item>(content);
}
else
{
item = (Item)ActivatorUtil.CreateInstance(m_Type);
item = m_Type.CreateInstance<Item>();
}
}
else if (m_Type.IsSubclassOf(typeofBaseDoor))
@ -430,11 +430,11 @@ namespace Server.Commands
}
}
item = (Item)ActivatorUtil.CreateInstance(m_Type, facing);
item = m_Type.CreateInstance<Item>(facing);
}
else
{
item = (Item)ActivatorUtil.CreateInstance(m_Type);
item = m_Type.CreateInstance<Item>();
}
}
catch (Exception e)

View file

@ -402,11 +402,11 @@ namespace Server.Commands
if (fill)
{
item = (Item)ActivatorUtil.CreateInstance(m_Type, content);
item = m_Type.CreateInstance<Item>(content);
}
else
{
item = (Item)ActivatorUtil.CreateInstance(m_Type);
item = m_Type.CreateInstance<Item>();
}
}
else if (m_Type.IsSubclassOf(typeofBaseDoor))
@ -427,11 +427,11 @@ namespace Server.Commands
}
}
item = (Item)ActivatorUtil.CreateInstance(m_Type, facing);
item = m_Type.CreateInstance<Item>(facing);
}
else
{
item = (Item)ActivatorUtil.CreateInstance(m_Type);
item = m_Type.CreateInstance<Item>();
}
}
catch (Exception e)