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
|
|
@ -289,9 +289,9 @@ namespace Server.Items
|
|||
|
||||
public void Carve(Mobile from, Item item)
|
||||
{
|
||||
if (IsCriminalAction(from) && Map != null && (Map.Rules & MapRules.HarmfulRestrictions) != 0)
|
||||
if (IsCriminalAction(from) && (Map?.Rules & MapRules.HarmfulRestrictions) != 0)
|
||||
{
|
||||
if (Owner == null || !Owner.Player)
|
||||
if (Owner?.Player != true)
|
||||
from.SendLocalizedMessage(1005035); // You did not earn the right to loot this creature!
|
||||
else
|
||||
from.SendLocalizedMessage(1010049); // You may not loot this corpse.
|
||||
|
|
@ -339,14 +339,9 @@ namespace Server.Items
|
|||
|
||||
public override bool IsChildVisibleTo(Mobile m, Item child)
|
||||
{
|
||||
if (!m.Player || m.AccessLevel > AccessLevel.Player) //Staff and creatures not subject to instancing.
|
||||
return true;
|
||||
|
||||
if (m_InstancedItems != null && m_InstancedItems.TryGetValue(child, out InstancedItemInfo info)
|
||||
&& (InstancedCorpse || info.Perpetual))
|
||||
return info.IsOwner(m); //IsOwner checks Party stuff.
|
||||
|
||||
return true;
|
||||
return !m.Player || m.AccessLevel > AccessLevel.Player || m_InstancedItems == null ||
|
||||
!m_InstancedItems.TryGetValue(child, out InstancedItemInfo info) || !InstancedCorpse && !info.Perpetual
|
||||
|| info.IsOwner(m);
|
||||
}
|
||||
|
||||
private void AssignInstancedLoot()
|
||||
|
|
@ -364,7 +359,7 @@ namespace Server.Items
|
|||
{
|
||||
Item item = Items[i];
|
||||
|
||||
if (item.LootType != LootType.Cursed) //Don't have curesd items take up someone's item spot.. (?)
|
||||
if (item.LootType != LootType.Cursed) //Don't have cursed items take up someone's item spot.. (?)
|
||||
{
|
||||
if (item.Stackable)
|
||||
m_Stackables.Add(item);
|
||||
|
|
@ -384,7 +379,7 @@ namespace Server.Items
|
|||
attackers[i] = temp;
|
||||
}
|
||||
|
||||
//stackables first, for the remaining stackables, have those be randomly added after
|
||||
// stackables first, for the remaining stackables, have those be randomly added after
|
||||
|
||||
for (int i = 0; i < m_Stackables.Count; i++)
|
||||
{
|
||||
|
|
@ -488,11 +483,9 @@ namespace Server.Items
|
|||
public static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair,
|
||||
List<Item> initialContent, List<Item> equipItems)
|
||||
{
|
||||
Corpse c;
|
||||
if (owner is MilitiaFighter)
|
||||
c = new MilitiaFighterCorpse(owner, hair, facialhair, equipItems);
|
||||
else
|
||||
c = new Corpse(owner, hair, facialhair, equipItems);
|
||||
Corpse c = owner is MilitiaFighter ?
|
||||
new MilitiaFighterCorpse(owner, hair, facialhair, equipItems) :
|
||||
new Corpse(owner, hair, facialhair, equipItems);
|
||||
|
||||
owner.Corpse = c;
|
||||
|
||||
|
|
@ -757,8 +750,8 @@ namespace Server.Items
|
|||
|
||||
public bool DevourCorpse()
|
||||
{
|
||||
if (Devoured || Deleted || Killer == null || Killer.Deleted || !Killer.Alive || !(Killer is IDevourer devourer) ||
|
||||
Owner == null || Owner.Deleted)
|
||||
if (Devoured || Deleted || Killer?.Deleted != false || !Killer.Alive || !(Killer is IDevourer devourer) ||
|
||||
Owner?.Deleted != false)
|
||||
return false;
|
||||
|
||||
m_Devourer = devourer; // Set the devourer the killer
|
||||
|
|
@ -769,15 +762,15 @@ namespace Server.Items
|
|||
{
|
||||
base.SendInfoTo(state, sendOplPacket);
|
||||
|
||||
if (((Body)Amount).IsHuman && ItemID == 0x2006)
|
||||
{
|
||||
if (state.ContainerGridLines)
|
||||
state.Send(new CorpseContent6017(state.Mobile, this));
|
||||
else
|
||||
state.Send(new CorpseContent(state.Mobile, this));
|
||||
if (!(((Body)Amount).IsHuman && ItemID == 0x2006))
|
||||
return;
|
||||
|
||||
state.Send(new CorpseEquip(state.Mobile, this));
|
||||
}
|
||||
if (state.ContainerGridLines)
|
||||
state.Send(new CorpseContent6017(state.Mobile, this));
|
||||
else
|
||||
state.Send(new CorpseContent(state.Mobile, this));
|
||||
|
||||
state.Send(new CorpseEquip(state.Mobile, this));
|
||||
}
|
||||
|
||||
public bool IsCriminalAction(Mobile from)
|
||||
|
|
@ -787,7 +780,7 @@ namespace Server.Items
|
|||
|
||||
Party p = Party.Get(Owner);
|
||||
|
||||
if (p != null && p.Contains(from))
|
||||
if (p?.Contains(from) == true)
|
||||
{
|
||||
PartyMemberInfo pmi = p[Owner];
|
||||
|
||||
|
|
@ -800,21 +793,12 @@ namespace Server.Items
|
|||
|
||||
public override bool CheckItemUse(Mobile from, Item item)
|
||||
{
|
||||
if (!base.CheckItemUse(from, item))
|
||||
return false;
|
||||
|
||||
if (item != this)
|
||||
return CanLoot(from, item);
|
||||
|
||||
return true;
|
||||
return base.CheckItemUse(from, item) && (item == this || CanLoot(from, item));
|
||||
}
|
||||
|
||||
public override bool CheckLift(Mobile from, Item item, ref LRReason reject)
|
||||
{
|
||||
if (!base.CheckLift(from, item, ref reject))
|
||||
return false;
|
||||
|
||||
return CanLoot(from, item);
|
||||
return base.CheckLift(from, item, ref reject) && CanLoot(from, item);
|
||||
}
|
||||
|
||||
public override void OnItemUsed(Mobile from, Item item)
|
||||
|
|
@ -888,17 +872,14 @@ namespace Server.Items
|
|||
|
||||
public bool CanLoot(Mobile from, Item item)
|
||||
{
|
||||
if (!IsCriminalAction(from))
|
||||
return true;
|
||||
|
||||
return Map != null && (Map.Rules & MapRules.HarmfulRestrictions) == 0;
|
||||
return !IsCriminalAction(from) || (Map.Rules & MapRules.HarmfulRestrictions) == 0;
|
||||
}
|
||||
|
||||
public bool CheckLoot(Mobile from, Item item)
|
||||
{
|
||||
if (!CanLoot(from, item))
|
||||
{
|
||||
if (Owner == null || !Owner.Player)
|
||||
if (Owner?.Player != true)
|
||||
from.SendLocalizedMessage(1005035); // You did not earn the right to loot this creature!
|
||||
else
|
||||
from.SendLocalizedMessage(1010049); // You may not loot this corpse.
|
||||
|
|
@ -908,7 +889,7 @@ namespace Server.Items
|
|||
|
||||
if (IsCriminalAction(from))
|
||||
{
|
||||
if (Owner == null || !Owner.Player)
|
||||
if (Owner?.Player != true)
|
||||
from.SendLocalizedMessage(1005036); // Looting this monster corpse will be a criminal act!
|
||||
else
|
||||
from.SendLocalizedMessage(1005038); // Looting this corpse will be a criminal act!
|
||||
|
|
@ -965,12 +946,12 @@ namespace Server.Items
|
|||
!GetRestoreInfo(item, ref loc))
|
||||
continue;
|
||||
|
||||
if (pack != null && pack.CheckHold(from, item, false, true))
|
||||
if (pack?.CheckHold(from, item, false, true) == true)
|
||||
{
|
||||
item.Location = loc;
|
||||
pack.AddItem(item);
|
||||
|
||||
if (RestoreEquip != null && RestoreEquip.Contains(item))
|
||||
if (RestoreEquip?.Contains(item) == true)
|
||||
from.EquipItem(item);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue