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
|
|
@ -13,12 +13,7 @@ namespace Server.Items
|
|||
public static int Range = Core.AOS ? 2 : 1;
|
||||
|
||||
[Constructible]
|
||||
public Bandage() : this(1)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public Bandage(int amount) : base(0xE21)
|
||||
public Bandage(int amount = 1) : base(0xE21)
|
||||
{
|
||||
Stackable = true;
|
||||
Amount = amount;
|
||||
|
|
@ -84,16 +79,13 @@ namespace Server.Items
|
|||
|
||||
if (from.InRange(b.GetWorldLocation(), Range))
|
||||
{
|
||||
Target t = from.Target;
|
||||
|
||||
if (t != null)
|
||||
if (from.Target != null)
|
||||
{
|
||||
Target.Cancel(from);
|
||||
from.Target = null;
|
||||
}
|
||||
|
||||
from.RevealingAction();
|
||||
|
||||
from.SendLocalizedMessage(500948); // Who will you use the bandages on?
|
||||
|
||||
new InternalTarget(b).Invoke(from, e.Target);
|
||||
|
|
@ -122,9 +114,8 @@ namespace Server.Items
|
|||
{
|
||||
if (from.InRange(m_Bandage.GetWorldLocation(), Bandage.Range))
|
||||
{
|
||||
if (BandageContext.BeginHeal(from, mobile) != null)
|
||||
if (!DuelContext.IsFreeConsume(from))
|
||||
m_Bandage.Consume();
|
||||
if (!(BandageContext.BeginHeal(from, mobile) == null || DuelContext.IsFreeConsume(from)))
|
||||
m_Bandage.Consume();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -187,9 +178,7 @@ namespace Server.Items
|
|||
public void StopHeal()
|
||||
{
|
||||
m_Table.Remove(Healer);
|
||||
|
||||
Timer?.Stop();
|
||||
|
||||
Timer = null;
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +227,7 @@ namespace Server.Items
|
|||
patientNumber = -1;
|
||||
playSound = false;
|
||||
}
|
||||
else if (!Patient.Alive || petPatient != null && petPatient.IsDeadPet)
|
||||
else if (!Patient.Alive || petPatient?.IsDeadPet == true)
|
||||
{
|
||||
double healing = Healer.Skills[primarySkill].Value;
|
||||
double anatomy = Healer.Skills[secondarySkill].Value;
|
||||
|
|
@ -267,7 +256,7 @@ namespace Server.Items
|
|||
Patient.PlaySound(0x214);
|
||||
Patient.FixedEffect(0x376A, 10, 16);
|
||||
|
||||
if (petPatient != null && petPatient.IsDeadPet)
|
||||
if (petPatient?.IsDeadPet == true)
|
||||
{
|
||||
Mobile master = petPatient.ControlMaster;
|
||||
|
||||
|
|
@ -277,7 +266,7 @@ namespace Server.Items
|
|||
|
||||
for (int i = 0; i < petPatient.Skills.Length; ++i) petPatient.Skills[i].Base -= 0.1;
|
||||
}
|
||||
else if (master != null && master.InRange(petPatient, 3))
|
||||
else if (master?.InRange(petPatient, 3) == true)
|
||||
{
|
||||
healerNumber = 503255; // You are able to resurrect the creature.
|
||||
|
||||
|
|
@ -319,7 +308,7 @@ namespace Server.Items
|
|||
}
|
||||
else
|
||||
{
|
||||
if (petPatient != null && petPatient.IsDeadPet)
|
||||
if (petPatient?.IsDeadPet == true)
|
||||
healerNumber = 503256; // You fail to resurrect the creature.
|
||||
else
|
||||
healerNumber = 500966; // You are unable to resurrect your patient.
|
||||
|
|
@ -536,4 +525,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Network;
|
||||
using Server.Spells;
|
||||
using Server.Targeting;
|
||||
|
|
@ -38,14 +39,11 @@ namespace Server.Items
|
|||
return false;
|
||||
}
|
||||
|
||||
int sulfAsh = Core.AOS ? 4 : 15;
|
||||
if (from.Backpack == null || from.Backpack.GetAmount(typeof(SulfurousAsh)) < sulfAsh)
|
||||
{
|
||||
from.SendLocalizedMessage(1049617); // You do not have enough sulfurous ash.
|
||||
return false;
|
||||
}
|
||||
if (from.Backpack?.GetAmount(typeof(SulfurousAsh)) >= (Core.AOS ? 4 : 15))
|
||||
return true;
|
||||
|
||||
return true;
|
||||
from.SendLocalizedMessage(1049617); // You do not have enough sulfurous ash.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
|
|
@ -85,22 +83,21 @@ namespace Server.Items
|
|||
new HuedEffect(EffectType.Moving, from.Serial, Serial.Zero, 0x36D4, from.Location, loc, 5, 0, false, true, 0,
|
||||
0));
|
||||
|
||||
List<Mobile> targets = new List<Mobile>();
|
||||
bool playerVsPlayer = false;
|
||||
|
||||
IPooledEnumerable<Mobile> eable = from.Map.GetMobilesInRange(new Point3D(loc), 2);
|
||||
|
||||
foreach (Mobile m in eable)
|
||||
if (from != m && SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false))
|
||||
{
|
||||
if (Core.AOS && !from.InLOS(m))
|
||||
continue;
|
||||
bool playerVsPlayer = false;
|
||||
List<Mobile> targets = eable.Where(m =>
|
||||
{
|
||||
if (from == m || !SpellHelper.ValidIndirectTarget(from, m) || !from.CanBeHarmful(m, false)
|
||||
|| Core.AOS && !from.InLOS(m))
|
||||
return false;
|
||||
|
||||
targets.Add(m);
|
||||
if (m.Player)
|
||||
playerVsPlayer = true;
|
||||
|
||||
if (m.Player)
|
||||
playerVsPlayer = true;
|
||||
}
|
||||
return true;
|
||||
|
||||
}).ToList();
|
||||
|
||||
eable.Free();
|
||||
|
||||
|
|
@ -219,4 +216,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,12 @@ namespace Server.Items
|
|||
{
|
||||
private int m_RecipeID;
|
||||
|
||||
public RecipeScroll(Recipe r)
|
||||
: this(r.ID)
|
||||
public RecipeScroll(Recipe r) : this(r.ID)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public RecipeScroll(int recipeID)
|
||||
: base(0x2831)
|
||||
public RecipeScroll(int recipeID) : base(0x2831)
|
||||
{
|
||||
m_RecipeID = recipeID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,26 +23,13 @@ namespace Server.Items
|
|||
private double m_SkillLevel;
|
||||
|
||||
[Constructible]
|
||||
public RepairDeed() : this(RepairSkillType.Smithing, 100.0, null, true)
|
||||
public RepairDeed(RepairSkillType skill, double level, bool normalizeLevel) :
|
||||
this(skill, level, null, normalizeLevel)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public RepairDeed(RepairSkillType skill, double level) : this(skill, level, null, true)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public RepairDeed(RepairSkillType skill, double level, bool normalizeLevel) : this(skill, level, null,
|
||||
normalizeLevel)
|
||||
{
|
||||
}
|
||||
|
||||
public RepairDeed(RepairSkillType skill, double level, Mobile crafter) : this(skill, level, crafter, true)
|
||||
{
|
||||
}
|
||||
|
||||
public RepairDeed(RepairSkillType skill, double level, Mobile crafter, bool normalizeLevel) : base(0x14F0)
|
||||
public RepairDeed(RepairSkillType skill = RepairSkillType.Smithing, double level = 100.0,
|
||||
Mobile crafter = null, bool normalizeLevel = true) : base(0x14F0)
|
||||
{
|
||||
if (normalizeLevel)
|
||||
SkillLevel = (int)(level / 10) * 10;
|
||||
|
|
@ -250,4 +237,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue