cleanup: Fixes bugs and cleans up code (#660)

This commit is contained in:
Kamron Batman 2021-07-19 20:49:59 -07:00 committed by GitHub
parent 1de0b656a9
commit 679e8100f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 160 additions and 346 deletions

View file

@ -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();

View file

@ -15,7 +15,6 @@
using System;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using SerializationGenerator;

View file

@ -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");
}
}
}
}

View file

@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis;

View file

@ -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;

View file

@ -1,7 +1,6 @@
using System;
using System.Buffers;
using System.IO;
using Server.Network;
using Xunit;
namespace Server.Tests.Buffers

View file

@ -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)
{

View file

@ -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);
}

View file

@ -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) &&

View file

@ -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);

View file

@ -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;
}
}
}

View file

@ -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;

View file

@ -2,7 +2,6 @@ using System;
using System.Buffers;
using System.IO;
using System.IO.Compression;
using Server.Multis;
namespace Server.Network
{

View file

@ -54,6 +54,7 @@ namespace Server.Commands
}
catch
{
// ignored
}
}
}

View file

@ -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;

View file

@ -1,4 +1,3 @@
using System;
using System.IO;
using System.Text;
using Server.Accounting;

View file

@ -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)
{

View file

@ -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<Item> m_DeleteQueue = new();
private static readonly string[] m_EmptyParams = Array.Empty<string>();
private List<DecorationEntryMag> 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;

View file

@ -1,5 +1,4 @@
using System;
using System.Globalization;
using System.Globalization;
namespace Server.Commands
{

View file

@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;

View file

@ -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()
{

View file

@ -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;
}

View file

@ -18,7 +18,7 @@ namespace Server.Engines.CannedEvil
public class DungeonChampionSpawn : ChampionSpawn
{
[Constructible]
public DungeonChampionSpawn() : base()
public DungeonChampionSpawn()
{
CannedEvilTimer.AddSpawn(this);
}

View file

@ -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;

View file

@ -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);

View file

@ -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)
{

View file

@ -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<object> m_List;
private readonly object m_Object;

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;

View file

@ -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"
};
}

View file

@ -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;

View file

@ -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)

View file

@ -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

View file

@ -123,7 +123,7 @@ namespace Server.Engines.Doom
m_Tiles = new List<LeverPuzzleRegion>();
for (; i < 9; i++)
{
m_Tiles.Add(new LeverPuzzleRegion(this, TA[i]));
m_Tiles.Add(new LeverPuzzleRegion(TA[i]));
}
m_Teles = new List<Item>();
@ -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<LeverPuzzleRegion>();
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);

View file

@ -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();

View file

@ -1,4 +1,3 @@
using System;
using Server.Mobiles;
using Server.Network;

View file

@ -1,4 +1,3 @@
using System;
using Server.Gumps;
using Server.Mobiles;
using Server.Multis;

View file

@ -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)

View file

@ -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<SOS>()

View file

@ -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);
}

View file

@ -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;

View file

@ -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;

View file

@ -63,8 +63,6 @@ namespace Server.Engines.Quests.Collector
Y = y;
}
public ImageType Image { get; }
public int Figurine { get; }
public Type Type { get; }

View file

@ -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

View file

@ -14,7 +14,6 @@
*************************************************************************/
using System.Collections.Generic;
using System.Reflection;
using Server.Buffers;
using Server.Commands.Generic;
using Server.Engines.Spawners;

View file

@ -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;

View file

@ -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;
}

View file

@ -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;

View file

@ -104,7 +104,7 @@ namespace Server.Gumps
}
else
{
Item toGive = null;
Item toGive;
if (m_House.IsAosRules)
{

View file

@ -1,4 +1,3 @@
using System;
using Server.Factions;
using Server.Guilds;
using Server.Mobiles;

View file

@ -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;
}

View file

@ -11,12 +11,10 @@ namespace Server.Gumps
{
private readonly List<Mobile> m_Killers;
private int m_Idx;
private Mobile m_Victum;
private ReportMurdererGump(Mobile victum, List<Mobile> killers, int idx = 0) : base(0, 0)
private ReportMurdererGump(List<Mobile> 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));
}
}
}

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Mobiles;

View file

@ -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);

View file

@ -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;
}

View file

@ -1,4 +1,3 @@
using System;
using System.Linq;
using Server.Mobiles;

View file

@ -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
}

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;

View file

@ -1,4 +1,3 @@
using System;
using Server.Gumps;
using Server.Multis;
using Server.Network;

View file

@ -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;

View file

@ -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;

View file

@ -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]);

View file

@ -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()

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -1,5 +1,3 @@
using System;
namespace Server.Items
{
public class DisguisePersistance : Item

View file

@ -160,7 +160,6 @@ namespace Server.Gumps
x += 150;
AddHtml(x, 140 + idx * 20, 60, 20, Color(Center("1"), color));
x += 60;
}
}

View file

@ -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()

View file

@ -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,

View file

@ -1,4 +1,3 @@
using System;
using Server.Engines.MLQuests;
using Server.Engines.MLQuests.Objectives;
using Server.Mobiles;

View file

@ -1,4 +1,3 @@
using System;
using Server.Engines.Quests.Haven;
using Server.Engines.VeteranRewards;
using Server.Gumps;

View file

@ -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);

View file

@ -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,

View file

@ -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
}

View file

@ -1,4 +1,3 @@
using System;
using Server.Accounting;
using Server.Network;

View file

@ -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
{

View file

@ -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

View file

@ -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);

View file

@ -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,

View file

@ -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<ContextMenuEntry> list)

View file

@ -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);
}

View file

@ -38,7 +38,7 @@ namespace Server.Mobiles
AddItem(
Utility.RandomBool()
? (Item)new SkullCap(Utility.RandomNeutralHue())
? new SkullCap(Utility.RandomNeutralHue())
: new Bandana(Utility.RandomNeutralHue())
);

View file

@ -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);
}

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Items;

View file

@ -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;

View file

@ -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;

View file

@ -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
{

View file

@ -16,7 +16,6 @@
using System;
using System.Buffers;
using Server.Accounting;
using Server.Items;
using Server.Logging;
using Server.Text;

View file

@ -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))
{

View file

@ -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,

View file

@ -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;
}

View file

@ -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<Mobile> m_Queue = new();
private static Queue<Mobile> 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<Mobile>();
m_Queue.Enqueue(m);
}
}
eable.Free();
while (m_Queue.Count > 0)
while (m_Queue?.Count > 0)
{
var m = m_Queue.Dequeue();

View file

@ -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<Mobile> 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<Mobile>();
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;

View file

@ -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)
)

View file

@ -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);

View file

@ -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);

View file

@ -1,4 +1,3 @@
using System;
using Server.Targeting;
namespace Server.Spells

View file

@ -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);