From 679e8100f4054c007f256bbf8c745b7959cd542c Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 19 Jul 2021 20:49:59 -0700 Subject: [PATCH] cleanup: Fixes bugs and cleans up code (#660) --- .../SerializableEntityGeneration.Class.cs | 4 +- ...rializationMethodSignatureMigrationRule.cs | 1 - .../SourceGeneration.Class.cs | 13 +---- .../SymbolMetadata/SymbolMetadata.UO.cs | 1 - .../Application.cs | 1 - .../Buffers/CircularBufferWriterTests.cs | 1 - Projects/Server/Items/Item.cs | 3 +- Projects/Server/Logging/SerilogLogger.cs | 11 +++++ Projects/Server/Maps/Map.cs | 20 +++----- Projects/Server/NativeReader.cs | 2 +- .../Serialization/SerializableAttribute.cs | 6 ++- Projects/Server/Targeting/Target.cs | 3 -- .../Tests/Multis/Houses/HousePackets.cs | 1 - Projects/UOContent/Commands/Dupe.cs | 1 + .../Generic/Implementors/ObjectConditional.cs | 4 +- Projects/UOContent/Commands/Logging.cs | 1 - .../Commands/Object Creation/CAGObject.cs | 2 +- .../Commands/Object Creation/DecorateMag.cs | 5 +- Projects/UOContent/Commands/ShardTime.cs | 3 +- .../Configuration/EmailConfiguration.cs | 1 - .../UOContent/Context Menus/OpenBankEntry.cs | 2 +- .../Engines/Bulk Orders/BulkMaterialType.cs | 2 +- .../CannedEvil/DungeonChampionSpawn.cs | 2 +- Projects/UOContent/Engines/ConPVP/Arena.cs | 7 +-- .../UOContent/Engines/ConPVP/DuelContext.cs | 19 +------- .../Engines/ConPVP/Games/BombingRun.cs | 3 +- .../ConPVP/Gumps/TournamentBracketGump.cs | 1 - .../Engines/ConPVP/TournamentController.cs | 1 - .../Engines/Craft/Core/CraftGumpItem.cs | 6 +-- .../UOContent/Engines/Craft/Core/CraftItem.cs | 6 +-- .../UOContent/Engines/Craft/DefCarpentry.cs | 2 +- .../UOContent/Engines/Doom/GauntletSpawner.cs | 2 - .../Doom/LeverPuzzle/LeverPuzzleController.cs | 10 ++-- .../Doom/LeverPuzzle/LeverPuzzleRegions.cs | 2 +- .../Engines/Factions/Core/Keywords.cs | 1 - .../Engines/Factions/Gumps/FinanceGump.cs | 1 - .../Mobiles/Vendors/FactionHorseVendor.cs | 2 +- Projects/UOContent/Engines/Harvest/Fishing.cs | 2 - .../Engines/ML Quests/Items/Teleporters.cs | 2 +- .../UOContent/Engines/Pathing/FastMovement.cs | 11 ++--- .../UOContent/Engines/Pathing/Movement.cs | 8 +--- .../Quests/Collector/Items/ImageTypeInfo.cs | 2 - .../Engines/Spawners/EditSpawnCommand.cs | 2 - .../Engines/Spawners/SpawnPropsGump.cs | 1 - .../Treasures of Tokuno/TreasuresOfTokuno.cs | 2 +- .../Character Statue Maker/CharacterStatue.cs | 2 +- Projects/UOContent/Gumps/AdminGump.cs | 1 - .../UOContent/Gumps/ConfirmHouseResize.cs | 2 +- .../Gumps/Guilds/GuildChangeTypeGump.cs | 1 - .../Guilds/New Guild System/AdvancedSearch.cs | 6 +-- Projects/UOContent/Gumps/ReportMurderer.cs | 8 ++-- .../UOContent/Gumps/VendorInventoryGump.cs | 1 - Projects/UOContent/Items/Addons/BaseAddon.cs | 4 +- .../Items/Addons/BaseAddonContainer.cs | 4 +- .../UOContent/Items/Addons/SHTeleporter.cs | 1 - .../UOContent/Items/Clothing/BaseClothing.cs | 6 +-- .../Items/Construction/Doors/HouseDoors.cs | 1 - .../UOContent/Items/Deeds/HolidayTreeDeed.cs | 1 - .../Minor Artifacts/ML/QuiverOfElements.cs | 4 +- .../Items/Minor Artifacts/ML/QuiverOfRage.cs | 4 +- Projects/UOContent/Items/Misc/LOSBlocker.cs | 2 +- .../UOContent/Items/Quivers/BaseQuiver.cs | 20 +++++--- .../UOContent/Items/Quivers/QuiverOfBlight.cs | 4 +- .../UOContent/Items/Quivers/QuiverOfFire.cs | 4 +- .../UOContent/Items/Quivers/QuiverOfIce.cs | 4 +- .../Items/Quivers/QuiverOfLightning.cs | 4 +- .../Skill Items/Thief/DisguisePersistance.cs | 2 - .../House Raffle/HouseRaffleManagementGump.cs | 1 - .../Mutation Core/PlagueBeastOrgans.cs | 6 +-- Projects/UOContent/Items/Special/SoulStone.cs | 4 +- .../Special Scrolls/ScrollofTranscendence.cs | 1 - .../Items/Special/Veteran Rewards/Cannon.cs | 1 - Projects/UOContent/Items/Wands/WandTarget.cs | 2 - .../UOContent/Items/Weapons/BaseWeapon.cs | 36 +++++++------- Projects/UOContent/Misc/Notoriety.cs | 3 +- Projects/UOContent/Misc/Profile.cs | 1 - .../UOContent/Misc/TreasureMapProtection.cs | 6 +-- .../UOContent/Mobiles/Guards/WarriorGuard.cs | 2 +- Projects/UOContent/Mobiles/Townfolk/Banker.cs | 2 +- .../UOContent/Mobiles/Vendors/BaseVendor.cs | 4 +- .../Mobiles/Vendors/NPC/AnimalTrainer.cs | 2 +- .../Mobiles/Vendors/NPC/KeeperOfChivalry.cs | 2 +- .../UOContent/Mobiles/Vendors/NPC/Vagabond.cs | 2 +- .../Mobiles/Vendors/PlayerBarkeeper.cs | 2 +- .../UOContent/Multis/Houses/ContestHouses.cs | 1 - .../Multis/Houses/HouseFoundation.cs | 3 -- .../UOContent/Multis/Houses/HousePlacement.cs | 4 +- Projects/UOContent/Multis/Houses/HouseSign.cs | 2 +- Projects/UOContent/Network/ConnectUO.cs | 1 - Projects/UOContent/Regions/HouseRegion.cs | 2 +- .../Special Systems/Engines/TestCenter.cs | 4 +- .../UOContent/Spells/Base/SpellRegistry.cs | 2 +- .../UOContent/Spells/Fifth/PoisonField.cs | 47 ++++--------------- Projects/UOContent/Spells/Fourth/FireField.cs | 33 +++---------- .../UOContent/Spells/Necromancy/MindRot.cs | 4 +- .../UOContent/Spells/Seventh/EnergyField.cs | 18 +------ .../UOContent/Spells/Sixth/ParalyzeField.cs | 19 +------- .../Spells/Targeting/SpellTargetPoint3D.cs | 1 - .../UOContent/Spells/Third/WallOfStone.cs | 19 +------- 99 files changed, 160 insertions(+), 346 deletions(-) diff --git a/Projects/SerializationGenerator/SerializableEntityGeneration/SerializableEntityGeneration.Class.cs b/Projects/SerializationGenerator/SerializableEntityGeneration/SerializableEntityGeneration.Class.cs index f312d9330..4a13970bc 100644 --- a/Projects/SerializationGenerator/SerializableEntityGeneration/SerializableEntityGeneration.Class.cs +++ b/Projects/SerializationGenerator/SerializableEntityGeneration/SerializableEntityGeneration.Class.cs @@ -117,6 +117,7 @@ namespace SerializationGenerator StringBuilder source = new StringBuilder(); + source.AppendLine("#pragma warning disable\n"); source.GenerateNamespaceStart(namespaceName); source.GenerateClassStart( @@ -131,8 +132,7 @@ namespace SerializationGenerator InstanceModifier.Const, "int", "_version", - version.ToString(), - true + version.ToString() ); source.AppendLine(); diff --git a/Projects/SerializationGenerator/SerializableMigration/Rules/SerializationMethodSignatureMigrationRule.cs b/Projects/SerializationGenerator/SerializableMigration/Rules/SerializationMethodSignatureMigrationRule.cs index 36ee040cf..91e92baed 100644 --- a/Projects/SerializationGenerator/SerializableMigration/Rules/SerializationMethodSignatureMigrationRule.cs +++ b/Projects/SerializationGenerator/SerializableMigration/Rules/SerializationMethodSignatureMigrationRule.cs @@ -15,7 +15,6 @@ using System; using System.Collections.Immutable; -using System.Linq; using System.Text; using Microsoft.CodeAnalysis; using SerializationGenerator; diff --git a/Projects/SerializationGenerator/SourceGeneration/SourceGeneration.Class.cs b/Projects/SerializationGenerator/SourceGeneration/SourceGeneration.Class.cs index 7068d5faf..50d9d2f99 100644 --- a/Projects/SerializationGenerator/SourceGeneration/SourceGeneration.Class.cs +++ b/Projects/SerializationGenerator/SourceGeneration/SourceGeneration.Class.cs @@ -53,24 +53,13 @@ namespace SerializationGenerator InstanceModifier instance, string type, string variableName, - string value, - bool unusedPragma = false + string value ) { - if (unusedPragma) - { - source.AppendLine("#pragma warning disable 0414"); // assigned, but never used - } - var instanceStr = instance == InstanceModifier.None ? "" : $"{instance.ToFriendlyString()} "; var accessorStr = accessors == Accessibility.NotApplicable ? "" : $"{accessors.ToFriendlyString()} "; var valueStr = value == null ? "" : $" = {value}"; source.AppendLine($" {accessorStr}{instanceStr}{type} {variableName}{valueStr};"); - - if (unusedPragma) - { - source.AppendLine("#pragma warning restore 0414"); - } } } } diff --git a/Projects/SerializationGenerator/SourceGeneration/SymbolMetadata/SymbolMetadata.UO.cs b/Projects/SerializationGenerator/SourceGeneration/SymbolMetadata/SymbolMetadata.UO.cs index 91654cf94..9c439941b 100644 --- a/Projects/SerializationGenerator/SourceGeneration/SymbolMetadata/SymbolMetadata.UO.cs +++ b/Projects/SerializationGenerator/SourceGeneration/SymbolMetadata/SymbolMetadata.UO.cs @@ -13,7 +13,6 @@ * along with this program. If not, see . * *************************************************************************/ -using System; using System.Collections.Immutable; using System.Linq; using Microsoft.CodeAnalysis; diff --git a/Projects/SerializationSchemaGenerator/Application.cs b/Projects/SerializationSchemaGenerator/Application.cs index 02d35aa62..dae7d407f 100644 --- a/Projects/SerializationSchemaGenerator/Application.cs +++ b/Projects/SerializationSchemaGenerator/Application.cs @@ -16,7 +16,6 @@ using System; using System.Collections.Immutable; using System.IO; -using System.Text; using System.Text.Json; using System.Threading.Tasks; using SerializationGenerator; diff --git a/Projects/Server.Tests/Tests/Buffers/CircularBufferWriterTests.cs b/Projects/Server.Tests/Tests/Buffers/CircularBufferWriterTests.cs index 38f627ce8..4ccf19533 100644 --- a/Projects/Server.Tests/Tests/Buffers/CircularBufferWriterTests.cs +++ b/Projects/Server.Tests/Tests/Buffers/CircularBufferWriterTests.cs @@ -1,7 +1,6 @@ using System; using System.Buffers; using System.IO; -using Server.Network; using Xunit; namespace Server.Tests.Buffers diff --git a/Projects/Server/Items/Item.cs b/Projects/Server/Items/Item.cs index 5ad68b15c..cffee465a 100644 --- a/Projects/Server/Items/Item.cs +++ b/Projects/Server/Items/Item.cs @@ -3553,8 +3553,7 @@ namespace Server var landTile = map.Tiles.GetLandTile(x, y); var landFlags = TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags; - int landZ = 0, landAvg = 0, landTop = 0; - map.GetAverageZ(x, y, ref landZ, ref landAvg, ref landTop); + map.GetAverageZ(x, y, out var landZ, out var landAvg, out _); if (!landTile.Ignored && (landFlags & TileFlag.Impassable) == 0) { diff --git a/Projects/Server/Logging/SerilogLogger.cs b/Projects/Server/Logging/SerilogLogger.cs index c4df66f29..6aa9178d9 100644 --- a/Projects/Server/Logging/SerilogLogger.cs +++ b/Projects/Server/Logging/SerilogLogger.cs @@ -14,6 +14,7 @@ *************************************************************************/ using System; +using System.Runtime.CompilerServices; namespace Server.Logging { @@ -24,33 +25,43 @@ namespace Server.Logging public SerilogLogger(Serilog.ILogger serilogLogger) => this.serilogLogger = serilogLogger; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Debug(string message, params object[] args) => serilogLogger.Debug(message, args); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Debug(Exception exception, string message, params object[] args) => serilogLogger.Debug(exception, message, args); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Information(string message, params object[] args) => serilogLogger.Information(message, args); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Information(Exception exception, string message, params object[] args) => serilogLogger.Information(exception, message, args); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Warning(string message, params object[] args) => serilogLogger.Warning(message, args); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Warning(Exception exception, string message, params object[] args) => serilogLogger.Information(exception, message, args); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Error(string message, params object[] args) => serilogLogger.Error(message, args); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Error(Exception exception, string message, params object[] args) => serilogLogger.Error(exception, message, args); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Fatal(string message, params object[] args) => serilogLogger.Fatal(message, args); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Fatal(Exception exception, string message, params object[] args) => serilogLogger.Fatal(exception, message, args); } diff --git a/Projects/Server/Maps/Map.cs b/Projects/Server/Maps/Map.cs index d5f9d38fd..170fe5ec0 100644 --- a/Projects/Server/Maps/Map.cs +++ b/Projects/Server/Maps/Map.cs @@ -435,14 +435,11 @@ namespace Server public int GetAverageZ(int x, int y) { - int z = 0, avg = 0, top = 0; - - GetAverageZ(x, y, ref z, ref avg, ref top); - + GetAverageZ(x, y, out _, out var avg, out _); return avg; } - public void GetAverageZ(int x, int y, ref int z, ref int avg, ref int top) + public void GetAverageZ(int x, int y, out int z, out int avg, out int top) { var zTop = Tiles.GetLandTile(x, y).Z; var zLeft = Tiles.GetLandTile(x, y + 1).Z; @@ -556,8 +553,7 @@ namespace Server var landTile = Tiles.GetLandTile(x, y); var tiles = Tiles.GetStaticTiles(x, y, true); - int landZ = 0, landAvg = 0, landTop = 0; - GetAverageZ(x, y, ref landZ, ref landAvg, ref landTop); + GetAverageZ(x, y, out _, out var landAvg, out _); var items = AcquireFixItems(this, x, y); @@ -1010,8 +1006,7 @@ namespace Server { p = target.Location; - int low = 0, avg = 0, top = 0; - GetAverageZ(p.X, p.Y, ref low, ref avg, ref top); + GetAverageZ(p.X, p.Y, out _, out _, out var top); p.Z = top + 1; } @@ -1108,9 +1103,7 @@ namespace Server var hasSurface = false; var lt = Tiles.GetLandTile(x, y); - int lowZ = 0, avgZ = 0, topZ = 0; - - GetAverageZ(x, y, ref lowZ, ref avgZ, ref topZ); + GetAverageZ(x, y, out var lowZ, out var avgZ, out _); var landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags; if ((landFlags & TileFlag.Impassable) != 0 && avgZ > z && z + height > lowZ) @@ -1327,8 +1320,7 @@ namespace Server var pointTop = point.m_Z + 1; var landTile = Tiles.GetLandTile(point.X, point.Y); - int landZ = 0, landAvg = 0, landTop = 0; - GetAverageZ(point.m_X, point.m_Y, ref landZ, ref landAvg, ref landTop); + GetAverageZ(point.m_X, point.m_Y, out var landZ, out _, out var landTop); if (landZ <= pointTop && landTop >= point.m_Z && (point.m_X != end.m_X || point.m_Y != end.m_Y || landZ > endTop || landTop < end.m_Z) && diff --git a/Projects/Server/NativeReader.cs b/Projects/Server/NativeReader.cs index 026ca99b4..78cbd4fe8 100644 --- a/Projects/Server/NativeReader.cs +++ b/Projects/Server/NativeReader.cs @@ -9,7 +9,7 @@ namespace Server { private static readonly INativeReader m_NativeReader; - static NativeReader() => m_NativeReader = Core.Unix ? (INativeReader)new NativeReaderUnix() : new NativeReaderWin32(); + static NativeReader() => m_NativeReader = Core.Unix ? new NativeReaderUnix() : new NativeReaderWin32(); public static unsafe int Read(FileStream source, void* buffer, int length) => m_NativeReader.Read(source, buffer, length); diff --git a/Projects/Server/Serialization/SerializableAttribute.cs b/Projects/Server/Serialization/SerializableAttribute.cs index e05af4a5e..052d81d11 100755 --- a/Projects/Server/Serialization/SerializableAttribute.cs +++ b/Projects/Server/Serialization/SerializableAttribute.cs @@ -23,6 +23,10 @@ namespace Server public int Version { get; } public bool EncodedVersion { get; } - public SerializableAttribute(int version, bool encodedVersion = true) => Version = version; + public SerializableAttribute(int version, bool encodedVersion = true) + { + Version = version; + EncodedVersion = encodedVersion; + } } } diff --git a/Projects/Server/Targeting/Target.cs b/Projects/Server/Targeting/Target.cs index 02e68c609..d0035ed3b 100644 --- a/Projects/Server/Targeting/Target.cs +++ b/Projects/Server/Targeting/Target.cs @@ -252,9 +252,6 @@ namespace Server.Targeting private class TimeoutTimer : Timer { - private static readonly TimeSpan ThirtySeconds = TimeSpan.FromSeconds(30.0); - private static readonly TimeSpan TenSeconds = TimeSpan.FromSeconds(10.0); - private static readonly TimeSpan OneSecond = TimeSpan.FromSeconds(1.0); private readonly Mobile m_Mobile; private readonly Target m_Target; diff --git a/Projects/UOContent.Tests/Tests/Multis/Houses/HousePackets.cs b/Projects/UOContent.Tests/Tests/Multis/Houses/HousePackets.cs index fe94744d3..75c757ea6 100644 --- a/Projects/UOContent.Tests/Tests/Multis/Houses/HousePackets.cs +++ b/Projects/UOContent.Tests/Tests/Multis/Houses/HousePackets.cs @@ -2,7 +2,6 @@ using System; using System.Buffers; using System.IO; using System.IO.Compression; -using Server.Multis; namespace Server.Network { diff --git a/Projects/UOContent/Commands/Dupe.cs b/Projects/UOContent/Commands/Dupe.cs index f5303453d..db7bfdbde 100644 --- a/Projects/UOContent/Commands/Dupe.cs +++ b/Projects/UOContent/Commands/Dupe.cs @@ -54,6 +54,7 @@ namespace Server.Commands } catch { + // ignored } } } diff --git a/Projects/UOContent/Commands/Generic/Implementors/ObjectConditional.cs b/Projects/UOContent/Commands/Generic/Implementors/ObjectConditional.cs index acf79a09a..bbd64e822 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/ObjectConditional.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/ObjectConditional.cs @@ -21,9 +21,9 @@ namespace Server.Commands.Generic public Type Type { get; } - public bool IsItem => Type == null || Type.IsAssignableTo(OfItem); + public bool IsItem => Type?.IsAssignableTo(OfItem) != false; - public bool IsMobile => Type == null || Type.IsAssignableTo(OfMobile); + public bool IsMobile => Type?.IsAssignableTo(OfMobile) != false; public bool HasCompiled => m_Conditionals != null; diff --git a/Projects/UOContent/Commands/Logging.cs b/Projects/UOContent/Commands/Logging.cs index 2abf6b2cb..a1a5ab3d2 100644 --- a/Projects/UOContent/Commands/Logging.cs +++ b/Projects/UOContent/Commands/Logging.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using System.Text; using Server.Accounting; diff --git a/Projects/UOContent/Commands/Object Creation/CAGObject.cs b/Projects/UOContent/Commands/Object Creation/CAGObject.cs index 6404cdb9d..4b8f19968 100644 --- a/Projects/UOContent/Commands/Object Creation/CAGObject.cs +++ b/Projects/UOContent/Commands/Object Creation/CAGObject.cs @@ -34,7 +34,7 @@ namespace Server.Commands public CAGCategory Parent { get; set; } - public override string Title => Type == null ? "bad type" : Type.Name; + public override string Title => Type?.Name ?? "bad type"; public override void OnClick(Mobile from, int page) { diff --git a/Projects/UOContent/Commands/Object Creation/DecorateMag.cs b/Projects/UOContent/Commands/Object Creation/DecorateMag.cs index 5a2bb58b1..62eeb73c1 100644 --- a/Projects/UOContent/Commands/Object Creation/DecorateMag.cs +++ b/Projects/UOContent/Commands/Object Creation/DecorateMag.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using Server.Engines.Quests.Haven; @@ -73,7 +72,7 @@ namespace Server.Commands private static readonly Type typeofCannon = typeof(Cannon); private static readonly Type typeofSerpentPillar = typeof(SerpentPillar); - private static readonly Queue m_DeleteQueue = new(); + private static readonly Queue m_DeleteQueue = new(); private static readonly string[] m_EmptyParams = Array.Empty(); private List m_Entries; @@ -1143,7 +1142,7 @@ namespace Server.Commands while (m_DeleteQueue.Count > 0) { - ((Item)m_DeleteQueue.Dequeue())?.Delete(); + m_DeleteQueue.Dequeue()?.Delete(); } return res; diff --git a/Projects/UOContent/Commands/ShardTime.cs b/Projects/UOContent/Commands/ShardTime.cs index 8453de7a1..a206d1340 100644 --- a/Projects/UOContent/Commands/ShardTime.cs +++ b/Projects/UOContent/Commands/ShardTime.cs @@ -1,5 +1,4 @@ -using System; -using System.Globalization; +using System.Globalization; namespace Server.Commands { diff --git a/Projects/UOContent/Configuration/EmailConfiguration.cs b/Projects/UOContent/Configuration/EmailConfiguration.cs index 264718a21..8726a5df3 100644 --- a/Projects/UOContent/Configuration/EmailConfiguration.cs +++ b/Projects/UOContent/Configuration/EmailConfiguration.cs @@ -13,7 +13,6 @@ * along with this program. If not, see . * *************************************************************************/ -using System; using System.IO; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/Projects/UOContent/Context Menus/OpenBankEntry.cs b/Projects/UOContent/Context Menus/OpenBankEntry.cs index 66ccb4da7..faf3468f5 100644 --- a/Projects/UOContent/Context Menus/OpenBankEntry.cs +++ b/Projects/UOContent/Context Menus/OpenBankEntry.cs @@ -4,7 +4,7 @@ namespace Server.ContextMenus { private readonly Mobile m_Banker; - public OpenBankEntry(Mobile from, Mobile banker) : base(6105, 12) => m_Banker = banker; + public OpenBankEntry(Mobile banker) : base(6105, 12) => m_Banker = banker; public override void OnClick() { diff --git a/Projects/UOContent/Engines/Bulk Orders/BulkMaterialType.cs b/Projects/UOContent/Engines/Bulk Orders/BulkMaterialType.cs index fd5e0196c..43a8a0e57 100644 --- a/Projects/UOContent/Engines/Bulk Orders/BulkMaterialType.cs +++ b/Projects/UOContent/Engines/Bulk Orders/BulkMaterialType.cs @@ -35,7 +35,7 @@ namespace Server.Engines.BulkOrders return BulkGenericType.Iron; } - return itemType == null || itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes)) + return itemType?.IsSubclassOf(typeof(BaseArmor)) != false || itemType.IsSubclassOf(typeof(BaseShoes)) ? BulkGenericType.Leather : BulkGenericType.Cloth; } diff --git a/Projects/UOContent/Engines/CannedEvil/DungeonChampionSpawn.cs b/Projects/UOContent/Engines/CannedEvil/DungeonChampionSpawn.cs index 20402cde1..c4eedc84b 100644 --- a/Projects/UOContent/Engines/CannedEvil/DungeonChampionSpawn.cs +++ b/Projects/UOContent/Engines/CannedEvil/DungeonChampionSpawn.cs @@ -18,7 +18,7 @@ namespace Server.Engines.CannedEvil public class DungeonChampionSpawn : ChampionSpawn { [Constructible] - public DungeonChampionSpawn() : base() + public DungeonChampionSpawn() { CannedEvilTimer.AddSpawn(this); } diff --git a/Projects/UOContent/Engines/ConPVP/Arena.cs b/Projects/UOContent/Engines/ConPVP/Arena.cs index bb8f56843..c22cffc22 100644 --- a/Projects/UOContent/Engines/ConPVP/Arena.cs +++ b/Projects/UOContent/Engines/ConPVP/Arena.cs @@ -772,11 +772,7 @@ namespace Server.Engines.ConPVP { var pe = prefs.Find(players[j]); - if (pe.Disliked.Contains(ae.m_Arena.Name)) - { - ++ae.m_VotesAgainst; - } - else + if (!pe.Disliked.Contains(ae.m_Arena.Name)) { ++ae.m_VotesFor; } @@ -827,7 +823,6 @@ namespace Server.Engines.ConPVP private class ArenaEntry { public readonly Arena m_Arena; - public int m_VotesAgainst; public int m_VotesFor; public ArenaEntry(Arena arena) => m_Arena = arena; diff --git a/Projects/UOContent/Engines/ConPVP/DuelContext.cs b/Projects/UOContent/Engines/ConPVP/DuelContext.cs index 6f40bfce3..27f72d4a6 100644 --- a/Projects/UOContent/Engines/ConPVP/DuelContext.cs +++ b/Projects/UOContent/Engines/ConPVP/DuelContext.cs @@ -1924,24 +1924,7 @@ namespace Server.Engines.ConPVP var rx = dx - dy; var ry = dx + dy; - bool eastToWest; - - if (rx >= 0 && ry >= 0) - { - eastToWest = false; - } - else if (rx >= 0) - { - eastToWest = true; - } - else if (ry >= 0) - { - eastToWest = true; - } - else - { - eastToWest = false; - } + bool eastToWest = rx == 0 && ry >= 0 || rx >= 0 && ry == 0; Effects.PlaySound(wall, Arena.Facet, 0x1F6); diff --git a/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs b/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs index 8adcfea1f..05a22aee0 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs @@ -456,8 +456,7 @@ namespace Server.Engines.ConPVP var point = m_Path[i]; var landTile = Map.Tiles.GetLandTile(point.X, point.Y); - int landZ = 0, landAvg = 0, landTop = 0; - Map.GetAverageZ(point.X, point.Y, ref landZ, ref landAvg, ref landTop); + Map.GetAverageZ(point.X, point.Y, out var landZ, out _, out var landTop); if (landZ <= point.Z && landTop >= point.Z && !landTile.Ignored) { diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs index 5e7dfcddc..8da52acff 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs @@ -23,7 +23,6 @@ namespace Server.Engines.ConPVP public class TournamentBracketGump : Gump { private const int BlackColor32 = 0x000008; - private const int LabelColor32 = 0xFFFFFF; private readonly Mobile m_From; private List m_List; private readonly object m_Object; diff --git a/Projects/UOContent/Engines/ConPVP/TournamentController.cs b/Projects/UOContent/Engines/ConPVP/TournamentController.cs index 545b776f3..91a1a0544 100644 --- a/Projects/UOContent/Engines/ConPVP/TournamentController.cs +++ b/Projects/UOContent/Engines/ConPVP/TournamentController.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using Server.ContextMenus; using Server.Gumps; diff --git a/Projects/UOContent/Engines/Craft/Core/CraftGumpItem.cs b/Projects/UOContent/Engines/Craft/Core/CraftGumpItem.cs index ebf4bdaf6..ec0a307e5 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftGumpItem.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftGumpItem.cs @@ -143,9 +143,9 @@ namespace Server.Engines.Craft { return expansion switch { - Expansion.SE => (TextDefinition)1063363, // * Requires the "Samurai Empire" expansion - Expansion.ML => (TextDefinition)1072651, // * Requires the "Mondain's Legacy" expansion - _ => (TextDefinition)$"* Requires the \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion" + Expansion.SE => 1063363, // * Requires the "Samurai Empire" expansion + Expansion.ML => 1072651, // * Requires the "Mondain's Legacy" expansion + _ => $"* Requires the \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion" }; } diff --git a/Projects/UOContent/Engines/Craft/Core/CraftItem.cs b/Projects/UOContent/Engines/Craft/Core/CraftItem.cs index b5c2ecda8..f108acaa8 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftItem.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftItem.cs @@ -876,7 +876,7 @@ namespace Server.Engines.Craft } public bool CheckSkills( - Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality, ref bool allRequiredSkills + Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality, out bool allRequiredSkills ) => CheckSkills(from, typeRes, craftSystem, ref quality, out allRequiredSkills, true); @@ -1132,9 +1132,7 @@ namespace Server.Engines.Craft var ignored = 1; var endquality = 1; - var allRequiredSkills = true; - - if (CheckSkills(from, typeRes, craftSystem, ref ignored, ref allRequiredSkills)) + if (CheckSkills(from, typeRes, craftSystem, ref ignored, out var allRequiredSkills)) { // Resource var resHue = 0; diff --git a/Projects/UOContent/Engines/Craft/DefCarpentry.cs b/Projects/UOContent/Engines/Craft/DefCarpentry.cs index 69445dfb4..62044ee88 100644 --- a/Projects/UOContent/Engines/Craft/DefCarpentry.cs +++ b/Projects/UOContent/Engines/Craft/DefCarpentry.cs @@ -84,7 +84,7 @@ namespace Server.Engines.Craft public override void InitCraftList() { - var index = -1; + int index; // Other Items if (Core.Expansion == Expansion.AOS || Core.Expansion == Expansion.SE) diff --git a/Projects/UOContent/Engines/Doom/GauntletSpawner.cs b/Projects/UOContent/Engines/Doom/GauntletSpawner.cs index 9a922bb90..5ccec19dd 100644 --- a/Projects/UOContent/Engines/Doom/GauntletSpawner.cs +++ b/Projects/UOContent/Engines/Doom/GauntletSpawner.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using Server.Items; -using Server.Mobiles; -using Server.Regions; using Server.Utilities; namespace Server.Engines.Doom diff --git a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs index fb16c2c5d..32745c925 100644 --- a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs +++ b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs @@ -123,7 +123,7 @@ namespace Server.Engines.Doom m_Tiles = new List(); for (; i < 9; i++) { - m_Tiles.Add(new LeverPuzzleRegion(this, TA[i])); + m_Tiles.Add(new LeverPuzzleRegion(TA[i])); } m_Teles = new List(); @@ -400,7 +400,7 @@ namespace Server.Engines.Doom { if ((player = GetOccupant(i)) != null) { - new RockTimer(player, this).Start(); + new RockTimer(player).Start(); } } } @@ -570,7 +570,7 @@ namespace Server.Engines.Doom m_Tiles = new List(); for (var i = 4; i < 9; i++) { - m_Tiles.Add(new LeverPuzzleRegion(this, TA[i])); + m_Tiles.Add(new LeverPuzzleRegion(TA[i])); } m_LampRoom = new LampRoomRegion(this); @@ -584,14 +584,12 @@ namespace Server.Engines.Doom { private readonly Mobile m_Player; private int Count; - private LeverPuzzleController m_Controller; - public RockTimer(Mobile player, LeverPuzzleController controller) + public RockTimer(Mobile player) : base(TimeSpan.Zero, TimeSpan.FromSeconds(.25)) { Count = 0; m_Player = player; - m_Controller = controller; } private int Rock() => 0x1363 + Utility.Random(0, 11); diff --git a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs index 3e1077f6d..781cf752d 100644 --- a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs +++ b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs @@ -88,7 +88,7 @@ namespace Server.Engines.Doom { public Mobile m_Occupant; - public LeverPuzzleRegion(LeverPuzzleController controller, int[] loc) + public LeverPuzzleRegion(int[] loc) : base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), new Rectangle2D(loc[0], loc[1], 1, 1)) { Register(); diff --git a/Projects/UOContent/Engines/Factions/Core/Keywords.cs b/Projects/UOContent/Engines/Factions/Core/Keywords.cs index 4af72108f..c73ed31a3 100644 --- a/Projects/UOContent/Engines/Factions/Core/Keywords.cs +++ b/Projects/UOContent/Engines/Factions/Core/Keywords.cs @@ -1,4 +1,3 @@ -using System; using Server.Mobiles; using Server.Network; diff --git a/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs b/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs index 6fe8e204d..81437f5b7 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs @@ -1,4 +1,3 @@ -using System; using Server.Gumps; using Server.Mobiles; using Server.Multis; diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs index 5bd425428..0d1dc6b89 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs @@ -30,7 +30,7 @@ namespace Server.Factions { base.InitOutfit(); - AddItem(Utility.RandomBool() ? new QuarterStaff() : (Item)new ShepherdsCrook()); + AddItem(Utility.RandomBool() ? new QuarterStaff() : new ShepherdsCrook()); } public override void VendorBuy(Mobile from) diff --git a/Projects/UOContent/Engines/Harvest/Fishing.cs b/Projects/UOContent/Engines/Harvest/Fishing.cs index 6eb65a55e..a663100d6 100644 --- a/Projects/UOContent/Engines/Harvest/Fishing.cs +++ b/Projects/UOContent/Engines/Harvest/Fishing.cs @@ -168,8 +168,6 @@ namespace Server.Engines.Harvest return type; } - private static Map SafeMap(Map map) => map == null || map == Map.Internal ? Map.Trammel : map; - public override bool CheckResources(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed) { return from?.Backpack?.FindItemsByType() diff --git a/Projects/UOContent/Engines/ML Quests/Items/Teleporters.cs b/Projects/UOContent/Engines/ML Quests/Items/Teleporters.cs index c4bc27740..a1dd82869 100644 --- a/Projects/UOContent/Engines/ML Quests/Items/Teleporters.cs +++ b/Projects/UOContent/Engines/ML Quests/Items/Teleporters.cs @@ -87,7 +87,7 @@ namespace Server.Engines.MLQuests.Items writer.Write(0); // version - writer.Write(m_QuestType != null ? m_QuestType.FullName : null); + writer.Write(m_QuestType?.FullName); TextDefinition.Serialize(writer, Message); } diff --git a/Projects/UOContent/Engines/Pathing/FastMovement.cs b/Projects/UOContent/Engines/Pathing/FastMovement.cs index d753f1941..364bc924a 100644 --- a/Projects/UOContent/Engines/Pathing/FastMovement.cs +++ b/Projects/UOContent/Engines/Pathing/FastMovement.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using Server.Items; @@ -212,8 +211,8 @@ namespace Server.Movement var tiles = map.Tiles.GetStaticTiles(x, y, true); var landTile = map.Tiles.GetLandTile(x, y); var landData = TileData.LandTable[landTile.ID & TileData.MaxLandValue]; - var landBlocks = (landData.Flags & TileFlag.Impassable) != 0; var considerLand = !landTile.Ignored; + var landBlocks = (landData.Flags & TileFlag.Impassable) != 0; if (landBlocks && canSwim && (landData.Flags & TileFlag.Wet) != 0) { @@ -224,9 +223,7 @@ namespace Server.Movement landBlocks = true; } - int landZ = 0, landCenter = 0, landTop = 0; - - map.GetAverageZ(x, y, ref landZ, ref landCenter, ref landTop); + map.GetAverageZ(x, y, out var landZ, out var landCenter, out _); var moveIsOk = false; @@ -490,9 +487,7 @@ namespace Server.Movement landBlocks = true; } - int landZ = 0, landCenter = 0, landTop = 0; - - map.GetAverageZ(xCheck, yCheck, ref landZ, ref landCenter, ref landTop); + map.GetAverageZ(xCheck, yCheck, out var landZ, out var landCenter, out var landTop); var considerLand = !landTile.Ignored; diff --git a/Projects/UOContent/Engines/Pathing/Movement.cs b/Projects/UOContent/Engines/Pathing/Movement.cs index 6fda9fc22..b7a8ff1c0 100644 --- a/Projects/UOContent/Engines/Pathing/Movement.cs +++ b/Projects/UOContent/Engines/Pathing/Movement.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using Server.Items; using Server.Mobiles; @@ -429,9 +428,7 @@ namespace Server.Movement var considerLand = !landTile.Ignored; - int landZ = 0, landCenter = 0, landTop = 0; - - map.GetAverageZ(x, y, ref landZ, ref landCenter, ref landTop); + map.GetAverageZ(x, y, out var landZ, out var landCenter, out _); var moveIsOk = false; @@ -630,14 +627,13 @@ namespace Server.Movement int xCheck = loc.X, yCheck = loc.Y; var landTile = map.Tiles.GetLandTile(xCheck, yCheck); - int landZ = 0, landCenter = 0, landTop = 0; var flags = TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags; var impassable = (flags & TileFlag.Impassable) != 0; // Impassable + swim on water is ok, otherwise block if cannot walk or impassable var landBlocks = (m.CantWalk || impassable) && !(impassable && m.CanSwim && (flags & TileFlag.Wet) != 0); - map.GetAverageZ(xCheck, yCheck, ref landZ, ref landCenter, ref landTop); + map.GetAverageZ(xCheck, yCheck, out var landZ, out var landCenter, out var landTop); var considerLand = !landTile.Ignored; diff --git a/Projects/UOContent/Engines/Quests/Collector/Items/ImageTypeInfo.cs b/Projects/UOContent/Engines/Quests/Collector/Items/ImageTypeInfo.cs index 4ad0d7000..e521abddc 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Items/ImageTypeInfo.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Items/ImageTypeInfo.cs @@ -63,8 +63,6 @@ namespace Server.Engines.Quests.Collector Y = y; } - public ImageType Image { get; } - public int Figurine { get; } public Type Type { get; } diff --git a/Projects/UOContent/Engines/Spawners/EditSpawnCommand.cs b/Projects/UOContent/Engines/Spawners/EditSpawnCommand.cs index 99c6c7da0..df36003dc 100644 --- a/Projects/UOContent/Engines/Spawners/EditSpawnCommand.cs +++ b/Projects/UOContent/Engines/Spawners/EditSpawnCommand.cs @@ -16,8 +16,6 @@ using System; using System.Collections.Generic; using Server.Commands.Generic; -using Server.Network; - using static Server.Types; namespace Server.Engines.Spawners diff --git a/Projects/UOContent/Engines/Spawners/SpawnPropsGump.cs b/Projects/UOContent/Engines/Spawners/SpawnPropsGump.cs index 94a089e95..2b1583603 100644 --- a/Projects/UOContent/Engines/Spawners/SpawnPropsGump.cs +++ b/Projects/UOContent/Engines/Spawners/SpawnPropsGump.cs @@ -14,7 +14,6 @@ *************************************************************************/ using System.Collections.Generic; -using System.Reflection; using Server.Buffers; using Server.Commands.Generic; using Server.Engines.Spawners; diff --git a/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs b/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs index 65b6efec3..b21626fbc 100644 --- a/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs +++ b/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs @@ -331,7 +331,7 @@ namespace Server.Gumps public ItemTileButtonInfo(Item i) : base( i.ItemID, i.Hue, - i.Name == null || i.Name.Length <= 0 ? (TextDefinition)i.LabelNumber : (TextDefinition)i.Name + i.Name == null || i.Name.Length <= 0 ? i.LabelNumber : i.Name ) => Item = i; diff --git a/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs b/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs index d07e5d05e..f05fd9666 100644 --- a/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs +++ b/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs @@ -683,7 +683,7 @@ namespace Server.Mobiles return AddonFitResult.Blocked; } - if (!BaseAddon.CheckHouse(from, p, map, 20, ref house)) + if (!BaseAddon.CheckHouse(from, p, map, 20, out house)) { return AddonFitResult.NotInHouse; } diff --git a/Projects/UOContent/Gumps/AdminGump.cs b/Projects/UOContent/Gumps/AdminGump.cs index 50bbd70a2..794e1e5db 100644 --- a/Projects/UOContent/Gumps/AdminGump.cs +++ b/Projects/UOContent/Gumps/AdminGump.cs @@ -6,7 +6,6 @@ using System.Threading; using Server.Accounting; using Server.Buffers; using Server.Commands; -using Server.Items; using Server.Misc; using Server.Multis; using Server.Network; diff --git a/Projects/UOContent/Gumps/ConfirmHouseResize.cs b/Projects/UOContent/Gumps/ConfirmHouseResize.cs index 168f9ef6d..caf8f78f0 100644 --- a/Projects/UOContent/Gumps/ConfirmHouseResize.cs +++ b/Projects/UOContent/Gumps/ConfirmHouseResize.cs @@ -104,7 +104,7 @@ namespace Server.Gumps } else { - Item toGive = null; + Item toGive; if (m_House.IsAosRules) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs b/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs index edd1b4569..0867310be 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs @@ -1,4 +1,3 @@ -using System; using Server.Factions; using Server.Guilds; using Server.Mobiles; diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/AdvancedSearch.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/AdvancedSearch.cs index 96a1ed51d..dfbfea16e 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/AdvancedSearch.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/AdvancedSearch.cs @@ -56,20 +56,18 @@ namespace Server.Guilds { base.OnResponse(sender, info); - if (!(sender.Mobile is PlayerMobile pm) || !IsMember(pm, guild)) + if (sender.Mobile is not PlayerMobile pm || !IsMember(pm, guild)) { return; } - var display = m_Display; - if (info.ButtonID == 5) { for (var i = 0; i < 3; i++) { if (info.IsSwitched(i)) { - display = (GuildDisplayType)i; + var display = (GuildDisplayType)i; m_Callback(display); break; } diff --git a/Projects/UOContent/Gumps/ReportMurderer.cs b/Projects/UOContent/Gumps/ReportMurderer.cs index a17709e91..35fb28781 100644 --- a/Projects/UOContent/Gumps/ReportMurderer.cs +++ b/Projects/UOContent/Gumps/ReportMurderer.cs @@ -11,12 +11,10 @@ namespace Server.Gumps { private readonly List m_Killers; private int m_Idx; - private Mobile m_Victum; - private ReportMurdererGump(Mobile victum, List killers, int idx = 0) : base(0, 0) + private ReportMurdererGump(List killers, int idx = 0) : base(0, 0) { m_Killers = killers; - m_Victum = victum; m_Idx = idx; BuildGump(); } @@ -178,7 +176,7 @@ namespace Server.Gumps m_Idx++; if (m_Idx < m_Killers.Count) { - from.SendGump(new ReportMurdererGump(from, m_Killers, m_Idx)); + from.SendGump(new ReportMurdererGump( m_Killers, m_Idx)); } } @@ -195,7 +193,7 @@ namespace Server.Gumps protected override void OnTick() { - m_Victim.SendGump(new ReportMurdererGump(m_Victim, m_Killers)); + m_Victim.SendGump(new ReportMurdererGump(m_Killers)); } } } diff --git a/Projects/UOContent/Gumps/VendorInventoryGump.cs b/Projects/UOContent/Gumps/VendorInventoryGump.cs index f68ad16ba..6daf9e0fc 100644 --- a/Projects/UOContent/Gumps/VendorInventoryGump.cs +++ b/Projects/UOContent/Gumps/VendorInventoryGump.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using Server.Mobiles; diff --git a/Projects/UOContent/Items/Addons/BaseAddon.cs b/Projects/UOContent/Items/Addons/BaseAddon.cs index 2f70e0712..2176d86ac 100644 --- a/Projects/UOContent/Items/Addons/BaseAddon.cs +++ b/Projects/UOContent/Items/Addons/BaseAddon.cs @@ -161,7 +161,7 @@ namespace Server.Items return AddonFitResult.Blocked; } - if (!CheckHouse(from, p3D, map, c.ItemData.Height, ref house)) + if (!CheckHouse(from, p3D, map, c.ItemData.Height, out house)) { return AddonFitResult.NotInHouse; } @@ -203,7 +203,7 @@ namespace Server.Items return AddonFitResult.Valid; } - public static bool CheckHouse(Mobile from, Point3D p, Map map, int height, ref BaseHouse house) + public static bool CheckHouse(Mobile from, Point3D p, Map map, int height, out BaseHouse house) { house = BaseHouse.FindHouseAt(p, map, height); diff --git a/Projects/UOContent/Items/Addons/BaseAddonContainer.cs b/Projects/UOContent/Items/Addons/BaseAddonContainer.cs index f0a2385b4..6c49d6d9a 100644 --- a/Projects/UOContent/Items/Addons/BaseAddonContainer.cs +++ b/Projects/UOContent/Items/Addons/BaseAddonContainer.cs @@ -246,7 +246,7 @@ namespace Server.Items return AddonFitResult.Blocked; } - if (!BaseAddon.CheckHouse(from, p3D, map, c.ItemData.Height, ref house)) + if (!BaseAddon.CheckHouse(from, p3D, map, c.ItemData.Height, out house)) { return AddonFitResult.NotInHouse; } @@ -269,7 +269,7 @@ namespace Server.Items return AddonFitResult.Blocked; } - if (!BaseAddon.CheckHouse(from, p3, map, ItemData.Height, ref house)) + if (!BaseAddon.CheckHouse(from, p3, map, ItemData.Height, out house)) { return AddonFitResult.NotInHouse; } diff --git a/Projects/UOContent/Items/Addons/SHTeleporter.cs b/Projects/UOContent/Items/Addons/SHTeleporter.cs index 87207e780..726069b63 100644 --- a/Projects/UOContent/Items/Addons/SHTeleporter.cs +++ b/Projects/UOContent/Items/Addons/SHTeleporter.cs @@ -1,4 +1,3 @@ -using System; using System.Linq; using Server.Mobiles; diff --git a/Projects/UOContent/Items/Clothing/BaseClothing.cs b/Projects/UOContent/Items/Clothing/BaseClothing.cs index 68e450104..5939cd356 100644 --- a/Projects/UOContent/Items/Clothing/BaseClothing.cs +++ b/Projects/UOContent/Items/Clothing/BaseClothing.cs @@ -769,7 +769,7 @@ namespace Server.Items list.Add(1060436, prop.ToString()); // luck ~1_val~ } - if ((prop = ClothingAttributes.MageArmor) != 0) + if (ClothingAttributes.MageArmor != 0) { list.Add(1060437); // mage armor } @@ -784,7 +784,7 @@ namespace Server.Items list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ } - if ((prop = Attributes.NightSight) != 0) + if (Attributes.NightSight != 0) { list.Add(1060441); // night sight } @@ -809,7 +809,7 @@ namespace Server.Items list.Add(1060450, prop.ToString()); // self repair ~1_val~ } - if ((prop = Attributes.SpellChanneling) != 0) + if (Attributes.SpellChanneling != 0) { list.Add(1060482); // spell channeling } diff --git a/Projects/UOContent/Items/Construction/Doors/HouseDoors.cs b/Projects/UOContent/Items/Construction/Doors/HouseDoors.cs index 88bbfed4a..43a46e7ce 100644 --- a/Projects/UOContent/Items/Construction/Doors/HouseDoors.cs +++ b/Projects/UOContent/Items/Construction/Doors/HouseDoors.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using Server.ContextMenus; using Server.Gumps; diff --git a/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs b/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs index 28d35544e..ea3fec3b1 100644 --- a/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs +++ b/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs @@ -1,4 +1,3 @@ -using System; using Server.Gumps; using Server.Multis; using Server.Network; diff --git a/Projects/UOContent/Items/Minor Artifacts/ML/QuiverOfElements.cs b/Projects/UOContent/Items/Minor Artifacts/ML/QuiverOfElements.cs index abc834acc..cd72fa5f6 100644 --- a/Projects/UOContent/Items/Minor Artifacts/ML/QuiverOfElements.cs +++ b/Projects/UOContent/Items/Minor Artifacts/ML/QuiverOfElements.cs @@ -16,8 +16,8 @@ namespace Server.Items public override int LabelNumber => 1075040; // Quiver of the Elements public override void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct + out int phys, out int fire, out int cold, out int pois, out int nrgy, + out int chaos, out int direct ) { phys = fire = cold = pois = nrgy = direct = 0; diff --git a/Projects/UOContent/Items/Minor Artifacts/ML/QuiverOfRage.cs b/Projects/UOContent/Items/Minor Artifacts/ML/QuiverOfRage.cs index 1e654961c..c0abb2706 100644 --- a/Projects/UOContent/Items/Minor Artifacts/ML/QuiverOfRage.cs +++ b/Projects/UOContent/Items/Minor Artifacts/ML/QuiverOfRage.cs @@ -18,8 +18,8 @@ namespace Server.Items public override int LabelNumber => 1075038; // Quiver of Rage public override void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct + out int phys, out int fire, out int cold, out int pois, out int nrgy, + out int chaos, out int direct ) { chaos = direct = 0; diff --git a/Projects/UOContent/Items/Misc/LOSBlocker.cs b/Projects/UOContent/Items/Misc/LOSBlocker.cs index 2fff4a0bb..8a4afd4ae 100644 --- a/Projects/UOContent/Items/Misc/LOSBlocker.cs +++ b/Projects/UOContent/Items/Misc/LOSBlocker.cs @@ -50,7 +50,7 @@ namespace Server.Items else { length = OutgoingItemPackets.CreateWorldItem(buffer, this); - BinaryPrimitives.WriteUInt16BigEndian(buffer[7..2], GMItemId); + BinaryPrimitives.WriteUInt16BigEndian(buffer[7..9], GMItemId); } ns.Send(buffer[..length]); diff --git a/Projects/UOContent/Items/Quivers/BaseQuiver.cs b/Projects/UOContent/Items/Quivers/BaseQuiver.cs index d0091e733..8ce5c8fc5 100644 --- a/Projects/UOContent/Items/Quivers/BaseQuiver.cs +++ b/Projects/UOContent/Items/Quivers/BaseQuiver.cs @@ -265,10 +265,15 @@ namespace Server.Items list.Add(1074762, prop.ToString()); // Damage modifier: ~1_PERCENT~% } - int phys, fire, cold, pois, nrgy, chaos, direct; - phys = fire = cold = pois = nrgy = chaos = direct = 0; - - AlterBowDamage(ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct); + AlterBowDamage( + out var phys, + out var fire, + out var cold, + out var pois, + out var nrgy, + out var chaos, + out var direct + ); if (phys != 0) { @@ -372,7 +377,7 @@ namespace Server.Items list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ } - if ((prop = Attributes.NightSight) != 0) + if (Attributes.NightSight != 0) { list.Add(1060441); // night sight } @@ -547,10 +552,11 @@ namespace Server.Items } public virtual void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct + out int phys, out int fire, out int cold, out int pois, out int nrgy, + out int chaos, out int direct ) { + phys = fire = cold = pois = nrgy = chaos = direct = 0; } public void InvalidateWeight() diff --git a/Projects/UOContent/Items/Quivers/QuiverOfBlight.cs b/Projects/UOContent/Items/Quivers/QuiverOfBlight.cs index c0ed1bd11..6378d52fb 100644 --- a/Projects/UOContent/Items/Quivers/QuiverOfBlight.cs +++ b/Projects/UOContent/Items/Quivers/QuiverOfBlight.cs @@ -12,8 +12,8 @@ namespace Server.Items public override int LabelNumber => 1073111; // Quiver of Blight public override void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct + out int phys, out int fire, out int cold, out int pois, out int nrgy, + out int chaos, out int direct ) { phys = fire = nrgy = chaos = direct = 0; diff --git a/Projects/UOContent/Items/Quivers/QuiverOfFire.cs b/Projects/UOContent/Items/Quivers/QuiverOfFire.cs index 8caf6aa2a..135d89434 100644 --- a/Projects/UOContent/Items/Quivers/QuiverOfFire.cs +++ b/Projects/UOContent/Items/Quivers/QuiverOfFire.cs @@ -12,8 +12,8 @@ namespace Server.Items public override int LabelNumber => 1073109; // quiver of fire public override void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct + out int phys, out int fire, out int cold, out int pois, out int nrgy, + out int chaos, out int direct ) { cold = pois = nrgy = chaos = direct = 0; diff --git a/Projects/UOContent/Items/Quivers/QuiverOfIce.cs b/Projects/UOContent/Items/Quivers/QuiverOfIce.cs index 281519a7a..faf35ff1c 100644 --- a/Projects/UOContent/Items/Quivers/QuiverOfIce.cs +++ b/Projects/UOContent/Items/Quivers/QuiverOfIce.cs @@ -12,8 +12,8 @@ namespace Server.Items public override int LabelNumber => 1073110; // quiver of ice public override void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct + out int phys, out int fire, out int cold, out int pois, out int nrgy, + out int chaos, out int direct ) { fire = pois = nrgy = chaos = direct = 0; diff --git a/Projects/UOContent/Items/Quivers/QuiverOfLightning.cs b/Projects/UOContent/Items/Quivers/QuiverOfLightning.cs index d00563ab0..ced6fcfea 100644 --- a/Projects/UOContent/Items/Quivers/QuiverOfLightning.cs +++ b/Projects/UOContent/Items/Quivers/QuiverOfLightning.cs @@ -12,8 +12,8 @@ namespace Server.Items public override int LabelNumber => 1073112; // Quiver of Lightning public override void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct + out int phys, out int fire, out int cold, out int pois, out int nrgy, + out int chaos, out int direct ) { fire = cold = pois = chaos = direct = 0; diff --git a/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs b/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs index c3dce8530..e7ce82c96 100644 --- a/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs +++ b/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs @@ -1,5 +1,3 @@ -using System; - namespace Server.Items { public class DisguisePersistance : Item diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs index ef78fa154..c8af3b143 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs @@ -160,7 +160,6 @@ namespace Server.Gumps x += 150; AddHtml(x, 140 + idx * 20, 60, 20, Color(Center("1"), color)); - x += 60; } } diff --git a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastOrgans.cs b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastOrgans.cs index e4f0bb8eb..1ad40358a 100644 --- a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastOrgans.cs +++ b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastOrgans.cs @@ -350,8 +350,6 @@ namespace Server.Items { private Item m_Gland; - private Timer m_Timer; - public PlagueBeastBackupOrgan() : base(0x1362, 0x6) { } @@ -407,7 +405,7 @@ namespace Server.Items if (to.Hue == 0x1 && m_Gland == null && item is PlagueBeastGland) { m_Gland = item; - m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(3), FinishHealing); + Timer.DelayCall(TimeSpan.FromSeconds(3), FinishHealing); from.SendAsciiMessage(0x3B2, "* You place the healthy gland inside the organ sac *"); item.Movable = false; @@ -437,7 +435,7 @@ namespace Server.Items Components[i].Hue = 0x6; } - m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(2), OpenOrgan); + Timer.DelayCall(TimeSpan.FromSeconds(2), OpenOrgan); } public void OpenOrgan() diff --git a/Projects/UOContent/Items/Special/SoulStone.cs b/Projects/UOContent/Items/Special/SoulStone.cs index 990b01a04..7bba3a90a 100644 --- a/Projects/UOContent/Items/Special/SoulStone.cs +++ b/Projects/UOContent/Items/Special/SoulStone.cs @@ -550,7 +550,7 @@ namespace Server.Items Effects.PlaySound(from.Location, from.Map, 0x243); Effects.SendMovingParticles( - new Entity(Server.Serial.Zero, new Point3D(from.X - 6, from.Y - 6, from.Z + 15), from.Map), + new Entity(Serial.Zero, new Point3D(from.X - 6, from.Y - 6, from.Z + 15), from.Map), from, 0x36D4, 7, @@ -797,7 +797,7 @@ namespace Server.Items Effects.PlaySound(from.Location, from.Map, 0x243); Effects.SendMovingParticles( - new Entity(Server.Serial.Zero, new Point3D(from.X - 6, from.Y - 6, from.Z + 15), from.Map), + new Entity(Serial.Zero, new Point3D(from.X - 6, from.Y - 6, from.Z + 15), from.Map), from, 0x36D4, 7, diff --git a/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs b/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs index d2a23aca3..80f44cc3e 100644 --- a/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs +++ b/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs @@ -1,4 +1,3 @@ -using System; using Server.Engines.MLQuests; using Server.Engines.MLQuests.Objectives; using Server.Mobiles; diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs b/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs index e8835985b..37246e4f6 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs @@ -1,4 +1,3 @@ -using System; using Server.Engines.Quests.Haven; using Server.Engines.VeteranRewards; using Server.Gumps; diff --git a/Projects/UOContent/Items/Wands/WandTarget.cs b/Projects/UOContent/Items/Wands/WandTarget.cs index fd15bc638..de78937c5 100644 --- a/Projects/UOContent/Items/Wands/WandTarget.cs +++ b/Projects/UOContent/Items/Wands/WandTarget.cs @@ -8,8 +8,6 @@ namespace Server.Targeting public WandTarget(BaseWand item) : base(6, false, TargetFlags.None) => m_Item = item; - private static int GetOffset(Mobile caster) => 5 + (int)(caster.Skills.Magery.Value * 0.02); - protected override void OnTarget(Mobile from, object targeted) { m_Item.DoWandTarget(from, targeted); diff --git a/Projects/UOContent/Items/Weapons/BaseWeapon.cs b/Projects/UOContent/Items/Weapons/BaseWeapon.cs index 212eb555b..82d1b3a9d 100644 --- a/Projects/UOContent/Items/Weapons/BaseWeapon.cs +++ b/Projects/UOContent/Items/Weapons/BaseWeapon.cs @@ -1847,24 +1847,24 @@ namespace Server.Items } AddBlood(attacker, defender, damage); + int phys, fire, cold, pois, nrgy, chaos, direct; - GetDamageTypes( - attacker, - out var phys, - out var fire, - out var cold, - out var pois, - out var nrgy, - out var chaos, - out var direct - ); - - if (Core.ML && this is BaseRanged) + if (Core.ML && this is BaseRanged && attacker.FindItemOnLayer(Layer.Cloak) is BaseQuiver quiver) { - if (attacker.FindItemOnLayer(Layer.Cloak) is BaseQuiver quiver) - { - quiver.AlterBowDamage(ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct); - } + quiver.AlterBowDamage(out phys, out fire, out cold, out pois, out nrgy, out chaos, out direct); + } + else + { + GetDamageTypes( + attacker, + out phys, + out fire, + out cold, + out pois, + out nrgy, + out chaos, + out direct + ); } if (Consecrated) @@ -1930,8 +1930,6 @@ namespace Server.Items ImmolatingWeaponSpell.DoEffect(this, defender); } - var damageGiven = damage; - if (a?.OnBeforeDamage(attacker, defender) == false) { WeaponAbility.ClearCurrentAbility(attacker); @@ -1946,7 +1944,7 @@ namespace Server.Items var ignoreArmor = a is ArmorIgnore || move?.IgnoreArmor(attacker) == true; - damageGiven = AOS.Damage( + var damageGiven = AOS.Damage( defender, attacker, damage, diff --git a/Projects/UOContent/Misc/Notoriety.cs b/Projects/UOContent/Misc/Notoriety.cs index 96dce3691..33e2a8169 100644 --- a/Projects/UOContent/Misc/Notoriety.cs +++ b/Projects/UOContent/Misc/Notoriety.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using Server.Engines.ConPVP; using Server.Engines.PartySystem; @@ -258,7 +257,7 @@ namespace Server.Misc return true; // Guild allies or enemies can be harmful } - if (bcTarg?.Controlled == true || bcTarg?.Summoned == true && bcTarg?.SummonMaster != from) + if (bcTarg?.Controlled == true || bcTarg?.Summoned == true && bcTarg.SummonMaster != from) { return false; // Cannot harm other controlled mobiles } diff --git a/Projects/UOContent/Misc/Profile.cs b/Projects/UOContent/Misc/Profile.cs index 7fe9bb9ef..085396208 100644 --- a/Projects/UOContent/Misc/Profile.cs +++ b/Projects/UOContent/Misc/Profile.cs @@ -1,4 +1,3 @@ -using System; using Server.Accounting; using Server.Network; diff --git a/Projects/UOContent/Misc/TreasureMapProtection.cs b/Projects/UOContent/Misc/TreasureMapProtection.cs index a5a1e8d7a..0fc5d1283 100644 --- a/Projects/UOContent/Misc/TreasureMapProtection.cs +++ b/Projects/UOContent/Misc/TreasureMapProtection.cs @@ -23,7 +23,7 @@ namespace Server public static void Initialize() { var filePath = Path.Combine(Core.BaseDirectory, "Data/treasure.cfg"); - int i = 0, x = 0, y = 0; + int i = 0; if (File.Exists(filePath)) { @@ -38,8 +38,8 @@ namespace Server { var split = line.Split(' '); - x = Convert.ToInt32(split[0]); - y = Convert.ToInt32(split[1]); + var x = Convert.ToInt32(split[0]); + var y = Convert.ToInt32(split[1]); try { diff --git a/Projects/UOContent/Mobiles/Guards/WarriorGuard.cs b/Projects/UOContent/Mobiles/Guards/WarriorGuard.cs index 962972044..59c1e23ff 100644 --- a/Projects/UOContent/Mobiles/Guards/WarriorGuard.cs +++ b/Projects/UOContent/Mobiles/Guards/WarriorGuard.cs @@ -24,7 +24,7 @@ namespace Server.Mobiles Body = 0x191; Name = NameList.RandomName("female"); - AddItem(Utility.RandomBool() ? (Item)new LeatherSkirt() : new LeatherShorts()); + AddItem(Utility.RandomBool() ? new LeatherSkirt() : new LeatherShorts()); AddItem( Utility.Random(5) switch diff --git a/Projects/UOContent/Mobiles/Townfolk/Banker.cs b/Projects/UOContent/Mobiles/Townfolk/Banker.cs index 3efbc67cf..73db97375 100644 --- a/Projects/UOContent/Mobiles/Townfolk/Banker.cs +++ b/Projects/UOContent/Mobiles/Townfolk/Banker.cs @@ -463,7 +463,7 @@ namespace Server.Mobiles { if (from.Alive) { - list.Add(new OpenBankEntry(from, this)); + list.Add(new OpenBankEntry(this)); } base.AddCustomContextEntries(from, list); diff --git a/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs b/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs index 98886e967..0310c7f2b 100644 --- a/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs @@ -816,7 +816,7 @@ namespace Server.Mobiles } else { - AddItem(Utility.RandomBool() ? (Item)new LongPants(GetRandomHue()) : new ShortPants(GetRandomHue())); + AddItem(Utility.RandomBool() ? new LongPants(GetRandomHue()) : new ShortPants(GetRandomHue())); } PackGold(100, 200); @@ -875,7 +875,7 @@ namespace Server.Mobiles new BuyItemState( buyItem.Name, cont.Serial, - disp?.Serial ?? (Serial)0x7FC0FFEE, + disp?.Serial ?? 0x7FC0FFEE, buyItem.Price, buyItem.Amount, buyItem.ItemID, diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs b/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs index 0a9a02f5a..7e203c696 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles { base.InitOutfit(); - AddItem(Utility.RandomBool() ? new QuarterStaff() : (Item)new ShepherdsCrook()); + AddItem(Utility.RandomBool() ? new QuarterStaff() : new ShepherdsCrook()); } public override void AddCustomContextEntries(Mobile from, List list) diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/KeeperOfChivalry.cs b/Projects/UOContent/Mobiles/Vendors/NPC/KeeperOfChivalry.cs index 03ca4493e..2b24d277a 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/KeeperOfChivalry.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/KeeperOfChivalry.cs @@ -58,7 +58,7 @@ namespace Server.Mobiles AddItem(new MetalKiteShield { Hue = Utility.RandomNondyedHue() }); - AddItem(Utility.RandomBool() ? (Item)new Boots() : new ThighBoots()); + AddItem(Utility.RandomBool() ? new Boots() : new ThighBoots()); PackGold(100, 200); } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Vagabond.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Vagabond.cs index 41e673cee..efce88dc3 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Vagabond.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Vagabond.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles AddItem( Utility.RandomBool() - ? (Item)new SkullCap(Utility.RandomNeutralHue()) + ? new SkullCap(Utility.RandomNeutralHue()) : new Bandana(Utility.RandomNeutralHue()) ); diff --git a/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs b/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs index 9e4d8c251..9051cdc36 100644 --- a/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs +++ b/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs @@ -800,7 +800,7 @@ namespace Server.Mobiles { --buttonID; - if (buttonID >= 0 && buttonID < m_Entries.Length) + if (buttonID < m_Entries.Length) { m_Barkeeper.EndChangeTitle(m_From, m_Entries[buttonID].m_Title, m_Entries[buttonID].m_Vendor); } diff --git a/Projects/UOContent/Multis/Houses/ContestHouses.cs b/Projects/UOContent/Multis/Houses/ContestHouses.cs index 60caccfb8..2d3433b09 100644 --- a/Projects/UOContent/Multis/Houses/ContestHouses.cs +++ b/Projects/UOContent/Multis/Houses/ContestHouses.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using Server.Items; diff --git a/Projects/UOContent/Multis/Houses/HouseFoundation.cs b/Projects/UOContent/Multis/Houses/HouseFoundation.cs index 18f53deb8..fbafbacbd 100644 --- a/Projects/UOContent/Multis/Houses/HouseFoundation.cs +++ b/Projects/UOContent/Multis/Houses/HouseFoundation.cs @@ -1,9 +1,6 @@ using System; -using System.Buffers; using System.Collections.Generic; using System.IO; -using System.IO.Compression; -using System.Runtime.CompilerServices; using Server.Gumps; using Server.Items; using Server.Mobiles; diff --git a/Projects/UOContent/Multis/Houses/HousePlacement.cs b/Projects/UOContent/Multis/Houses/HousePlacement.cs index 0cff65cfa..563ef319d 100644 --- a/Projects/UOContent/Multis/Houses/HousePlacement.cs +++ b/Projects/UOContent/Multis/Houses/HousePlacement.cs @@ -164,9 +164,7 @@ namespace Server.Multis } } - int landStartZ = 0, landAvgZ = 0, landTopZ = 0; - - map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ); + map.GetAverageZ(tileX, tileY, out var landStartZ, out var landAvgZ, out _); var hasFoundation = false; diff --git a/Projects/UOContent/Multis/Houses/HouseSign.cs b/Projects/UOContent/Multis/Houses/HouseSign.cs index 257c81e98..9341915e4 100644 --- a/Projects/UOContent/Multis/Houses/HouseSign.cs +++ b/Projects/UOContent/Multis/Houses/HouseSign.cs @@ -90,7 +90,7 @@ namespace Server.Multis public override void OnSingleClick(Mobile from) { - if (Owner != null && BaseHouse.DecayEnabled && Owner.DecayPeriod != TimeSpan.Zero) + if (BaseHouse.DecayEnabled && Owner != null && Owner.DecayPeriod != TimeSpan.Zero) { var message = Owner.DecayLevel switch { diff --git a/Projects/UOContent/Network/ConnectUO.cs b/Projects/UOContent/Network/ConnectUO.cs index 7b1a5d2aa..44749b378 100644 --- a/Projects/UOContent/Network/ConnectUO.cs +++ b/Projects/UOContent/Network/ConnectUO.cs @@ -16,7 +16,6 @@ using System; using System.Buffers; using Server.Accounting; -using Server.Items; using Server.Logging; using Server.Text; diff --git a/Projects/UOContent/Regions/HouseRegion.cs b/Projects/UOContent/Regions/HouseRegion.cs index 0e170b7e4..419ba11a8 100644 --- a/Projects/UOContent/Regions/HouseRegion.cs +++ b/Projects/UOContent/Regions/HouseRegion.cs @@ -117,7 +117,7 @@ namespace Server.Regions m.Location = House.BanLocation; m.SendLocalizedMessage(1061637); // You are not allowed to access this. } - else if (House is HouseFoundation foundation && foundation?.Customizer != null && + else if (House is HouseFoundation foundation && foundation.Customizer != null && foundation.Customizer != m && House.IsInside(m)) { diff --git a/Projects/UOContent/Special Systems/Engines/TestCenter.cs b/Projects/UOContent/Special Systems/Engines/TestCenter.cs index 25355bea2..706045e35 100644 --- a/Projects/UOContent/Special Systems/Engines/TestCenter.cs +++ b/Projects/UOContent/Special Systems/Engines/TestCenter.cs @@ -235,7 +235,7 @@ namespace Server.Misc if (sb.Length + 1 + v.Length >= 256) { sender.SendMessage( - Server.Serial.MinusOne, + Serial.MinusOne, -1, MessageType.Label, 0x35, @@ -259,7 +259,7 @@ namespace Server.Misc if (sb.Length > 0) { sender.SendMessage( - Server.Serial.MinusOne, + Serial.MinusOne, -1, MessageType.Label, 0x35, diff --git a/Projects/UOContent/Spells/Base/SpellRegistry.cs b/Projects/UOContent/Spells/Base/SpellRegistry.cs index 5c26b2579..9ddbd25db 100644 --- a/Projects/UOContent/Spells/Base/SpellRegistry.cs +++ b/Projects/UOContent/Spells/Base/SpellRegistry.cs @@ -114,7 +114,7 @@ namespace Server.Spells var t = m_Types[spellID]; - if (t == null || !t.IsSubclassOf(typeof(SpecialMove))) + if (t?.IsSubclassOf(typeof(SpecialMove)) != true) { return null; } diff --git a/Projects/UOContent/Spells/Fifth/PoisonField.cs b/Projects/UOContent/Spells/Fifth/PoisonField.cs index e70a7cbce..c8f36551f 100644 --- a/Projects/UOContent/Spells/Fifth/PoisonField.cs +++ b/Projects/UOContent/Spells/Fifth/PoisonField.cs @@ -43,24 +43,7 @@ namespace Server.Spells.Fifth var rx = (dx - dy) * 44; var ry = (dx + dy) * 44; - bool eastToWest; - - if (rx >= 0 && ry >= 0) - { - eastToWest = false; - } - else if (rx >= 0) - { - eastToWest = true; - } - else if (ry >= 0) - { - eastToWest = true; - } - else - { - eastToWest = false; - } + bool eastToWest = rx == 0 && ry >= 0 || rx >= 0 && ry == 0; Effects.PlaySound(new Point3D(p), Caster.Map, 0x20B); @@ -169,24 +152,13 @@ namespace Server.Spells.Fifth if (Core.AOS) { - var total = (m_Caster.Skills.Magery.Fixed + m_Caster.Skills.Poisoning.Fixed) / 2; - - if (total >= 1000) + p = ((m_Caster.Skills.Magery.Fixed + m_Caster.Skills.Poisoning.Fixed) / 2) switch { - p = Poison.Deadly; - } - else if (total > 850) - { - p = Poison.Greater; - } - else if (total > 650) - { - p = Poison.Regular; - } - else - { - p = Poison.Lesser; - } + >= 1000 => Poison.Deadly, + > 850 => Poison.Greater, + > 650 => Poison.Regular, + _ => Poison.Lesser + }; } else { @@ -220,7 +192,7 @@ namespace Server.Spells.Fifth private class InternalTimer : Timer { - private static readonly Queue m_Queue = new(); + private static Queue m_Queue; private readonly bool m_CanFit; private readonly bool m_InLOS; private readonly InternalItem m_Item; @@ -292,13 +264,14 @@ namespace Server.Spells.Fifth if (m.Z + 16 > m_Item.Z && m_Item.Z + 12 > m.Z && (!Core.AOS || m != caster) && SpellHelper.ValidIndirectTarget(caster, m) && caster.CanBeHarmful(m, false)) { + m_Queue ??= new Queue(); m_Queue.Enqueue(m); } } eable.Free(); - while (m_Queue.Count > 0) + while (m_Queue?.Count > 0) { var m = m_Queue.Dequeue(); diff --git a/Projects/UOContent/Spells/Fourth/FireField.cs b/Projects/UOContent/Spells/Fourth/FireField.cs index e75149664..af62cb38b 100644 --- a/Projects/UOContent/Spells/Fourth/FireField.cs +++ b/Projects/UOContent/Spells/Fourth/FireField.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using Server.Items; using Server.Misc; using Server.Mobiles; @@ -43,24 +43,7 @@ namespace Server.Spells.Fourth var rx = (dx - dy) * 44; var ry = (dx + dy) * 44; - bool eastToWest; - - if (rx >= 0 && ry >= 0) - { - eastToWest = false; - } - else if (rx >= 0) - { - eastToWest = true; - } - else if (ry >= 0) - { - eastToWest = true; - } - else - { - eastToWest = false; - } + bool eastToWest = rx == 0 && ry >= 0 || rx >= 0 && ry == 0; Effects.PlaySound(new Point3D(p), Caster.Map, 0x20C); @@ -216,15 +199,12 @@ namespace Server.Spells.Fourth private class InternalTimer : Timer { - private static readonly Queue m_Queue = new(); + private static Queue m_Queue; private readonly bool m_CanFit; private readonly bool m_InLOS; private readonly FireFieldItem m_Item; - public InternalTimer(FireFieldItem item, TimeSpan delay, bool inLOS, bool canFit) : base( - delay, - TimeSpan.FromSeconds(1.0) - ) + public InternalTimer(FireFieldItem item, TimeSpan delay, bool inLOS, bool canFit) : base(delay, TimeSpan.FromSeconds(1.0)) { m_Item = item; m_InLOS = inLOS; @@ -281,13 +261,14 @@ namespace Server.Spells.Fourth if (m.Z + 16 > m_Item.Z && m_Item.Z + 12 > m.Z && (!Core.AOS || m != caster) && SpellHelper.ValidIndirectTarget(caster, m) && caster.CanBeHarmful(m, false)) { + m_Queue ??= new Queue(); m_Queue.Enqueue(m); } } - while (m_Queue.Count > 0) + while (m_Queue?.Count > 0) { - var m = m_Queue.Dequeue() as Mobile; + var m = m_Queue.Dequeue(); if (m == null) { continue; diff --git a/Projects/UOContent/Spells/Necromancy/MindRot.cs b/Projects/UOContent/Spells/Necromancy/MindRot.cs index 6c2b8240f..44a70e316 100644 --- a/Projects/UOContent/Spells/Necromancy/MindRot.cs +++ b/Projects/UOContent/Spells/Necromancy/MindRot.cs @@ -99,7 +99,7 @@ namespace Server.Spells.Necromancy { if (!m_Table.ContainsKey(target)) { - var tmpB = new MRBucket(scalar, new MRExpireTimer(caster, target, duration)); + var tmpB = new MRBucket(scalar, new MRExpireTimer(target, duration)); m_Table.Add(target, tmpB); BuffInfo.AddBuff(target, new BuffInfo(BuffIcon.Mindrot, 1075665, duration, target)); tmpB.m_MRExpireTimer.Start(); @@ -113,7 +113,7 @@ namespace Server.Spells.Necromancy private readonly DateTime m_End; private readonly Mobile m_Target; - public MRExpireTimer(Mobile caster, Mobile target, TimeSpan delay) : base( + public MRExpireTimer(Mobile target, TimeSpan delay) : base( TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0) ) diff --git a/Projects/UOContent/Spells/Seventh/EnergyField.cs b/Projects/UOContent/Spells/Seventh/EnergyField.cs index 8d61cca70..8e7fa4d85 100644 --- a/Projects/UOContent/Spells/Seventh/EnergyField.cs +++ b/Projects/UOContent/Spells/Seventh/EnergyField.cs @@ -43,24 +43,8 @@ namespace Server.Spells.Seventh var rx = (dx - dy) * 44; var ry = (dx + dy) * 44; - bool eastToWest; + bool eastToWest = rx == 0 && ry >= 0 || rx >= 0 && ry == 0; - if (rx >= 0 && ry >= 0) - { - eastToWest = false; - } - else if (rx >= 0) - { - eastToWest = true; - } - else if (ry >= 0) - { - eastToWest = true; - } - else - { - eastToWest = false; - } Effects.PlaySound(new Point3D(p), Caster.Map, 0x20B); diff --git a/Projects/UOContent/Spells/Sixth/ParalyzeField.cs b/Projects/UOContent/Spells/Sixth/ParalyzeField.cs index 44d540074..f75edd8de 100644 --- a/Projects/UOContent/Spells/Sixth/ParalyzeField.cs +++ b/Projects/UOContent/Spells/Sixth/ParalyzeField.cs @@ -42,24 +42,7 @@ namespace Server.Spells.Sixth var rx = (dx - dy) * 44; var ry = (dx + dy) * 44; - bool eastToWest; - - if (rx >= 0 && ry >= 0) - { - eastToWest = false; - } - else if (rx >= 0) - { - eastToWest = true; - } - else if (ry >= 0) - { - eastToWest = true; - } - else - { - eastToWest = false; - } + bool eastToWest = rx == 0 && ry >= 0 || rx >= 0 && ry == 0; Effects.PlaySound(new Point3D(p), Caster.Map, 0x20B); diff --git a/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs b/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs index 5cd55fe36..039d8f6fe 100644 --- a/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs +++ b/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs @@ -1,4 +1,3 @@ -using System; using Server.Targeting; namespace Server.Spells diff --git a/Projects/UOContent/Spells/Third/WallOfStone.cs b/Projects/UOContent/Spells/Third/WallOfStone.cs index b05c28078..0169fb479 100644 --- a/Projects/UOContent/Spells/Third/WallOfStone.cs +++ b/Projects/UOContent/Spells/Third/WallOfStone.cs @@ -40,24 +40,7 @@ namespace Server.Spells.Third var rx = (dx - dy) * 44; var ry = (dx + dy) * 44; - bool eastToWest; - - if (rx >= 0 && ry >= 0) - { - eastToWest = false; - } - else if (rx >= 0) - { - eastToWest = true; - } - else if (ry >= 0) - { - eastToWest = true; - } - else - { - eastToWest = false; - } + bool eastToWest = rx == 0 && ry >= 0 || rx >= 0 && ry == 0; Effects.PlaySound(new Point3D(p), Caster.Map, 0x1F6);