Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -145,7 +145,7 @@ namespace Server.Items
|
|||
|
||||
Amount--;
|
||||
|
||||
if (from.Backpack != null && !from.Backpack.Deleted)
|
||||
if (from.Backpack?.Deleted != false)
|
||||
from.Backpack.DropItem(pot);
|
||||
else
|
||||
pot.MoveToWorld(from.Location, from.Map);
|
||||
|
|
@ -260,4 +260,4 @@ namespace Server.Items
|
|||
base.StackWith(from, potion, playSound);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Spells;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -260,19 +260,12 @@ namespace Server.Items
|
|||
if (m_Item.Map == null || from == null)
|
||||
return;
|
||||
|
||||
List<Mobile> mobiles = new List<Mobile>();
|
||||
|
||||
foreach (Mobile mobile in m_Item.GetMobilesInRange(0))
|
||||
mobiles.Add(mobile);
|
||||
|
||||
for (int i = 0; i < mobiles.Count; i++)
|
||||
foreach (Mobile m in m_Item.GetMobilesInRange(0))
|
||||
{
|
||||
Mobile m = mobiles[i];
|
||||
|
||||
if (m.Z + 16 > m_Item.Z && m_Item.Z + 12 > m.Z && (!Core.AOS || m != from) &&
|
||||
SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false))
|
||||
{
|
||||
from?.DoHarmful(m);
|
||||
from.DoHarmful(m);
|
||||
|
||||
AOS.Damage(m, from, m_Item.GetDamage(), 0, 100, 0, 0, 0);
|
||||
m.PlaySound(0x208);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Misc;
|
||||
using Server.Mobiles;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Network;
|
||||
using Server.Spells;
|
||||
using Server.Targeting;
|
||||
|
|
@ -175,22 +176,17 @@ namespace Server.Items
|
|||
alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10));
|
||||
|
||||
IPooledEnumerable<IEntity> eable = map.GetObjectsInRange(loc, ExplosionRange, LeveledExplosion);
|
||||
List<IEntity> toExplode = new List<IEntity>();
|
||||
|
||||
int toDamage = 0;
|
||||
|
||||
foreach (IEntity o in eable)
|
||||
if (o is Mobile mobile && (from == null ||
|
||||
SpellHelper.ValidIndirectTarget(from, mobile) &&
|
||||
from.CanBeHarmful(mobile, false)))
|
||||
{
|
||||
toExplode.Add(mobile);
|
||||
++toDamage;
|
||||
}
|
||||
else if (o is BaseExplosionPotion && o != this)
|
||||
{
|
||||
toExplode.Add(o);
|
||||
}
|
||||
List<IEntity> toExplode = eable.Where(o =>
|
||||
{
|
||||
if (!(o is Mobile mobile) || from != null &&
|
||||
(!SpellHelper.ValidIndirectTarget(from, mobile) || !from.CanBeHarmful(mobile, false)))
|
||||
return o is BaseExplosionPotion && o != this;
|
||||
|
||||
++toDamage;
|
||||
return true;
|
||||
}).ToList();
|
||||
|
||||
eable.Free();
|
||||
|
||||
|
|
@ -199,7 +195,7 @@ namespace Server.Items
|
|||
|
||||
for (int i = 0; i < toExplode.Count; ++i)
|
||||
{
|
||||
object o = toExplode[i];
|
||||
IEntity o = toExplode[i];
|
||||
|
||||
if (o is Mobile m)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue