Code cleanup (#188)

This commit is contained in:
Kamron Batman 2020-08-01 08:40:06 -07:00 • committed by GitHub
parent df53c16620
commit 010fd9402a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
185 changed files with 1052 additions and 1271 deletions

View file

@ -141,7 +141,7 @@ namespace Server.Misc
string saves = Path.Combine(Core.BaseDirectory, "Saves");
if (Directory.Exists(saves))
Directory.Move(saves, FormatDirectory(root, m_Backups[m_Backups.Length - 1], GetTimeStamp()));
Directory.Move(saves, FormatDirectory(root, m_Backups[^1], GetTimeStamp()));
}
private static DirectoryInfo Match(string[] paths, string match)

View file

@ -19,7 +19,7 @@ namespace Server
public static void ResendBuffsOnClientVersionReceived(NetState ns, ClientVersion cv)
{
if (ns.Mobile is PlayerMobile pm)
Timer.DelayCall(TimeSpan.Zero, pm.ResendBuffs);
Timer.DelayCall(pm.ResendBuffs);
}
public BuffIcon ID { get; }
@ -62,13 +62,7 @@ namespace Server
TimeLength = length;
TimeStart = DateTime.UtcNow;
Timer = Timer.DelayCall(length, () =>
{
if (!(m is PlayerMobile pm))
return;
pm.RemoveBuff(this);
});
Timer = Timer.DelayCall(length, RemoveBuff, m, this);
}
public BuffInfo(BuffIcon iconID, int titleCliloc, TextDefinition args)

View file

@ -108,14 +108,7 @@ namespace Server.Misc
state.Mobile.SendMessage(0x22, kickMessage);
state.Mobile.SendMessage(0x22, "You will be disconnected in {0} seconds.", KickDelay.TotalSeconds);
Timer.DelayCall(KickDelay, () =>
{
if (state.Connection != null)
{
Console.WriteLine("Client: {0}: Disconnecting, bad version", state);
state.Dispose();
}
});
Timer.DelayCall(KickDelay, OnKick, state);
}
else if (Required != null && version < Required)
{
@ -138,6 +131,15 @@ namespace Server.Misc
}
}
private static void OnKick(NetState ns)
{
if (ns.Connection != null)
{
Console.WriteLine("Client: {0}: Disconnecting, bad version", ns);
ns.Dispose();
}
}
private static void KickMessage(Mobile from, bool okay)
{
from.SendMessage("You will be reminded of this again.");
@ -147,7 +149,7 @@ namespace Server.Misc
"Old clients will be kicked after {0} days of character age and {1} hours of play time",
m_AgeLeniency, m_GameTimeLeniency);
Timer.DelayCall(TimeSpan.FromMinutes(Utility.Random(5, 15)), () => SendAnnoyGump(from));
Timer.DelayCall(TimeSpan.FromMinutes(Utility.Random(5, 15)), SendAnnoyGump, from);
}
private static void SendAnnoyGump(Mobile m)

View file

@ -390,7 +390,7 @@ namespace Server
public static bool IsFrame(int id, int[] list)
{
if (id > list[list.Length - 1])
if (id > list[^1])
return false;
for (int i = 0; i < list.Length; ++i)

View file

@ -1,4 +1,3 @@
using System;
using Server.Gumps;
using Server.Multis;
using Server.Network;
@ -71,7 +70,7 @@ namespace Server.Items
int version = reader.ReadInt();
Timer.DelayCall(TimeSpan.Zero, FixMovingCrate);
Timer.DelayCall(FixMovingCrate);
}
private void FixMovingCrate()

View file

@ -1089,7 +1089,7 @@ namespace Server.Guilds
AcceptedWars ??= new List<WarDeclaration>();
PendingWars ??= new List<WarDeclaration>();
Timer.DelayCall(TimeSpan.Zero, VerifyGuild_Callback);
Timer.DelayCall(VerifyGuild_Callback);
}
private void VerifyGuild_Callback()

View file

@ -115,7 +115,7 @@ namespace Server.Misc
IPHostEntry iphe = Dns.GetHostEntry(addr);
if (iphe.AddressList.Length > 0)
outValue = iphe.AddressList[iphe.AddressList.Length - 1];
outValue = iphe.AddressList[^1];
}
catch
{