Code Cleanup & Fixes Warnings (#74)
This commit is contained in:
parent
e11d1f3ad9
commit
57b14ad690
143 changed files with 2960 additions and 3427 deletions
|
|
@ -46,10 +46,7 @@ namespace Server.Items
|
|||
public virtual int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes,
|
||||
BaseTool tool, CraftItem craftItem, int resHue)
|
||||
{
|
||||
Type resourceType = typeRes;
|
||||
|
||||
if (resourceType == null)
|
||||
resourceType = craftItem.Resources.GetAt(0).ItemType;
|
||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
||||
|
||||
Resource = CraftResources.GetFromType(resourceType);
|
||||
|
||||
|
|
|
|||
|
|
@ -486,10 +486,7 @@ namespace Server.Items
|
|||
if (makersMark)
|
||||
Crafter = from;
|
||||
|
||||
Type resourceType = typeRes;
|
||||
|
||||
if (resourceType == null)
|
||||
resourceType = craftItem.Resources.GetAt(0).ItemType;
|
||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
||||
|
||||
Resource = CraftResources.GetFromType(resourceType);
|
||||
PlayerConstructed = true;
|
||||
|
|
@ -1271,8 +1268,7 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
if (SkillBonuses == null)
|
||||
SkillBonuses = new AosSkillBonuses(this);
|
||||
SkillBonuses ??= new AosSkillBonuses(this);
|
||||
|
||||
Mobile m = Parent as Mobile;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class ElvenGlasses : BaseArmor
|
||||
|
|
@ -126,10 +128,11 @@ namespace Server.Items
|
|||
WeaponAttributes = new AosWeaponAttributes(this);
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum SaveFlag
|
||||
{
|
||||
None = 0x00000000,
|
||||
WeaponAttributes = 0x00000001
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
// Intended for defined books only
|
||||
public BaseBook(int itemID, bool writable) : this(itemID, 0)
|
||||
public BaseBook(int itemID, bool writable) : this(itemID, 0, writable)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -152,10 +152,7 @@ namespace Server.Items
|
|||
|
||||
if (DefaultResource != CraftResource.None)
|
||||
{
|
||||
Type resourceType = typeRes;
|
||||
|
||||
if (resourceType == null)
|
||||
resourceType = craftItem.Resources.GetAt(0).ItemType;
|
||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
||||
|
||||
Resource = CraftResources.GetFromType(resourceType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,13 +85,9 @@ namespace Server.Items
|
|||
|
||||
if (Commodity != null)
|
||||
{
|
||||
string args;
|
||||
|
||||
if (Commodity.Name == null)
|
||||
args =
|
||||
$"#{(Commodity is ICommodity commodity ? commodity.DescriptionNumber : Commodity.LabelNumber)}\t{Commodity.Amount}";
|
||||
else
|
||||
args = $"{Commodity.Name}\t{Commodity.Amount}";
|
||||
var args = Commodity.Name == null ?
|
||||
$"#{(Commodity is ICommodity commodity ? commodity.DescriptionNumber : Commodity.LabelNumber)}\t{Commodity.Amount}" :
|
||||
$"{Commodity.Name}\t{Commodity.Amount}";
|
||||
|
||||
list.Add(1060658, args); // ~1_val~: ~2_val~
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@ namespace Server.Items
|
|||
if (makersMark)
|
||||
Crafter = from;
|
||||
|
||||
Type resourceType = typeRes;
|
||||
|
||||
if (resourceType == null)
|
||||
resourceType = craftItem.Resources.GetAt(0).ItemType;
|
||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
||||
|
||||
Resource = CraftResources.GetFromType(resourceType);
|
||||
|
||||
|
|
|
|||
|
|
@ -131,10 +131,7 @@ namespace Server.Items
|
|||
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
|
||||
CraftItem craftItem, int resHue)
|
||||
{
|
||||
Type resourceType = typeRes;
|
||||
|
||||
if (resourceType == null)
|
||||
resourceType = craftItem.Resources.GetAt(0).ItemType;
|
||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
||||
|
||||
Resource = CraftResources.GetFromType(resourceType);
|
||||
|
||||
|
|
|
|||
|
|
@ -347,8 +347,7 @@ namespace Server.Items
|
|||
if (Aggressors.Count == 0 || Items.Count == 0)
|
||||
return;
|
||||
|
||||
if (m_InstancedItems == null)
|
||||
m_InstancedItems = new Dictionary<Item, InstancedItemInfo>();
|
||||
m_InstancedItems ??= new Dictionary<Item, InstancedItemInfo>();
|
||||
|
||||
List<Item> m_Stackables = new List<Item>();
|
||||
List<Item> m_Unstackables = new List<Item>();
|
||||
|
|
@ -427,8 +426,7 @@ namespace Server.Items
|
|||
|
||||
if (InstancedCorpse)
|
||||
{
|
||||
if (m_InstancedItems == null)
|
||||
m_InstancedItems = new Dictionary<Item, InstancedItemInfo>();
|
||||
m_InstancedItems ??= new Dictionary<Item, InstancedItemInfo>();
|
||||
|
||||
m_InstancedItems.Add(carved, new InstancedItemInfo(carved, carver));
|
||||
}
|
||||
|
|
@ -836,8 +834,7 @@ namespace Server.Items
|
|||
if (item == null)
|
||||
return;
|
||||
|
||||
if (m_RestoreTable == null)
|
||||
m_RestoreTable = new Dictionary<Item, Point3D>();
|
||||
m_RestoreTable ??= new Dictionary<Item, Point3D>();
|
||||
|
||||
m_RestoreTable[item] = loc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,13 +261,7 @@ namespace Server.Items
|
|||
|
||||
public void PlaySound(IEntity trigger)
|
||||
{
|
||||
IEntity ent = null;
|
||||
|
||||
if (PlaySoundAtTrigger)
|
||||
ent = trigger;
|
||||
|
||||
if (ent == null)
|
||||
ent = this;
|
||||
IEntity ent = PlaySoundAtTrigger ? trigger : this;
|
||||
|
||||
Effects.PlaySound((ent as Item)?.GetWorldLocation() ?? ent.Location, ent.Map, SoundID);
|
||||
}
|
||||
|
|
@ -292,13 +286,8 @@ namespace Server.Items
|
|||
|
||||
public void InternalDoEffect(IEntity trigger)
|
||||
{
|
||||
IEntity from = m_Source, to = m_Target;
|
||||
|
||||
if (from == null)
|
||||
from = trigger;
|
||||
|
||||
if (to == null)
|
||||
to = trigger;
|
||||
IEntity from = m_Source ?? trigger;
|
||||
IEntity to = m_Target ?? trigger;
|
||||
|
||||
switch (EffectType)
|
||||
{
|
||||
|
|
@ -334,4 +323,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,7 @@ namespace Server.Items
|
|||
from.SendLocalizedMessage(1060581); // You've already lit it! Better throw it now!
|
||||
}
|
||||
|
||||
if (m_Users == null)
|
||||
m_Users = new List<Mobile>();
|
||||
m_Users ??= new List<Mobile>();
|
||||
|
||||
if (!m_Users.Contains(from))
|
||||
m_Users.Add(from);
|
||||
|
|
|
|||
|
|
@ -76,8 +76,7 @@ namespace Server.Items
|
|||
|
||||
from.RevealingAction();
|
||||
|
||||
if (Users == null)
|
||||
Users = new List<Mobile>();
|
||||
Users ??= new List<Mobile>();
|
||||
|
||||
if (!Users.Contains(from))
|
||||
Users.Add(from);
|
||||
|
|
|
|||
|
|
@ -810,11 +810,8 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
if (Attributes == null)
|
||||
Attributes = new AosAttributes(this);
|
||||
|
||||
if (SkillBonuses == null)
|
||||
SkillBonuses = new AosSkillBonuses(this);
|
||||
Attributes ??= new AosAttributes(this);
|
||||
SkillBonuses ??= new AosSkillBonuses(this);
|
||||
|
||||
if (Core.AOS && Parent is Mobile mobile)
|
||||
SkillBonuses.AddTo(mobile);
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ namespace Server.Items
|
|||
double toHeal = min + Utility.RandomDouble() * (max - min);
|
||||
|
||||
if (Patient.Body.IsMonster || Patient.Body.IsAnimal)
|
||||
toHeal += Patient.HitsMax / 100;
|
||||
toHeal += Patient.HitsMax / 100.0;
|
||||
|
||||
if (Core.AOS)
|
||||
toHeal -= toHeal * Slips * 0.35; // TODO: Verify algorithm
|
||||
|
|
|
|||
|
|
@ -66,8 +66,7 @@ namespace Server.Items
|
|||
{
|
||||
if (!pm.HasRecipe(r))
|
||||
{
|
||||
bool allRequiredSkills = true;
|
||||
double chance = r.CraftItem.GetSuccessChance(pm, null, r.CraftSystem, false, ref allRequiredSkills);
|
||||
double chance = r.CraftItem.GetSuccessChance(pm, null, r.CraftSystem, false, out var allRequiredSkills);
|
||||
|
||||
if (allRequiredSkills && chance >= 0.0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -274,13 +274,7 @@ namespace Server.Items
|
|||
|
||||
private void InternalUpdatePetName()
|
||||
{
|
||||
BaseCreature pet = Pet;
|
||||
|
||||
if (pet == null)
|
||||
PetName = "";
|
||||
else
|
||||
PetName = pet.Name;
|
||||
|
||||
PetName = Pet?.Name ?? "";
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,8 +63,7 @@ namespace Server.Items
|
|||
|
||||
public void TurnOn()
|
||||
{
|
||||
if (m_Fire == null)
|
||||
m_Fire = new Item();
|
||||
m_Fire ??= new Item();
|
||||
|
||||
m_Fire.ItemID = 0x19AB;
|
||||
m_Fire.Movable = false;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace Server.Items
|
|||
public static bool Slays(TalismanSlayerName name, Mobile m)
|
||||
{
|
||||
if (m == null || !m_Table.TryGetValue(name, out Type[] types) || types == null)
|
||||
return false;;
|
||||
return false;
|
||||
|
||||
Type type = m.GetType();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ namespace Server.Items
|
|||
|
||||
public virtual void StartTimer()
|
||||
{
|
||||
if (m_Timer == null)
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Refresh);
|
||||
m_Timer ??= Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Refresh);
|
||||
}
|
||||
|
||||
public virtual void StopTimer()
|
||||
|
|
|
|||
|
|
@ -107,10 +107,7 @@ namespace Server.Items
|
|||
|
||||
PlayerConstructed = true;
|
||||
|
||||
Type resourceType = typeRes;
|
||||
|
||||
if (resourceType == null)
|
||||
resourceType = craftItem.Resources.GetAt(0).ItemType;
|
||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
||||
|
||||
if (Core.AOS)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -144,8 +144,7 @@ namespace Server.Items
|
|||
|
||||
if (!pm.Warmode)
|
||||
{
|
||||
if (m_RecoveryTimer == null)
|
||||
m_RecoveryTimer = Timer.DelayCall(TimeSpan.FromSeconds(10), pm.RecoverAmmo);
|
||||
m_RecoveryTimer ??= Timer.DelayCall(TimeSpan.FromSeconds(10), pm.RecoverAmmo);
|
||||
|
||||
if (!m_RecoveryTimer.Running)
|
||||
m_RecoveryTimer.Start();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue