Fixes bad expressions, bad bool checks in loops, a few null pointer exceptions, and optimizes constructors.
This commit is contained in:
parent
8da55d6043
commit
f93c3b992e
62 changed files with 318 additions and 634 deletions
|
|
@ -126,7 +126,7 @@ namespace Server.Items
|
|||
armor.ColdBonus =
|
||||
armor.PoisonBonus = armor.EnergyBonus = 0; // Is there a method to remove bonuses?
|
||||
}
|
||||
else if (weapon != null)
|
||||
else
|
||||
{
|
||||
weapon.Quality = WeaponQuality.Regular;
|
||||
weapon.Crafter = from;
|
||||
|
|
|
|||
|
|
@ -488,44 +488,32 @@ namespace Server.Items
|
|||
public static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair,
|
||||
List<Item> initialContent, List<Item> equipItems)
|
||||
{
|
||||
bool shouldFillCorpse = true;
|
||||
|
||||
//if ( owner is BaseCreature )
|
||||
// shouldFillCorpse = !((BaseCreature)owner).IsBonded;
|
||||
|
||||
Corpse c;
|
||||
if (owner is MilitiaFighter)
|
||||
c = new MilitiaFighterCorpse(owner, hair, facialhair, shouldFillCorpse ? equipItems : new List<Item>());
|
||||
c = new MilitiaFighterCorpse(owner, hair, facialhair, equipItems);
|
||||
else
|
||||
c = new Corpse(owner, hair, facialhair, shouldFillCorpse ? equipItems : new List<Item>());
|
||||
c = new Corpse(owner, hair, facialhair, equipItems);
|
||||
|
||||
owner.Corpse = c;
|
||||
|
||||
if (shouldFillCorpse)
|
||||
|
||||
for (int i = 0; i < initialContent.Count; ++i)
|
||||
{
|
||||
for (int i = 0; i < initialContent.Count; ++i)
|
||||
{
|
||||
Item item = initialContent[i];
|
||||
Item item = initialContent[i];
|
||||
|
||||
if (Core.AOS && owner.Player && item.Parent == owner.Backpack)
|
||||
c.AddItem(item);
|
||||
else
|
||||
c.DropItem(item);
|
||||
if (Core.AOS && owner.Player && item.Parent == owner.Backpack)
|
||||
c.AddItem(item);
|
||||
else
|
||||
c.DropItem(item);
|
||||
|
||||
if (owner.Player && Core.AOS)
|
||||
c.SetRestoreInfo(item, item.Location);
|
||||
}
|
||||
|
||||
if (Core.SE && !owner.Player)
|
||||
c.AssignInstancedLoot();
|
||||
else if (Core.AOS && owner is PlayerMobile pm)
|
||||
c.RestoreEquip = pm.EquipSnapshot;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.Carved = true; // TODO: Is it needed?
|
||||
if (owner.Player && Core.AOS)
|
||||
c.SetRestoreInfo(item, item.Location);
|
||||
}
|
||||
|
||||
if (Core.SE && !owner.Player)
|
||||
c.AssignInstancedLoot();
|
||||
else if (Core.AOS && owner is PlayerMobile pm)
|
||||
c.RestoreEquip = pm.EquipSnapshot;
|
||||
|
||||
Point3D loc = owner.Location;
|
||||
Map map = owner.Map;
|
||||
|
||||
|
|
@ -769,11 +757,11 @@ namespace Server.Items
|
|||
|
||||
public bool DevourCorpse()
|
||||
{
|
||||
if (Devoured || Deleted || Killer == null || Killer.Deleted || !Killer.Alive || !(Killer is IDevourer) ||
|
||||
if (Devoured || Deleted || Killer == null || Killer.Deleted || !Killer.Alive || !(Killer is IDevourer devourer) ||
|
||||
Owner == null || Owner.Deleted)
|
||||
return false;
|
||||
|
||||
m_Devourer = (IDevourer)Killer; // Set the devourer the killer
|
||||
m_Devourer = devourer; // Set the devourer the killer
|
||||
return m_Devourer.Devour(this); // Devour the corpse if it hasn't
|
||||
}
|
||||
|
||||
|
|
@ -803,7 +791,7 @@ namespace Server.Items
|
|||
{
|
||||
PartyMemberInfo pmi = p[Owner];
|
||||
|
||||
if (pmi != null && pmi.CanLoot)
|
||||
if (pmi?.CanLoot == true)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -197,27 +197,24 @@ namespace Server.Items
|
|||
BaseCreature bc =
|
||||
(BaseCreature)Activator.CreateInstance(Creatures[Utility.Random(Creatures.Length)]);
|
||||
|
||||
if (bc != null)
|
||||
Point3D spawnLoc = GetSpawnPosition();
|
||||
|
||||
DoEffect(spawnLoc, map);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), delegate
|
||||
{
|
||||
Point3D spawnLoc = GetSpawnPosition();
|
||||
bc.Home = Location;
|
||||
bc.RangeHome = SpawnRange;
|
||||
bc.FightMode = FightMode.Closest;
|
||||
|
||||
bc.MoveToWorld(spawnLoc, map);
|
||||
|
||||
DoEffect(spawnLoc, map);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), delegate
|
||||
{
|
||||
bc.Home = Location;
|
||||
bc.RangeHome = SpawnRange;
|
||||
bc.FightMode = FightMode.Closest;
|
||||
bc.ForceReacquire();
|
||||
});
|
||||
|
||||
bc.MoveToWorld(spawnLoc, map);
|
||||
|
||||
DoEffect(spawnLoc, map);
|
||||
|
||||
bc.ForceReacquire();
|
||||
});
|
||||
|
||||
NextSpawn = DateTime.UtcNow + NextSpawnDelay;
|
||||
}
|
||||
NextSpawn = DateTime.UtcNow + NextSpawnDelay;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -227,6 +224,7 @@ namespace Server.Items
|
|||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
else
|
||||
from.SendLocalizedMessage(500446); // That is too far away.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue