diff --git a/Scripts/Engines/Doom/GauntletSpawner.cs b/Scripts/Engines/Doom/GauntletSpawner.cs index 0bf7249d8..c146d307a 100644 --- a/Scripts/Engines/Doom/GauntletSpawner.cs +++ b/Scripts/Engines/Doom/GauntletSpawner.cs @@ -220,9 +220,6 @@ namespace Server.Engines.Doom else trap = new MushroomTrap(); - if (trap == null) - return; - if (trap is FireColumnTrap || trap is MushroomTrap) trap.Hue = 0x451; diff --git a/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs b/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs index 0608b3e4e..b99f4503a 100644 --- a/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs +++ b/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs @@ -327,7 +327,7 @@ namespace Server.Factions { double prio = m_Mobile.GetDistanceToSqrt(m); - if (!activeOnly && (inactive == null || prio < inactPrio)) + if (inactive == null || prio < inactPrio) { inactive = m; inactPrio = prio; diff --git a/Scripts/Engines/Pathing/FastAStarAlgorithm.cs b/Scripts/Engines/Pathing/FastAStarAlgorithm.cs index c742cb59a..d50b81506 100644 --- a/Scripts/Engines/Pathing/FastAStarAlgorithm.cs +++ b/Scripts/Engines/Pathing/FastAStarAlgorithm.cs @@ -160,48 +160,48 @@ namespace Server.PathAlgorithms.FastAStar bool wasTouched = m_Touched[newNode]; - if (!wasTouched) + if (wasTouched) + continue; + + int newCost = m_Nodes[bestNode].cost + 1; + int newTotal = newCost + Heuristic(newNode % AreaSize, newNode / AreaSize % AreaSize, + m_Nodes[newNode].z); + + if (m_Nodes[newNode].total <= newTotal) + continue; + + m_Nodes[newNode].parent = bestNode; + m_Nodes[newNode].cost = newCost; + m_Nodes[newNode].total = newTotal; + + if (m_OnOpen[newNode]) + continue; + + AddToChain(newNode); + + if (newNode != destNode) + continue; + + pathCount = 0; + parent = m_Nodes[newNode].parent; + + while (parent != -1) { - int newCost = m_Nodes[bestNode].cost + 1; - int newTotal = newCost + Heuristic(newNode % AreaSize, newNode / AreaSize % AreaSize, - m_Nodes[newNode].z); + path[pathCount++] = GetDirection(parent % AreaSize, parent / AreaSize % AreaSize, + newNode % AreaSize, newNode / AreaSize % AreaSize); + newNode = parent; + parent = m_Nodes[newNode].parent; - if (!wasTouched || m_Nodes[newNode].total > newTotal) - { - m_Nodes[newNode].parent = bestNode; - m_Nodes[newNode].cost = newCost; - m_Nodes[newNode].total = newTotal; - - if (!wasTouched || !m_OnOpen[newNode]) - { - AddToChain(newNode); - - if (newNode == destNode) - { - pathCount = 0; - parent = m_Nodes[newNode].parent; - - while (parent != -1) - { - path[pathCount++] = GetDirection(parent % AreaSize, parent / AreaSize % AreaSize, - newNode % AreaSize, newNode / AreaSize % AreaSize); - newNode = parent; - parent = m_Nodes[newNode].parent; - - if (newNode == fromNode) - break; - } - - Direction[] dirs = new Direction[pathCount]; - - while (pathCount > 0) - dirs[backtrack++] = path[--pathCount]; - - return dirs; - } - } - } + if (newNode == fromNode) + break; } + + Direction[] dirs = new Direction[pathCount]; + + while (pathCount > 0) + dirs[backtrack++] = path[--pathCount]; + + return dirs; } } diff --git a/Scripts/Engines/Pathing/Movement.cs b/Scripts/Engines/Pathing/Movement.cs index c37103d40..ef466e6b2 100644 --- a/Scripts/Engines/Pathing/Movement.cs +++ b/Scripts/Engines/Pathing/Movement.cs @@ -529,7 +529,7 @@ namespace Server.Movement zLow = landZ; zCenter = landCenter; - if (!isSet || landTop > zTop) + if (landTop > zTop) zTop = landTop; isSet = true; diff --git a/Scripts/Engines/Plants/PlantHue.cs b/Scripts/Engines/Plants/PlantHue.cs index 5e8c91312..4141e1eec 100644 --- a/Scripts/Engines/Plants/PlantHue.cs +++ b/Scripts/Engines/Plants/PlantHue.cs @@ -152,10 +152,10 @@ namespace Server.Engines.Plants if (firstPrimary && secondPrimary) return notBrightFirst | notBrightSecond; - if (firstPrimary && !secondPrimary) + if (firstPrimary) return notBrightFirst; - if (!firstPrimary && secondPrimary) + if (secondPrimary) return notBrightSecond; return notBrightFirst & notBrightSecond; diff --git a/Scripts/Engines/Plants/PlantType.cs b/Scripts/Engines/Plants/PlantType.cs index 6417f20cb..9b59d81b2 100644 --- a/Scripts/Engines/Plants/PlantType.cs +++ b/Scripts/Engines/Plants/PlantType.cs @@ -125,15 +125,8 @@ namespace Server.Engines.Plants private int m_SeedLabelPlural; private PlantTypeInfo(int itemID, int offsetX, int offsetY, PlantType plantType, bool containsPlant, bool flowery, - bool crossable, bool reproduces, PlantCategory plantCategory) - : this(itemID, offsetX, offsetY, plantType, containsPlant, flowery, crossable, reproduces, plantCategory, -1, -1, - -1, -1, -1, -1) - { - } - - private PlantTypeInfo(int itemID, int offsetX, int offsetY, PlantType plantType, bool containsPlant, bool flowery, - bool crossable, bool reproduces, PlantCategory plantCategory, int plantLabelSeed, int plantLabelPlant, - int plantLabelFullGrown, int plantLabelDecorative, int seedLabel, int seedLabelPlural) + bool crossable, bool reproduces, PlantCategory plantCategory, int plantLabelSeed = -1, int plantLabelPlant = -1, + int plantLabelFullGrown = -1, int plantLabelDecorative = -1, int seedLabel = -1, int seedLabelPlural = -1) { ItemID = itemID; OffsetX = offsetX; diff --git a/Scripts/Engines/Quests/The Summoning/Objectives.cs b/Scripts/Engines/Quests/The Summoning/Objectives.cs index 7c0cb1355..8e646a569 100644 --- a/Scripts/Engines/Quests/The Summoning/Objectives.cs +++ b/Scripts/Engines/Quests/The Summoning/Objectives.cs @@ -110,7 +110,7 @@ namespace Server.Engines.Quests.Doom } else { - bool hasRights = true; + bool hasRights = false; if (m_Daemon != null) { diff --git a/Scripts/Engines/RemoteAdmin/RemoteAdminLogging.cs b/Scripts/Engines/RemoteAdmin/RemoteAdminLogging.cs index 8803bdae6..d020c8e72 100644 --- a/Scripts/Engines/RemoteAdmin/RemoteAdminLogging.cs +++ b/Scripts/Engines/RemoteAdmin/RemoteAdminLogging.cs @@ -72,11 +72,12 @@ namespace Server.RemoteAdmin { LazyInitialize(); - if (!Enabled) return; + if (!Enabled) + return; try { - Account acct = state.Account as Account; + Account acct = state?.Account as Account; string name = acct == null ? "(UNKNOWN)" : acct.Username; string accesslevel = acct == null ? "NoAccount" : acct.AccessLevel.ToString(); string statestr = state == null ? "NULLSTATE" : state.ToString(); @@ -97,6 +98,7 @@ namespace Server.RemoteAdmin } catch { + // ignored } } } diff --git a/Scripts/Engines/Reports/Rendering/PieChartRenderer.cs b/Scripts/Engines/Reports/Rendering/PieChartRenderer.cs index 1d70e2b0e..7e8da47fc 100644 --- a/Scripts/Engines/Reports/Rendering/PieChartRenderer.cs +++ b/Scripts/Engines/Reports/Rendering/PieChartRenderer.cs @@ -188,15 +188,14 @@ namespace Server.Engines.Reports for (int i = 0; i < _chartItems.Count; i++) { - DataItem item = (DataItem)_chartItems[i]; - SolidBrush brs = null; + DataItem item = (DataItem)_chartItems[i]; try { grp.DrawPie(new Pen(_borderColor, 0.5f), pieRect, item.StartPos, item.SweepSize); } - finally + catch { - brs?.Dispose(); + // ignored } } @@ -226,8 +225,8 @@ namespace Server.Engines.Reports } finally { - sf?.Dispose(); - grp?.Dispose(); + sf.Dispose(); + grp.Dispose(); sfp?.Dispose(); fnt?.Dispose(); pen?.Dispose(); diff --git a/Scripts/Engines/Spawner/Spawner.cs b/Scripts/Engines/Spawner/Spawner.cs index 5c21ab036..6725a3701 100644 --- a/Scripts/Engines/Spawner/Spawner.cs +++ b/Scripts/Engines/Spawner/Spawner.cs @@ -354,44 +354,40 @@ namespace Server.Mobiles { Defrag(); - if (Entries.Count > 0 && !IsFull) + if (Entries.Count <= 0 || IsFull) + return; + + int probsum = 0; + + for (int i = 0; i < Entries.Count; i++) + if (!Entries[i].IsFull) + probsum += Entries[i].SpawnedProbability; + + if (probsum <= 0) + return; + + int rand = Utility.RandomMinMax(1, probsum); + + for (int i = 0; i < Entries.Count; i++) { - int probsum = 0; + SpawnerEntry entry = Entries[i]; + if (entry.IsFull) + continue; - for (int i = 0; i < Entries.Count; i++) - if (!Entries[i].IsFull) - probsum += Entries[i].SpawnedProbability; - - if (probsum > 0) + if (rand <= entry.SpawnedProbability) { - int rand = Utility.RandomMinMax(1, probsum); - - for (int i = 0; i < Entries.Count; i++) - { - SpawnerEntry entry = Entries[i]; - if (!entry.IsFull) - { - bool success = true; - - if (rand <= entry.SpawnedProbability) - { - EntryFlags flags; - success = Spawn(entry, out flags); - entry.Valid = flags; - return; - } - - if (success) - rand -= entry.SpawnedProbability; - } - } + Spawn(entry, out EntryFlags flags); + entry.Valid = flags; + return; } + + rand -= entry.SpawnedProbability; } } private static string[,] FormatProperties(string[] args) { - string[,] props = null; + string[,] props; int remains = args.Length; diff --git a/Scripts/Engines/Spawner/SpawnerGump.cs b/Scripts/Engines/Spawner/SpawnerGump.cs index 6957171e8..7c23807cf 100644 --- a/Scripts/Engines/Spawner/SpawnerGump.cs +++ b/Scripts/Engines/Spawner/SpawnerGump.cs @@ -11,15 +11,7 @@ namespace Server.Mobiles private int m_Page; private Spawner m_Spawner; - public SpawnerGump(Spawner spawner) : this(spawner, 0) - { - } - - public SpawnerGump(Spawner spawner, int page) : this(spawner, null, page) - { - } - - public SpawnerGump(Spawner spawner, SpawnerEntry focusentry, int page) : base(50, 50) + public SpawnerGump(Spawner spawner, SpawnerEntry focusentry = null, int page = 0) : base(50, 50) { m_Spawner = spawner; m_Entry = focusentry; @@ -51,7 +43,7 @@ namespace Server.Mobiles AddButton(5, 22 * i + 21 + offset, entry != null ? 0xFBA : 0xFA5, entry != null ? 0xFBC : 0xFA7, GetButtonID(2, i * 2), GumpButtonType.Reply, 0); //Expand else - AddButton(5, 22 * i + 21 + offset, entry != null ? 0xFBB : 0xFA5, entry != null ? 0xFBC : 0xFA7, + AddButton(5, 22 * i + 21 + offset, 0xFBB, 0xFBC, GetButtonID(2, i * 2), GumpButtonType.Reply, 0); //Unexpand AddButton(38, 22 * i + 21 + offset, 0xFA2, 0xFA4, GetButtonID(2, 1 + i * 2), GumpButtonType.Reply, @@ -163,7 +155,7 @@ namespace Server.Mobiles if (type != null) { - SpawnerEntry entry = null; + SpawnerEntry entry; if (entryindex < ocount) { @@ -221,8 +213,6 @@ namespace Server.Mobiles if (m_Spawner.Deleted) return; - Mobile from = state.Mobile; - int val = info.ButtonID - 1; if (val < 0) @@ -309,7 +299,7 @@ namespace Server.Mobiles } } - if (m_Entry != null && m_Spawner.Entries.Contains(m_Entry)) + if (m_Entry != null && m_Spawner.Entries?.Contains(m_Entry) == true) state.Mobile.SendGump(new SpawnerGump(m_Spawner, m_Entry, m_Page)); else state.Mobile.SendGump(new SpawnerGump(m_Spawner, null, m_Page)); diff --git a/Scripts/Gumps/Guilds/GuildGump.cs b/Scripts/Gumps/Guilds/GuildGump.cs index 28ce5215f..96d847501 100644 --- a/Scripts/Gumps/Guilds/GuildGump.cs +++ b/Scripts/Gumps/Guilds/GuildGump.cs @@ -53,7 +53,7 @@ namespace Server.Gumps string fealtyName; - if (fealty == null || (fealtyName = fealty.Name) == null || (fealtyName = fealtyName.Trim()).Length <= 0) + if ((fealtyName = fealty.Name) == null || (fealtyName = fealtyName.Trim()).Length <= 0) fealtyName = "(empty)"; if (beholder == fealty) diff --git a/Scripts/Gumps/PlayerVendorGumps.cs b/Scripts/Gumps/PlayerVendorGumps.cs index 543c9b086..b4e9a400e 100644 --- a/Scripts/Gumps/PlayerVendorGumps.cs +++ b/Scripts/Gumps/PlayerVendorGumps.cs @@ -652,23 +652,15 @@ namespace Server.Gumps private class CustomItem { - public CustomItem(int itemID, int loc) : this(null, itemID, loc, 0, false) + public CustomItem(int itemID, int loc, bool longText = false) : this(null, itemID, loc, 0, longText) { } - public CustomItem(int itemID, int loc, bool longText) : this(null, itemID, loc, 0, longText) + public CustomItem(Type type, int loc, int art = 0) : this(type, 0, loc, art) { } - public CustomItem(Type type, int loc) : this(type, loc, 0) - { - } - - public CustomItem(Type type, int loc, int art) : this(type, 0, loc, art, false) - { - } - - public CustomItem(Type type, int itemID, int loc, int art, bool longText) + public CustomItem(Type type, int itemID = 0, int loc = 0, int art = 0, bool longText = false) { Type = type; ItemID = itemID; @@ -702,6 +694,7 @@ namespace Server.Gumps } catch { + // ignored } return i; diff --git a/Scripts/Gumps/Props/PropsGump.cs b/Scripts/Gumps/Props/PropsGump.cs index 4851c3965..260c3e998 100644 --- a/Scripts/Gumps/Props/PropsGump.cs +++ b/Scripts/Gumps/Props/PropsGump.cs @@ -452,9 +452,7 @@ namespace Server.Gumps private static bool HasAttribute(Type type, Type check, bool inherit) { - object[] objs = type.GetCustomAttributes(check, inherit); - - return objs != null && objs.Length > 0; + return type.GetCustomAttributes(check, inherit).Length > 0; } private static bool IsType(Type type, Type check) diff --git a/Scripts/Gumps/Props/SetObjectGump.cs b/Scripts/Gumps/Props/SetObjectGump.cs index 67c75c9f2..ec42c913f 100644 --- a/Scripts/Gumps/Props/SetObjectGump.cs +++ b/Scripts/Gumps/Props/SetObjectGump.cs @@ -140,8 +140,7 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { - object toSet; - bool shouldSet, shouldSend = true; + bool shouldSend = true; object viewProps = null; switch (info.ButtonID) @@ -149,25 +148,17 @@ namespace Server.Gumps case 0: // closed { m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); - - toSet = null; - shouldSet = false; shouldSend = false; - break; } case 1: // Change by Target { m_Mobile.Target = new SetObjectTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List); - toSet = null; - shouldSet = false; shouldSend = false; break; } case 2: // Change by Serial { - toSet = null; - shouldSet = false; shouldSend = false; m_Mobile.SendMessage("Enter the serial you wish to find:"); @@ -177,16 +168,20 @@ namespace Server.Gumps } case 3: // Nullify { - toSet = null; - shouldSet = true; - + try + { + CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, "(null)"); + m_Property.SetValue(m_Object, null, null); + PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); + } + catch + { + m_Mobile.SendMessage("An exception was caught. The property may not have changed."); + } break; } case 4: // View Properties { - toSet = null; - shouldSet = false; - object obj = m_Property.GetValue(m_Object, null); if (obj == null) @@ -196,30 +191,10 @@ namespace Server.Gumps else viewProps = obj; - break; - } - default: - { - toSet = null; - shouldSet = false; - break; } } - if (shouldSet) - try - { - CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, - toSet == null ? "(null)" : toSet.ToString()); - m_Property.SetValue(m_Object, toSet, null); - PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); - } - catch - { - m_Mobile.SendMessage("An exception was caught. The property may not have changed."); - } - if (shouldSend) m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List)); @@ -256,52 +231,41 @@ namespace Server.Gumps public override void OnResponse(Mobile from, string text) { - object toSet; - bool shouldSet; - try { int serial = Utility.ToInt32(text); - toSet = World.FindEntity(serial); + IEntity toSet = World.FindEntity(serial); if (toSet == null) { - shouldSet = false; m_Mobile.SendMessage("No object with that serial was found."); } - else if (!m_Type.IsAssignableFrom(toSet.GetType())) + else if (!m_Type.IsInstanceOfType(toSet)) { - toSet = null; - shouldSet = false; m_Mobile.SendMessage("The object with that serial could not be assigned to a property of type : {0}", m_Type.Name); } else { - shouldSet = true; + try + { + CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, + toSet.ToString()); + m_Property.SetValue(m_Object, toSet, null); + PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); + } + catch + { + m_Mobile.SendMessage("An exception was caught. The property may not have changed."); + } } } catch { - toSet = null; - shouldSet = false; m_Mobile.SendMessage("Bad format"); } - if (shouldSet) - try - { - CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, - toSet == null ? "(null)" : toSet.ToString()); - m_Property.SetValue(m_Object, toSet, null); - PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); - } - catch - { - m_Mobile.SendMessage("An exception was caught. The property may not have changed."); - } - m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List)); } } diff --git a/Scripts/Gumps/SetSecureLevelGump.cs b/Scripts/Gumps/SetSecureLevelGump.cs index f422d17d4..a56fce9fb 100644 --- a/Scripts/Gumps/SetSecureLevelGump.cs +++ b/Scripts/Gumps/SetSecureLevelGump.cs @@ -44,7 +44,7 @@ namespace Server.Gumps AddHtmlLocalized(45, 110, 150, 20, 1061279, GetColor(SecureLevel.Friends), false, false); // Friends Mobile houseOwner = house.Owner; - if (Guild.NewGuildSystem && house != null && houseOwner?.Guild != null && + if (Guild.NewGuildSystem && houseOwner?.Guild != null && ((Guild)houseOwner.Guild).Leader == houseOwner ) //Only the actual House owner AND guild master can set guild secures { diff --git a/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs b/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs index 63fd02d25..554fbe0c1 100644 --- a/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs +++ b/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs @@ -65,32 +65,32 @@ namespace Server.Engines.Events { Mobile twin = new NaughtyTwin(m_From); - if (twin != null && !twin.Deleted) + if (twin.Deleted) + return; + + foreach (Item item in m_From.Items) + if (item.Layer != Layer.Backpack && item.Layer != Layer.Mount && item.Layer != Layer.Bank) + m_Items.Add(item); + + if (m_Items.Count > 0) { - foreach (Item item in m_From.Items) + for (int i = 0; i < m_Items.Count; i++) /* dupe exploits start out like this ... */ + twin.AddItem(Mobile.LiftItemDupe(m_Items[i], 1)); + + foreach (Item item in twin.Items) /* ... and end like this */ if (item.Layer != Layer.Backpack && item.Layer != Layer.Mount && item.Layer != Layer.Bank) - m_Items.Add(item); - - if (m_Items.Count > 0) - { - for (int i = 0; i < m_Items.Count; i++) /* dupe exploits start out like this ... */ - twin.AddItem(Mobile.LiftItemDupe(m_Items[i], 1)); - - foreach (Item item in twin.Items) /* ... and end like this */ - if (item.Layer != Layer.Backpack && item.Layer != Layer.Mount && item.Layer != Layer.Bank) - item.Movable = false; - } - - twin.Hue = m_From.Hue; - twin.BodyValue = m_From.BodyValue; - twin.Kills = m_From.Kills; - - Point3D point = RandomPointOneAway(m_From.X, m_From.Y, m_From.Z, m_From.Map); - - twin.MoveToWorld(m_From.Map.CanSpawnMobile(point) ? point : m_From.Location, m_From.Map); - - Timer.DelayCall(TimeSpan.FromSeconds(5), DeleteTwin, twin); + item.Movable = false; } + + twin.Hue = m_From.Hue; + twin.BodyValue = m_From.BodyValue; + twin.Kills = m_From.Kills; + + Point3D point = RandomPointOneAway(m_From.X, m_From.Y, m_From.Z, m_From.Map); + + twin.MoveToWorld(m_From.Map.CanSpawnMobile(point) ? point : m_From.Location, m_From.Map); + + Timer.DelayCall(TimeSpan.FromSeconds(5), DeleteTwin, twin); } } @@ -184,11 +184,11 @@ namespace Server.Engines.Events { m_Begged.Say(1076770); /* TRICK! */ - int m_Action = Utility.Random(4); + int action = Utility.Random(4); - if (m_Action == 0) + if (action == 0) Timer.DelayCall(OneSecond, OneSecond, 10, Bleeding, from); - else if (m_Action == 1) + else if (action == 1) Timer.DelayCall(TimeSpan.FromSeconds(2), SolidHueMobile, from); else Timer.DelayCall(TimeSpan.FromSeconds(2), MakeTwin, from); @@ -302,8 +302,6 @@ namespace Server.Engines.Events public static Point3D RandomMoongate(Mobile target) { - Map map = target.Map; - switch (target.Map.MapID) { case 2: return Ilshenar_Locations[Utility.Random(Ilshenar_Locations.Length)]; diff --git a/Scripts/Items/Addons/GiantWebs.cs b/Scripts/Items/Addons/GiantWebs.cs index d715e2364..67438f036 100644 --- a/Scripts/Items/Addons/GiantWebs.cs +++ b/Scripts/Items/Addons/GiantWebs.cs @@ -7,11 +7,10 @@ namespace Server.Items { int itemID = 4280; int count = 5; - bool leftToRight = false; for (int i = 0; i < count; ++i) - AddComponent(new AddonComponent(itemID++), leftToRight ? i : count - 1 - i, - -(leftToRight ? i : count - 1 - i), 0); + AddComponent(new AddonComponent(itemID++), count - 1 - i, + -(count - 1 - i), 0); } public GiantWeb1(Serial serial) @@ -41,11 +40,10 @@ namespace Server.Items { int itemID = 4285; int count = 5; - bool leftToRight = true; for (int i = 0; i < count; ++i) - AddComponent(new AddonComponent(itemID++), leftToRight ? i : count - 1 - i, - -(leftToRight ? i : count - 1 - i), 0); + AddComponent(new AddonComponent(itemID++), i, + -i, 0); } public GiantWeb2(Serial serial) @@ -75,11 +73,10 @@ namespace Server.Items { int itemID = 4290; int count = 4; - bool leftToRight = true; for (int i = 0; i < count; ++i) - AddComponent(new AddonComponent(itemID++), leftToRight ? i : count - 1 - i, - -(leftToRight ? i : count - 1 - i), 0); + AddComponent(new AddonComponent(itemID++), i, + -i, 0); } public GiantWeb3(Serial serial) @@ -109,11 +106,10 @@ namespace Server.Items { int itemID = 4294; int count = 4; - bool leftToRight = false; for (int i = 0; i < count; ++i) - AddComponent(new AddonComponent(itemID++), leftToRight ? i : count - 1 - i, - -(leftToRight ? i : count - 1 - i), 0); + AddComponent(new AddonComponent(itemID++), count - 1 - i, + -(count - 1 - i), 0); } public GiantWeb4(Serial serial) @@ -143,11 +139,10 @@ namespace Server.Items { int itemID = 4298; int count = 4; - bool leftToRight = true; for (int i = 0; i < count; ++i) - AddComponent(new AddonComponent(itemID++), leftToRight ? i : count - 1 - i, - -(leftToRight ? i : count - 1 - i), 0); + AddComponent(new AddonComponent(itemID++), i, + -i, 0); } public GiantWeb5(Serial serial) @@ -177,11 +172,10 @@ namespace Server.Items { int itemID = 4302; int count = 4; - bool leftToRight = false; for (int i = 0; i < count; ++i) - AddComponent(new AddonComponent(itemID++), leftToRight ? i : count - 1 - i, - -(leftToRight ? i : count - 1 - i), 0); + AddComponent(new AddonComponent(itemID++), count - 1 - i, + -(count - 1 - i), 0); } public GiantWeb6(Serial serial) diff --git a/Scripts/Items/Containers/FillableContainers.cs b/Scripts/Items/Containers/FillableContainers.cs index aaad7efc9..b288c3065 100644 --- a/Scripts/Items/Containers/FillableContainers.cs +++ b/Scripts/Items/Containers/FillableContainers.cs @@ -197,21 +197,21 @@ namespace Server.Items { Item item = m_Content.Construct(); - if (item != null) + if (item == null) + continue; + + List list = Items; + + for (int j = 0; j < list.Count; ++j) { - List list = Items; + Item subItem = list[j]; - for (int j = 0; j < list.Count; ++j) - { - Item subItem = list[j]; - - if (!(subItem is Container) && subItem.StackWith(null, item, false)) - break; - } - - if (item != null && !item.Deleted) - DropItem(item); + if (!(subItem is Container) && subItem.StackWith(null, item, false)) + break; } + + if (!item.Deleted) + DropItem(item); } } diff --git a/Scripts/Items/Facial/Beard.cs b/Scripts/Items/Facial/Beard.cs index 7dced0ecc..55f805476 100644 --- a/Scripts/Items/Facial/Beard.cs +++ b/Scripts/Items/Facial/Beard.cs @@ -17,11 +17,7 @@ namespace Server.Items } }*/ - protected Beard(int itemID) : this(itemID, 0) - { - } - - protected Beard(int itemID, int hue) : base(itemID) + protected Beard(int itemID, int hue = 0) : base(itemID) { LootType = LootType.Blessed; Layer = Layer.FacialHair; @@ -67,12 +63,7 @@ namespace Server.Items public class GenericBeard : Beard { - private GenericBeard(int itemID) : this(itemID, 0) - { - } - - - private GenericBeard(int itemID, int hue) : base(itemID, hue) + private GenericBeard(int itemID, int hue = 0) : base(itemID, hue) { } @@ -97,12 +88,7 @@ namespace Server.Items public class LongBeard : Beard { - private LongBeard() - : this(0) - { - } - - private LongBeard(int hue) + private LongBeard(int hue = 0) : base(0x203E, hue) { } @@ -128,13 +114,7 @@ namespace Server.Items public class ShortBeard : Beard { - private ShortBeard() - : this(0) - { - } - - - private ShortBeard(int hue) + private ShortBeard(int hue = 0) : base(0x203f, hue) { } @@ -160,13 +140,7 @@ namespace Server.Items public class Goatee : Beard { - private Goatee() - : this(0) - { - } - - - private Goatee(int hue) + private Goatee(int hue = 0) : base(0x2040, hue) { } @@ -192,13 +166,7 @@ namespace Server.Items public class Mustache : Beard { - private Mustache() - : this(0) - { - } - - - private Mustache(int hue) + private Mustache(int hue = 0) : base(0x2041, hue) { } @@ -224,13 +192,7 @@ namespace Server.Items public class MediumShortBeard : Beard { - private MediumShortBeard() - : this(0) - { - } - - - private MediumShortBeard(int hue) + private MediumShortBeard(int hue = 0) : base(0x204B, hue) { } @@ -256,13 +218,7 @@ namespace Server.Items public class MediumLongBeard : Beard { - private MediumLongBeard() - : this(0) - { - } - - - private MediumLongBeard(int hue) + private MediumLongBeard(int hue = 0) : base(0x204C, hue) { } @@ -288,13 +244,7 @@ namespace Server.Items public class Vandyke : Beard { - private Vandyke() - : this(0) - { - } - - - private Vandyke(int hue) + private Vandyke(int hue = 0) : base(0x204D, hue) { } diff --git a/Scripts/Items/Facial/Hair.cs b/Scripts/Items/Facial/Hair.cs index 1adce6ab5..a78da945b 100644 --- a/Scripts/Items/Facial/Hair.cs +++ b/Scripts/Items/Facial/Hair.cs @@ -62,12 +62,7 @@ namespace Server.Items } * */ - protected Hair(int itemID) - : this(itemID, 0) - { - } - - protected Hair(int itemID, int hue) + protected Hair(int itemID, int hue = 0) : base(itemID) { LootType = LootType.Blessed; @@ -115,13 +110,7 @@ namespace Server.Items public class GenericHair : Hair { - private GenericHair(int itemID) - : this(itemID, 0) - { - } - - - private GenericHair(int itemID, int hue) + private GenericHair(int itemID, int hue = 0) : base(itemID, hue) { } @@ -148,13 +137,7 @@ namespace Server.Items public class Mohawk : Hair { - private Mohawk() - : this(0) - { - } - - - private Mohawk(int hue) + private Mohawk(int hue = 0) : base(0x2044, hue) { } @@ -181,13 +164,7 @@ namespace Server.Items public class PageboyHair : Hair { - private PageboyHair() - : this(0) - { - } - - - private PageboyHair(int hue) + private PageboyHair(int hue = 0) : base(0x2045, hue) { } @@ -214,13 +191,7 @@ namespace Server.Items public class BunsHair : Hair { - private BunsHair() - : this(0) - { - } - - - private BunsHair(int hue) + private BunsHair(int hue = 0) : base(0x2046, hue) { } @@ -247,13 +218,7 @@ namespace Server.Items public class LongHair : Hair { - private LongHair() - : this(0) - { - } - - - private LongHair(int hue) + private LongHair(int hue = 0) : base(0x203C, hue) { } @@ -280,13 +245,7 @@ namespace Server.Items public class ShortHair : Hair { - private ShortHair() - : this(0) - { - } - - - private ShortHair(int hue) + private ShortHair(int hue = 0) : base(0x203B, hue) { } @@ -313,13 +272,7 @@ namespace Server.Items public class PonyTail : Hair { - private PonyTail() - : this(0) - { - } - - - private PonyTail(int hue) + private PonyTail(int hue = 0) : base(0x203D, hue) { } @@ -346,13 +299,7 @@ namespace Server.Items public class Afro : Hair { - private Afro() - : this(0) - { - } - - - private Afro(int hue) + private Afro(int hue = 0) : base(0x2047, hue) { } @@ -379,13 +326,7 @@ namespace Server.Items public class ReceedingHair : Hair { - private ReceedingHair() - : this(0) - { - } - - - private ReceedingHair(int hue) + private ReceedingHair(int hue = 0) : base(0x2048, hue) { } @@ -412,13 +353,7 @@ namespace Server.Items public class TwoPigTails : Hair { - private TwoPigTails() - : this(0) - { - } - - - private TwoPigTails(int hue) + private TwoPigTails(int hue = 0) : base(0x2049, hue) { } @@ -445,13 +380,7 @@ namespace Server.Items public class KrisnaHair : Hair { - private KrisnaHair() - : this(0) - { - } - - - private KrisnaHair(int hue) + private KrisnaHair(int hue = 0) : base(0x204A, hue) { } diff --git a/Scripts/Items/Misc/ArcaneGem.cs b/Scripts/Items/Misc/ArcaneGem.cs index 59e07bde4..78795391b 100644 --- a/Scripts/Items/Misc/ArcaneGem.cs +++ b/Scripts/Items/Misc/ArcaneGem.cs @@ -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; diff --git a/Scripts/Items/Misc/Corpses/Corpse.cs b/Scripts/Items/Misc/Corpses/Corpse.cs index fa7eec7f2..3f3651ff9 100644 --- a/Scripts/Items/Misc/Corpses/Corpse.cs +++ b/Scripts/Items/Misc/Corpses/Corpse.cs @@ -488,44 +488,32 @@ namespace Server.Items public static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List initialContent, List 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()); + c = new MilitiaFighterCorpse(owner, hair, facialhair, equipItems); else - c = new Corpse(owner, hair, facialhair, shouldFillCorpse ? equipItems : new List()); + 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; } diff --git a/Scripts/Items/Misc/DeceitBrazier.cs b/Scripts/Items/Misc/DeceitBrazier.cs index b001f778d..2b7d9ed83 100644 --- a/Scripts/Items/Misc/DeceitBrazier.cs +++ b/Scripts/Items/Misc/DeceitBrazier.cs @@ -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. diff --git a/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs b/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs index aca9c46c0..571818323 100644 --- a/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs +++ b/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs @@ -143,16 +143,13 @@ namespace Server.Items { BasePotion pot = (BasePotion)Activator.CreateInstance(GetType()); - if (pot != null) - { - Amount--; + Amount--; - if (from.Backpack != null && !from.Backpack.Deleted) - from.Backpack.DropItem(pot); - else - pot.MoveToWorld(from.Location, from.Map); - pot.Drink(from); - } + if (from.Backpack != null && !from.Backpack.Deleted) + from.Backpack.DropItem(pot); + else + pot.MoveToWorld(from.Location, from.Map); + pot.Drink(from); } else { diff --git a/Scripts/Items/Skill Items/Tools/BaseRunicTool.cs b/Scripts/Items/Skill Items/Tools/BaseRunicTool.cs index f9b132e5a..49d255175 100644 --- a/Scripts/Items/Skill Items/Tools/BaseRunicTool.cs +++ b/Scripts/Items/Skill Items/Tools/BaseRunicTool.cs @@ -142,13 +142,8 @@ namespace Server.Items return low + (high - low) * percent / 1000001; } - private static void ApplyAttribute(AosAttributes attrs, int min, int max, AosAttribute attr, int low, int high) - { - ApplyAttribute(attrs, min, max, attr, low, high, 1); - } - private static void ApplyAttribute(AosAttributes attrs, int min, int max, AosAttribute attr, int low, int high, - int scale) + int scale = 1) { if (attr == AosAttribute.CastSpeed) attrs[attr] += Scale(min, max, low / scale, high / scale) * scale; @@ -436,9 +431,7 @@ namespace Server.Items public static void GetElementalDamages(BaseWeapon weapon, bool randomizeOrder) { - int fire, phys, cold, nrgy, pois, chaos, direct; - - weapon.GetDamageTypes(null, out phys, out fire, out cold, out pois, out nrgy, out chaos, out direct); + weapon.GetDamageTypes(null, out int phys, out int fire, out int cold, out int pois, out int nrgy, out int chaos, out int direct); int totalDamage = phys; diff --git a/Scripts/Items/Special/Holiday/IcyPatch.cs b/Scripts/Items/Special/Holiday/IcyPatch.cs index 96b99d9c4..a14d765dc 100644 --- a/Scripts/Items/Special/Holiday/IcyPatch.cs +++ b/Scripts/Items/Special/Holiday/IcyPatch.cs @@ -52,7 +52,7 @@ namespace Server.Items if (freeze) { - m.Frozen = freeze; + m.Frozen = true; Timer.DelayCall(TimeSpan.FromSeconds(message == 1095162 ? 2.0 : 1.25), new TimerStateCallback(EndFall_Callback), m); } diff --git a/Scripts/Items/Special/Veteran Rewards/Banner.cs b/Scripts/Items/Special/Veteran Rewards/Banner.cs index 92b8bccfd..2348304d7 100644 --- a/Scripts/Items/Special/Veteran Rewards/Banner.cs +++ b/Scripts/Items/Special/Veteran Rewards/Banner.cs @@ -301,12 +301,7 @@ namespace Server.Items } else if (north || west) { - Banner banner = null; - - if (north) - banner = new Banner(m_ItemID); - else if (west) - banner = new Banner(m_ItemID + 1); + Banner banner = new Banner(m_ItemID + (west ? 0 : 1)); house.Addons.Add(banner); diff --git a/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs b/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs index 7e7d27c30..8cff94aea 100644 --- a/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs +++ b/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs @@ -210,11 +210,7 @@ namespace Server.Items private DecorativeShieldDeed m_Shield; - public InternalGump(DecorativeShieldDeed shield) : this(shield, 1) - { - } - - public InternalGump(DecorativeShieldDeed shield, int page) : base(150, 50) + public InternalGump(DecorativeShieldDeed shield, int page = 1) : base(150, 50) { m_Shield = shield; m_Page = page; @@ -321,12 +317,7 @@ namespace Server.Items } else if (north || west) { - DecorativeShield shield = null; - - if (north) - shield = new DecorativeShield(m_ItemID); - else if (west) - shield = new DecorativeShield(GetWestItemID(m_ItemID)); + DecorativeShield shield = new DecorativeShield(west ? GetWestItemID(m_ItemID) : m_ItemID); house.Addons.Add(shield); diff --git a/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs b/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs index 41e7385b9..204dcd8d9 100644 --- a/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs +++ b/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs @@ -309,12 +309,7 @@ namespace Server.Items } else if (north || west) { - HangingSkeleton banner = null; - - if (north) - banner = new HangingSkeleton(m_ItemID); - else if (west) - banner = new HangingSkeleton(GetWestItemID(m_ItemID)); + HangingSkeleton banner = new HangingSkeleton(west ? GetWestItemID(m_ItemID) : m_ItemID); house.Addons.Add(banner); diff --git a/Scripts/Items/Weapons/Abilities/DoubleStrike.cs b/Scripts/Items/Weapons/Abilities/DoubleStrike.cs index a9e25450d..8a2f9bc3d 100644 --- a/Scripts/Items/Weapons/Abilities/DoubleStrike.cs +++ b/Scripts/Items/Weapons/Abilities/DoubleStrike.cs @@ -25,7 +25,7 @@ namespace Server.Items // Swing again: // If no combatant, wrong map, one of us is a ghost, or cannot see, or deleted, then stop combat - if (defender == null || defender.Deleted || attacker.Deleted || defender.Map != attacker.Map || + if (defender.Deleted || attacker.Deleted || defender.Map != attacker.Map || !defender.Alive || !attacker.Alive || !attacker.CanSee(defender)) { attacker.Combatant = null; diff --git a/Scripts/Items/Weapons/BaseWeapon.cs b/Scripts/Items/Weapons/BaseWeapon.cs index 2c4db1d55..927e7d480 100644 --- a/Scripts/Items/Weapons/BaseWeapon.cs +++ b/Scripts/Items/Weapons/BaseWeapon.cs @@ -1225,9 +1225,7 @@ namespace Server.Items AddBlood(attacker, defender, damage); - int phys, fire, cold, pois, nrgy, chaos, direct; - - GetDamageTypes(attacker, out phys, out fire, out cold, out pois, out nrgy, out chaos, out direct); + GetDamageTypes(attacker, out int phys, out int fire, out int cold, out int pois, out int nrgy, out int chaos, out int direct); if (Core.ML && this is BaseRanged) if (attacker.FindItemOnLayer(Layer.Cloak) is BaseQuiver quiver) diff --git a/Scripts/Misc/Cleanup.cs b/Scripts/Misc/Cleanup.cs index f552380f0..6ba6d8fd8 100644 --- a/Scripts/Misc/Cleanup.cs +++ b/Scripts/Misc/Cleanup.cs @@ -128,8 +128,7 @@ namespace Server.Misc return false; if (item is ICommodity || item is BaseBoat - || item is Fish || item is BigFish - || item is BasePotion || item is Food || item is CookableFood + || item is Fish || item is BigFish || item is Food || item is CookableFood || item is SpecialFishingNet || item is BaseMagicFish || item is Shoes || item is Sandals || item is Boots || item is ThighBoots @@ -137,7 +136,6 @@ namespace Server.Misc || item is BaseArmor || item is BaseWeapon || item is BaseClothing || item is BaseJewel && Core.AOS - || item is BasePotion && Core.ML #region Champion artifacts diff --git a/Scripts/Misc/Titles.cs b/Scripts/Misc/Titles.cs index 4e7e1dcb3..31813a197 100644 --- a/Scripts/Misc/Titles.cs +++ b/Scripts/Misc/Titles.cs @@ -349,7 +349,7 @@ namespace Server.Misc if (highest == null || check.BaseFixedPoint > highest.BaseFixedPoint) highest = check; - else if (highest != null && highest.Lock != SkillLock.Up && check.Lock == SkillLock.Up && + else if (highest.Lock != SkillLock.Up && check.Lock == SkillLock.Up && check.BaseFixedPoint == highest.BaseFixedPoint) highest = check; } diff --git a/Scripts/Misc/ValidationQueue.cs b/Scripts/Misc/ValidationQueue.cs index f878d9210..e223e1f79 100644 --- a/Scripts/Misc/ValidationQueue.cs +++ b/Scripts/Misc/ValidationQueue.cs @@ -37,14 +37,11 @@ namespace Server { Type type = typeof(T); - if (type != null) - { - MethodInfo m = type.GetMethod("Validate", BindingFlags.Instance | BindingFlags.Public); + MethodInfo m = type.GetMethod("Validate", BindingFlags.Instance | BindingFlags.Public); - if (m != null) - for (int i = 0; i < m_Queue.Count; ++i) - m.Invoke(m_Queue[i], null); - } + if (m != null) + for (int i = 0; i < m_Queue.Count; ++i) + m.Invoke(m_Queue[i], null); m_Queue.Clear(); m_Queue = null; diff --git a/Scripts/Misc/VendorGenerator.cs b/Scripts/Misc/VendorGenerator.cs index bf4649989..b9a826bfe 100644 --- a/Scripts/Misc/VendorGenerator.cs +++ b/Scripts/Misc/VendorGenerator.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using Server.Commands; using Server.Mobiles; @@ -140,7 +141,7 @@ namespace Server bool hasSpawner = false; - for (int j = 0; !hasSpawner && j < si.m_Floor.Count; ++j) + for (int j = 0; j < si.m_Floor.Count; ++j) { Point2D fp = (Point2D)si.m_Floor[j]; @@ -148,13 +149,7 @@ namespace Server yTotal += fp.Y; IPooledEnumerable eable = map.GetItemsInRange(new Point3D(fp.X, fp.Y, 0), 0); - - foreach (Spawner item in eable) - { - hasSpawner = true; - break; - } - + hasSpawner = eable.Any(); eable.Free(); if (hasSpawner) @@ -237,9 +232,7 @@ namespace Server if (cp == Point2D.Zero) continue; - int z; - - if (!GetFloorZ(map, cp.X, cp.Y, out z)) + if (!GetFloorZ(map, cp.X, cp.Y, out int z)) continue; new Spawner(1, 1, 1, 0, 4, (string)names[j]).MoveToWorld(new Point3D(cp.X, cp.Y, z), map); diff --git a/Scripts/Mobiles/AI/MageAI.cs b/Scripts/Mobiles/AI/MageAI.cs index 1e8633c0b..c0627c6d4 100644 --- a/Scripts/Mobiles/AI/MageAI.cs +++ b/Scripts/Mobiles/AI/MageAI.cs @@ -150,12 +150,7 @@ namespace Server.Mobiles m_Mobile.UseSkill(SkillName.SpiritSpeak); } else - { spell = new GreaterHealSpell(m_Mobile, null); - - if (spell == null) - spell = new HealSpell(m_Mobile, null); - } } else if (m_Mobile.Hits < m_Mobile.HitsMax - 10) { @@ -933,7 +928,7 @@ namespace Server.Mobiles { double prio = m_Mobile.GetDistanceToSqrt(m); - if (!activeOnly && (inactive == null || prio < inactPrio)) + if (inactive == null || prio < inactPrio) { inactive = m; inactPrio = prio; diff --git a/Scripts/Mobiles/Animals/Mounts/Ethereals.cs b/Scripts/Mobiles/Animals/Mounts/Ethereals.cs index 51c01a23d..507b55e40 100644 --- a/Scripts/Mobiles/Animals/Mounts/Ethereals.cs +++ b/Scripts/Mobiles/Animals/Mounts/Ethereals.cs @@ -96,7 +96,7 @@ namespace Server.Mobiles UnmountMe(); RemoveFollowers(); - m_Rider = value; + m_Rider = null; } else { diff --git a/Scripts/Mobiles/BaseCreature.cs b/Scripts/Mobiles/BaseCreature.cs index 03f8a8971..83fd4a36b 100644 --- a/Scripts/Mobiles/BaseCreature.cs +++ b/Scripts/Mobiles/BaseCreature.cs @@ -154,7 +154,7 @@ namespace Server.Mobiles { object[] objs = t.GetCustomAttributes(typeof(FriendlyNameAttribute), false); - if (objs != null && objs.Length > 0) + if (objs.Length > 0) { FriendlyNameAttribute friendly = objs[0] as FriendlyNameAttribute; diff --git a/Scripts/Mobiles/Monsters/LBR/Meers/MeerWarrior.cs b/Scripts/Mobiles/Monsters/LBR/Meers/MeerWarrior.cs index fdd0e101b..e45c726f2 100644 --- a/Scripts/Mobiles/Monsters/LBR/Meers/MeerWarrior.cs +++ b/Scripts/Mobiles/Monsters/LBR/Meers/MeerWarrior.cs @@ -55,7 +55,7 @@ namespace Server.Mobiles public override void OnDamage(int amount, Mobile from, bool willKill) { - if (from != null && !willKill && amount > 3 && from != null && !InRange(from, 7)) + if (from != null && !willKill && amount > 3 && !InRange(from, 7)) { MovingEffect(from, 0xF51, 10, 0, false, false); SpellHelper.Damage(TimeSpan.FromSeconds(1.0), from, this, Utility.RandomMinMax(30, 40) - (Core.AOS ? 0 : 10), diff --git a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs index b65490fb0..ae773754c 100644 --- a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs +++ b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs @@ -292,11 +292,7 @@ namespace Server.Mobiles { private PlagueBeastLord m_Lord; - public DecayTimer(PlagueBeastLord lord) : this(lord, 0, 120) - { - } - - public DecayTimer(PlagueBeastLord lord, int count, int deadline) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1)) + public DecayTimer(PlagueBeastLord lord, int count = 0, int deadline = 120) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1)) { m_Lord = lord; Count = count; diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 0cec8bfe3..9e8c8f36c 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -571,7 +571,7 @@ namespace Server.Mobiles private static bool CheckBlock(MountBlock block) { - return block is MountBlock && block.m_Timer.Running; + return block?.m_Timer.Running == true; } public void SetMountBlock(BlockMountType type, TimeSpan duration, bool dismount) @@ -640,9 +640,7 @@ namespace Server.Mobiles if (ns == null) return; - int global, personal; - - ComputeLightLevels(out global, out personal); + ComputeLightLevels(out int global, out int personal); if (!forceResend) forceResend = global != m_LastGlobalLight || personal != m_LastPersonalLight; diff --git a/Scripts/Spells/Necromancy/Strangle.cs b/Scripts/Spells/Necromancy/Strangle.cs index 7f7c3ced1..5cdf68e0c 100644 --- a/Scripts/Spells/Necromancy/Strangle.cs +++ b/Scripts/Spells/Necromancy/Strangle.cs @@ -227,8 +227,8 @@ namespace Server.Spells.Necromancy protected override void OnTarget(Mobile from, object o) { - if (o is Mobile) - m_Owner.Target((Mobile)o); + if (o is Mobile mobile) + m_Owner.Target(mobile); } protected override void OnTargetFinish(Mobile from) diff --git a/Scripts/Spells/Necromancy/SummonFamiliar.cs b/Scripts/Spells/Necromancy/SummonFamiliar.cs index 546368457..16a51287d 100644 --- a/Scripts/Spells/Necromancy/SummonFamiliar.cs +++ b/Scripts/Spells/Necromancy/SummonFamiliar.cs @@ -128,12 +128,12 @@ namespace Server.Spells.Necromancy AddButton(27, 53 + i * 21, 9702, 9703, i + 1, GumpButtonType.Reply, 0); - if (name is int) - AddHtmlLocalized(50, 51 + i * 21, 150, 20, (int)name, enabled ? EnabledColor16 : DisabledColor16, false, + if (name is int intName) + AddHtmlLocalized(50, 51 + i * 21, 150, 20, intName, enabled ? EnabledColor16 : DisabledColor16, false, false); - else if (name is string) + else if (name is string strName) AddHtml(50, 51 + i * 21, 150, 20, - $"{name}", false, + $"{strName}", false, false); } } diff --git a/Scripts/Spells/Necromancy/VengefulSpirit.cs b/Scripts/Spells/Necromancy/VengefulSpirit.cs index 3b65bccf0..5e64c948f 100644 --- a/Scripts/Spells/Necromancy/VengefulSpirit.cs +++ b/Scripts/Spells/Necromancy/VengefulSpirit.cs @@ -82,8 +82,8 @@ namespace Server.Spells.Necromancy protected override void OnTarget(Mobile from, object o) { - if (o is Mobile) - m_Owner.Target((Mobile)o); + if (o is Mobile mobile) + m_Owner.Target(mobile); } protected override void OnTargetFinish(Mobile from) diff --git a/Scripts/Spells/Necromancy/Wither.cs b/Scripts/Spells/Necromancy/Wither.cs index 61b9d9376..a76633e03 100644 --- a/Scripts/Spells/Necromancy/Wither.cs +++ b/Scripts/Spells/Necromancy/Wither.cs @@ -52,10 +52,8 @@ namespace Server.Spells.Necromancy { if (isMonster) { - if (m is BaseCreature) + if (m is BaseCreature bc) { - BaseCreature bc = (BaseCreature)m; - if (!bc.Controlled && !bc.Summoned && bc.Team == cbc.Team) continue; } diff --git a/Scripts/Spells/Necromancy/WraithForm.cs b/Scripts/Spells/Necromancy/WraithForm.cs index ba64c8f22..3ac9a7da6 100644 --- a/Scripts/Spells/Necromancy/WraithForm.cs +++ b/Scripts/Spells/Necromancy/WraithForm.cs @@ -33,8 +33,8 @@ namespace Server.Spells.Necromancy public override void DoEffect(Mobile m) { - if (m is PlayerMobile) - ((PlayerMobile)m).IgnoreMobiles = true; + if (m is PlayerMobile mobile) + mobile.IgnoreMobiles = true; m.PlaySound(0x17F); m.FixedParticles(0x374A, 1, 15, 9902, 1108, 4, EffectLayer.Waist); @@ -42,8 +42,8 @@ namespace Server.Spells.Necromancy public override void RemoveEffect(Mobile m) { - if (m is PlayerMobile && m.AccessLevel == AccessLevel.Player) - ((PlayerMobile)m).IgnoreMobiles = false; + if (m is PlayerMobile mobile && mobile.AccessLevel == AccessLevel.Player) + mobile.IgnoreMobiles = false; } } } \ No newline at end of file diff --git a/Scripts/Spells/Ninjitsu/AnimalForm.cs b/Scripts/Spells/Ninjitsu/AnimalForm.cs index 51b72991f..7db41dfba 100644 --- a/Scripts/Spells/Ninjitsu/AnimalForm.cs +++ b/Scripts/Spells/Ninjitsu/AnimalForm.cs @@ -482,9 +482,9 @@ namespace Server.Spells.Ninjitsu m_Caster.SendLocalizedMessage(1060174, mana.ToString()); // You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability. } - else if (m_Caster is PlayerMobile && (m_Caster as PlayerMobile).MountBlockReason != BlockMountType.None) + else if (m_Caster is PlayerMobile mobile && mobile.MountBlockReason != BlockMountType.None) { - m_Caster.SendLocalizedMessage(1063108); // You cannot use this ability right now. + mobile.SendLocalizedMessage(1063108); // You cannot use this ability right now. } else if (BaseFormTalisman.EntryEnabled(sender.Mobile, entry.Type)) { diff --git a/Scripts/Spells/Ninjitsu/DeathStrike.cs b/Scripts/Spells/Ninjitsu/DeathStrike.cs index 02b86819d..43e702c5f 100644 --- a/Scripts/Spells/Ninjitsu/DeathStrike.cs +++ b/Scripts/Spells/Ninjitsu/DeathStrike.cs @@ -85,9 +85,7 @@ namespace Server.Spells.Ninjitsu public static void AddStep(Mobile m) { - DeathStrikeInfo info = m_Table[m] as DeathStrikeInfo; - - if (info == null) + if (!(m_Table[m] is DeathStrikeInfo info)) return; if (++info.m_Steps >= 5) @@ -98,12 +96,10 @@ namespace Server.Spells.Ninjitsu { Mobile defender = (Mobile)state; - DeathStrikeInfo info = m_Table[defender] as DeathStrikeInfo; - - if (info == null) //sanity + if (!(m_Table[defender] is DeathStrikeInfo info)) //sanity return; - int maxDamage, damage = 0; + int damage; double ninjitsu = info.m_Attacker.Skills[SkillName.Ninjitsu].Value; double stalkingBonus = Tracking.GetStalkingBonus(info.m_Attacker, info.m_Target); @@ -130,7 +126,7 @@ namespace Server.Spells.Ninjitsu int divisor = info.m_Steps >= 5 ? 30 : 80; double baseDamage = ninjitsu / divisor * 10; - maxDamage = info.m_Steps >= 5 ? 62 : 22; // DamageBonus is 8 at most. That brings the cap up to 70/30. + int maxDamage = info.m_Steps >= 5 ? 62 : 22; damage = Math.Max(0, Math.Min(maxDamage, (int)(baseDamage + stalkingBonus))) + info.m_DamageBonus; } diff --git a/Scripts/Spells/Third/Fireball.cs b/Scripts/Spells/Third/Fireball.cs index a9f1c03a5..cf1f76707 100644 --- a/Scripts/Spells/Third/Fireball.cs +++ b/Scripts/Spells/Third/Fireball.cs @@ -78,8 +78,8 @@ namespace Server.Spells.Third protected override void OnTarget(Mobile from, object o) { - if (o is Mobile) - m_Owner.Target((Mobile)o); + if (o is Mobile mobile) + m_Owner.Target(mobile); } protected override void OnTargetFinish(Mobile from) diff --git a/Scripts/Spells/Third/MagicLock.cs b/Scripts/Spells/Third/MagicLock.cs index bd6230312..9e60fc007 100644 --- a/Scripts/Spells/Third/MagicLock.cs +++ b/Scripts/Spells/Third/MagicLock.cs @@ -72,8 +72,8 @@ namespace Server.Spells.Third protected override void OnTarget(Mobile from, object o) { - if (o is LockableContainer) - m_Owner.Target((LockableContainer)o); + if (o is LockableContainer container) + m_Owner.Target(container); else from.SendLocalizedMessage(501762); // Target must be an unlocked chest. } diff --git a/Scripts/Spells/Third/Poison.cs b/Scripts/Spells/Third/Poison.cs index 10ec66e50..49455bbe4 100644 --- a/Scripts/Spells/Third/Poison.cs +++ b/Scripts/Spells/Third/Poison.cs @@ -75,17 +75,15 @@ namespace Server.Spells.Third double total = Caster.Skills[SkillName.Magery].Value; - if (Caster is PlayerMobile) + if (Caster is PlayerMobile pm) { - PlayerMobile pm = (PlayerMobile)Caster; - if (pm.DuelContext != null && pm.DuelContext.Started && !pm.DuelContext.Finished && !pm.DuelContext.Ruleset.GetOption("Skills", "Poisoning")) { } else { - total += Caster.Skills[SkillName.Poisoning].Value; + total += pm.Skills[SkillName.Poisoning].Value; } } else @@ -133,7 +131,7 @@ namespace Server.Spells.Third protected override void OnTarget(Mobile from, object o) { - if (o is Mobile) m_Owner.Target((Mobile)o); + if (o is Mobile mobile) m_Owner.Target(mobile); } protected override void OnTargetFinish(Mobile from) diff --git a/Scripts/Spells/Third/Telekinesis.cs b/Scripts/Spells/Third/Telekinesis.cs index cc6dd8d04..086682034 100644 --- a/Scripts/Spells/Third/Telekinesis.cs +++ b/Scripts/Spells/Third/Telekinesis.cs @@ -55,7 +55,7 @@ namespace Server.Spells.Third { item.OnSnoop(Caster); } - else if (item is Corpse && !((Corpse)item).CheckLoot(Caster, null)) + else if (item is Corpse corpse && !corpse.CheckLoot(Caster, null)) { } else if (Caster.Region.OnDoubleClick(Caster, item)) @@ -82,10 +82,10 @@ namespace Server.Spells.Third protected override void OnTarget(Mobile from, object o) { - if (o is ITelekinesisable) - m_Owner.Target((ITelekinesisable)o); - else if (o is Container) - m_Owner.Target((Container)o); + if (o is ITelekinesisable telekinesisable) + m_Owner.Target(telekinesisable); + else if (o is Container container) + m_Owner.Target(container); else from.SendLocalizedMessage(501857); // This spell won't work on that! } diff --git a/Scripts/Spells/Third/Teleport.cs b/Scripts/Spells/Third/Teleport.cs index 4999d9768..f4f9af940 100644 --- a/Scripts/Spells/Third/Teleport.cs +++ b/Scripts/Spells/Third/Teleport.cs @@ -130,9 +130,7 @@ namespace Server.Spells.Third protected override void OnTarget(Mobile from, object o) { - IPoint3D p = o as IPoint3D; - - if (p != null) + if (o is IPoint3D p) m_Owner.Target(p); } diff --git a/Scripts/Spells/Third/Unlock.cs b/Scripts/Spells/Third/Unlock.cs index 164be8f0f..7a4fcc441 100644 --- a/Scripts/Spells/Third/Unlock.cs +++ b/Scripts/Spells/Third/Unlock.cs @@ -37,9 +37,7 @@ namespace Server.Spells.Third protected override void OnTarget(Mobile from, object o) { - IPoint3D loc = o as IPoint3D; - - if (loc == null) + if (!(o is IPoint3D loc)) return; if (m_Owner.CheckSequence()) @@ -81,7 +79,7 @@ namespace Server.Spells.Third int level = (int)(from.Skills[SkillName.Magery].Value * 0.8) - 4; if (level >= cont.RequiredSkill && - !(cont is TreasureMapChest && ((TreasureMapChest)cont).Level > 2)) + !(cont is TreasureMapChest chest && chest.Level > 2)) { cont.Locked = false; diff --git a/Scripts/Spells/Third/WallOfStone.cs b/Scripts/Spells/Third/WallOfStone.cs index 6d4c0302e..d512f42aa 100644 --- a/Scripts/Spells/Third/WallOfStone.cs +++ b/Scripts/Spells/Third/WallOfStone.cs @@ -156,11 +156,9 @@ namespace Server.Spells.Third public override bool OnMoveOver(Mobile m) { - int noto; - if (m is PlayerMobile) { - noto = Notoriety.Compute(m_Caster, m); + int noto = Notoriety.Compute(m_Caster, m); if (noto == Notoriety.Enemy || noto == Notoriety.Ally) return false; } @@ -203,8 +201,8 @@ namespace Server.Spells.Third protected override void OnTarget(Mobile from, object o) { - if (o is IPoint3D) - m_Owner.Target((IPoint3D)o); + if (o is IPoint3D d) + m_Owner.Target(d); } protected override void OnTargetFinish(Mobile from) diff --git a/Scripts/Targets/BladedItemTarget.cs b/Scripts/Targets/BladedItemTarget.cs index 721ce06b9..4fe2b115f 100644 --- a/Scripts/Targets/BladedItemTarget.cs +++ b/Scripts/Targets/BladedItemTarget.cs @@ -18,8 +18,8 @@ namespace Server.Targets protected override void OnTargetOutOfRange(Mobile from, object targeted) { - if (targeted is UnholyBone && from.InRange((UnholyBone)targeted, 12)) - ((UnholyBone)targeted).Carve(from, m_Item); + if (targeted is UnholyBone bone && from.InRange(bone, 12)) + bone.Carve(from, m_Item); else base.OnTargetOutOfRange(from, targeted); } @@ -29,14 +29,12 @@ namespace Server.Targets if (m_Item.Deleted) return; - if (targeted is ICarvable) + if (targeted is ICarvable carvable) { - ((ICarvable)targeted).Carve(from, m_Item); + carvable.Carve(from, m_Item); } - else if (targeted is SwampDragon && ((SwampDragon)targeted).HasBarding) + else if (targeted is SwampDragon pet && pet.HasBarding) { - SwampDragon pet = (SwampDragon)targeted; - if (!pet.Controlled || pet.ControlMaster != from) from.SendLocalizedMessage(1053022); // You cannot remove barding from a swamp dragon you do not own. else @@ -44,9 +42,9 @@ namespace Server.Targets } else { - if (targeted is StaticTarget) + if (targeted is StaticTarget target) { - int itemID = ((StaticTarget)targeted).ItemID; + int itemID = target.ItemID; if (itemID == 0xD15 || itemID == 0xD16) // red mushroom { @@ -56,10 +54,7 @@ namespace Server.Targets if (qs is WitchApprenticeQuest) { - FindIngredientObjective obj = - qs.FindObjective(typeof(FindIngredientObjective)) as FindIngredientObjective; - - if (obj != null && !obj.Completed && obj.Ingredient == Ingredient.RedMushrooms) + if (qs.FindObjective(typeof(FindIngredientObjective)) is FindIngredientObjective obj && !obj.Completed && obj.Ingredient == Ingredient.RedMushrooms) { player.SendLocalizedMessage(1055036); // You slice a red cap mushroom from its stem. obj.Complete(); @@ -72,11 +67,7 @@ namespace Server.Targets HarvestSystem system = Lumberjacking.System; HarvestDefinition def = Lumberjacking.System.Definition; - int tileID; - Map map; - Point3D loc; - - if (!system.GetHarvestDetails(from, m_Item, targeted, out tileID, out map, out loc)) + if (!system.GetHarvestDetails(from, m_Item, targeted, out int tileID, out Map map, out Point3D loc)) { from.SendLocalizedMessage(500494); // You can't use a bladed item on that! } diff --git a/Scripts/Targets/MoveTarget.cs b/Scripts/Targets/MoveTarget.cs index fbe826061..b55765919 100644 --- a/Scripts/Targets/MoveTarget.cs +++ b/Scripts/Targets/MoveTarget.cs @@ -15,9 +15,7 @@ namespace Server.Targets protected override void OnTarget(Mobile from, object o) { - IPoint3D p = o as IPoint3D; - - if (p != null) + if (o is IPoint3D p) { if (!BaseCommand.IsAccessible(from, m_Object)) { @@ -31,17 +29,13 @@ namespace Server.Targets CommandLogging.WriteLine(from, "{0} {1} moving {2} to {3}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(m_Object), new Point3D(p)); - if (m_Object is Item) + if (m_Object is Item item) { - Item item = (Item)m_Object; - if (!item.Deleted) item.MoveToWorld(new Point3D(p), from.Map); } - else if (m_Object is Mobile) + else if (m_Object is Mobile m) { - Mobile m = (Mobile)m_Object; - if (!m.Deleted) m.MoveToWorld(new Point3D(p), from.Map); } diff --git a/Server/Gumps/Gump.cs b/Server/Gumps/Gump.cs index 98b9101a3..0cfa9b4f5 100644 --- a/Server/Gumps/Gump.cs +++ b/Server/Gumps/Gump.cs @@ -340,16 +340,11 @@ namespace Server.Gumps return Encoding.ASCII.GetBytes(str); } - private Packet Compile() - { - return Compile(null); - } - - private Packet Compile(NetState ns) + private Packet Compile(NetState ns = null) { IGumpWriter disp; - if (ns != null && ns.Unpack) + if (ns?.Unpack == true) disp = new DisplayGumpPacked(this); else disp = new DisplayGumpFast(this); @@ -367,11 +362,10 @@ namespace Server.Gumps disp.AppendLayout(m_NoResize); int count = Entries.Count; - GumpEntry e; for (int i = 0; i < count; ++i) { - e = Entries[i]; + GumpEntry e = Entries[i]; disp.AppendLayout(m_BeginLayout); e.AppendTo(ns, disp); diff --git a/Server/Map.cs b/Server/Map.cs index d53d1f8ea..5ccab07f7 100644 --- a/Server/Map.cs +++ b/Server/Map.cs @@ -93,13 +93,13 @@ namespace Server public static IEnumerable SelectMobiles(Sector s, Rectangle2D bounds) where T : Mobile { - return s.Mobiles.OfType().Where(o => o != null && !o.Deleted && bounds.Contains(o)); + return s.Mobiles.OfType().Where(o => !o.Deleted && bounds.Contains(o)); } public static IEnumerable SelectItems(Sector s, Rectangle2D bounds) where T : Item { return s.Items.OfType() - .Where(o => o != null && !o.Deleted && o.Parent == null && o is T && bounds.Contains(o)); + .Where(o => !o.Deleted && o.Parent == null && bounds.Contains(o)); } public static IEnumerable SelectMultis(Sector s, Rectangle2D bounds) @@ -151,12 +151,7 @@ namespace Server return Map.PooledEnumerable.Instantiate(map, bounds, ClientSelector ?? SelectClients); } - public static Map.PooledEnumerable GetEntities(Map map, Rectangle2D bounds) - { - return GetEntities(map, bounds, true, true); - } - - public static Map.PooledEnumerable GetEntities(Map map, Rectangle2D bounds, bool items, bool mobiles) + public static Map.PooledEnumerable GetEntities(Map map, Rectangle2D bounds, bool items = true, bool mobiles = true) { return Map.PooledEnumerable.Instantiate(map, bounds, EntitySelector ?? SelectEntities); } diff --git a/Server/Mobile.cs b/Server/Mobile.cs index f9ef79ecc..2049857e1 100644 --- a/Server/Mobile.cs +++ b/Server/Mobile.cs @@ -8207,20 +8207,15 @@ namespace Server m_CancelCallback = cancelCallback; } - public SimplePrompt(PromptCallback callback, bool callbackHandlesCancel) + public SimplePrompt(PromptCallback callback, bool callbackHandlesCancel = false) { m_Callback = callback; m_CallbackHandlesCancel = callbackHandlesCancel; } - public SimplePrompt(PromptCallback callback) - : this(callback, false) - { - } - public override void OnResponse(Mobile from, string text) { - m_Callback?.Invoke(@from, text); + m_Callback?.Invoke(from, text); } public override void OnCancel(Mobile from) @@ -8229,7 +8224,7 @@ namespace Server m_Callback(from, ""); else { - m_CancelCallback?.Invoke(@from, ""); + m_CancelCallback?.Invoke(from, ""); } } } @@ -8285,7 +8280,7 @@ namespace Server public override void OnResponse(Mobile from, string text) { - m_Callback?.Invoke(@from, text, m_State); + m_Callback?.Invoke(from, text, m_State); } public override void OnCancel(Mobile from) @@ -8294,7 +8289,7 @@ namespace Server m_Callback(from, "", m_State); else { - m_CancelCallback?.Invoke(@from, "", m_State); + m_CancelCallback?.Invoke(from, "", m_State); } } } @@ -8350,7 +8345,7 @@ namespace Server public override void OnResponse(Mobile from, string text) { - m_Callback?.Invoke(@from, text, m_State); + m_Callback?.Invoke(from, text, m_State); } public override void OnCancel(Mobile from) @@ -8359,7 +8354,7 @@ namespace Server m_Callback(from, "", m_State); else { - m_CancelCallback?.Invoke(@from, "", m_State); + m_CancelCallback?.Invoke(from, "", m_State); } } } diff --git a/Server/Utility.cs b/Server/Utility.cs index ebe2b0fa7..2f5545db3 100644 --- a/Server/Utility.cs +++ b/Server/Utility.cs @@ -934,8 +934,7 @@ namespace Server } catch { - double val; - if (double.TryParse(doubleString, out val)) + if (double.TryParse(doubleString, out double val)) return val; return defaultValue; @@ -950,8 +949,7 @@ namespace Server } catch { - int val; - if (int.TryParse(intString, out val)) + if (int.TryParse(intString, out int val)) return val; return defaultValue; @@ -966,9 +964,7 @@ namespace Server } catch { - DateTime d; - - if (DateTime.TryParse(dateTimeString, out d)) + if (DateTime.TryParse(dateTimeString, out DateTime d)) return d; return defaultValue; @@ -983,9 +979,7 @@ namespace Server } catch { - DateTimeOffset d; - - if (DateTimeOffset.TryParse(dateTimeOffsetString, out d)) + if (DateTimeOffset.TryParse(dateTimeOffsetString, out DateTimeOffset d)) return d; return defaultValue;