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:
parent
4d6e584b6c
commit
e9c1e4cbba
66 changed files with 597 additions and 496 deletions
|
|
@ -19,7 +19,7 @@ namespace Server.Factions
|
|||
{
|
||||
try
|
||||
{
|
||||
return ActivatorUtil.CreateInstance(Definition.Type) as BaseFactionGuard;
|
||||
return Definition.Type.CreateInstance<BaseFactionGuard>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace Server.Factions
|
|||
{
|
||||
try
|
||||
{
|
||||
return ActivatorUtil.CreateInstance(type);
|
||||
return type.CreateInstance<object>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Server.Factions
|
|||
{
|
||||
try
|
||||
{
|
||||
return ActivatorUtil.CreateInstance(Definition.Type, town, faction) as BaseFactionVendor;
|
||||
return Definition.Type.CreateInstance<BaseFactionVendor>(town, faction);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace Server
|
|||
{
|
||||
if (weight < item.Weight)
|
||||
{
|
||||
var obj = item.Construct();
|
||||
var obj = item.Type.CreateInstance<Item>();
|
||||
|
||||
if (obj != null)
|
||||
{
|
||||
|
|
@ -188,8 +188,6 @@ namespace Server
|
|||
public int Weight { get; }
|
||||
|
||||
public Type Type { get; }
|
||||
|
||||
public Item Construct() => ActivatorUtil.CreateInstance(Type) as Item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace Server.Factions
|
|||
{
|
||||
try
|
||||
{
|
||||
return ActivatorUtil.CreateInstance(TrapType, m_Faction, from) as BaseFactionTrap;
|
||||
return TrapType.CreateInstance<BaseFactionTrap>(m_Faction, from);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ namespace Server.Factions
|
|||
if (entry.Chance > Utility.Random(100))
|
||||
{
|
||||
releaseTime = DateTime.UtcNow + entry.Hold;
|
||||
return (Spell)ActivatorUtil.CreateInstance(entry.Spell, mob, null);
|
||||
return entry.Spell.CreateInstance<Spell>(mob, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -406,9 +406,9 @@ namespace Server.Factions
|
|||
{
|
||||
if (m_Mobile.Target != null)
|
||||
m_Mobile.Target.Cancel( m_Mobile, TargetCancelType.Canceled );
|
||||
|
||||
|
||||
new TeleportSpell( m_Mobile, null ).Cast();
|
||||
|
||||
|
||||
m_Mobile.DebugSay( "I am stuck, I'm going to try teleporting away" );
|
||||
}
|
||||
else*/
|
||||
|
|
@ -744,7 +744,7 @@ namespace Server.Factions
|
|||
}
|
||||
else if (types.Count == 1)
|
||||
{
|
||||
spell = ActivatorUtil.CreateInstance(types[0], m_Guard, null) as Spell;
|
||||
spell = types[0].CreateInstance<Spell>(m_Guard, null);
|
||||
}
|
||||
}
|
||||
else if (types.Count > 0)
|
||||
|
|
@ -796,7 +796,7 @@ namespace Server.Factions
|
|||
}
|
||||
else if (types.Count == 1)
|
||||
{
|
||||
spell = (Spell)ActivatorUtil.CreateInstance(types[0], m_Guard, null);
|
||||
spell = types[0].CreateInstance<Spell>(m_Guard, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -804,24 +804,14 @@ namespace Server.Factions
|
|||
|
||||
if (spell != null && m_Guard.HitsMax - m_Guard.Hits + 10 > Utility.Random(100))
|
||||
{
|
||||
Type type = null;
|
||||
|
||||
if (spell is GreaterHealSpell)
|
||||
Type type = spell switch
|
||||
{
|
||||
type = typeof(BaseHealPotion);
|
||||
}
|
||||
else if (spell is CureSpell)
|
||||
{
|
||||
type = typeof(BaseCurePotion);
|
||||
}
|
||||
else if (spell is StrengthSpell)
|
||||
{
|
||||
type = typeof(BaseStrengthPotion);
|
||||
}
|
||||
else if (spell is AgilitySpell)
|
||||
{
|
||||
type = typeof(BaseAgilityPotion);
|
||||
}
|
||||
GreaterHealSpell _ => typeof(BaseHealPotion),
|
||||
CureSpell _ => typeof(BaseCurePotion),
|
||||
StrengthSpell _ => typeof(BaseStrengthPotion),
|
||||
AgilitySpell _ => typeof(BaseAgilityPotion),
|
||||
_ => null
|
||||
};
|
||||
|
||||
if (type == typeof(BaseHealPotion) && !m_Guard.CanBeginAction(type))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue