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

@ -451,18 +451,18 @@ namespace Server.Items
if (type != null)
{
object obj;
IEntity entity;
try
{
obj = ActivatorUtil.CreateInstance(type);
entity = type.CreateInstance<IEntity>();
}
catch
{
obj = null;
entity = null;
}
if (obj is Item item)
if (entity is Item item)
{
var count = 1;
@ -492,7 +492,7 @@ namespace Server.Items
if (i + 1 < count)
{
item = ActivatorUtil.CreateInstance(type) as Item;
item = type.CreateInstance<Item>();
}
}
@ -513,7 +513,7 @@ namespace Server.Items
from.SendLocalizedMessage(1074853, m_Summoner.Name.ToString()); // You have been given ~1_name~
}
}
else if (obj is BaseCreature mob)
else if (entity is BaseCreature mob)
{
if (m_Creature?.Deleted == false || from.Followers + mob.ControlSlots > from.FollowersMax)
{
@ -536,6 +536,10 @@ namespace Server.Items
m_Creature = mob;
}
else
{
entity?.Delete();
}
OnAfterUse(from);
}