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
|
|
@ -20,18 +20,15 @@ namespace Server.SkillHandlers
|
|||
if (to.Player)
|
||||
return from.CanBeHarmful(to, false, true); // normal restrictions
|
||||
|
||||
if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
if ((map?.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
return true; // felucca you can snoop anybody
|
||||
|
||||
GuardedRegion reg = to.Region.GetRegion<GuardedRegion>();
|
||||
|
||||
if (reg == null || reg.IsDisabled())
|
||||
if (reg?.IsDisabled() != true)
|
||||
return true; // not in town? we can snoop any npc
|
||||
|
||||
if (to.Body.IsHuman && (!(to is BaseCreature cret) || !cret.AlwaysAttackable && !cret.AlwaysMurderer))
|
||||
return false; // in town we cannot snoop blue human npcs
|
||||
|
||||
return true;
|
||||
return !to.Body.IsHuman || to is BaseCreature cret && (cret.AlwaysAttackable || cret.AlwaysMurderer);
|
||||
}
|
||||
|
||||
public static void Container_Snoop(Container cont, Mobile from)
|
||||
|
|
@ -40,22 +37,22 @@ namespace Server.SkillHandlers
|
|||
{
|
||||
Mobile root = cont.RootParent as Mobile;
|
||||
|
||||
if (root != null && !root.Alive)
|
||||
if (root?.Alive == false)
|
||||
return;
|
||||
|
||||
if (root != null && root.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player)
|
||||
if (root?.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player)
|
||||
{
|
||||
from.SendLocalizedMessage(500209); // You can not peek into the container.
|
||||
return;
|
||||
}
|
||||
|
||||
if (root != null && from.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root))
|
||||
if (root?.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root))
|
||||
{
|
||||
from.SendLocalizedMessage(1001018); // You cannot perform negative acts on your target.
|
||||
return;
|
||||
}
|
||||
|
||||
if (root != null && from.AccessLevel == AccessLevel.Player &&
|
||||
if (root?.AccessLevel == AccessLevel.Player &&
|
||||
from.Skills.Snooping.Value < Utility.Random(100))
|
||||
{
|
||||
Map map = from.Map;
|
||||
|
|
@ -98,4 +95,4 @@ namespace Server.SkillHandlers
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue