Adds BufferReader and BufferWriter. Updates UOP handling. (#101)
This commit is contained in:
parent
2c0d97cd36
commit
038c3be258
98 changed files with 2458 additions and 2185 deletions
|
|
@ -1,31 +1,23 @@
|
|||
namespace Server.Misc
|
||||
{
|
||||
public class Animations
|
||||
public static class Animations
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.AnimateRequest += EventSink_AnimateRequest;
|
||||
}
|
||||
|
||||
private static void EventSink_AnimateRequest(AnimateRequestEventArgs e)
|
||||
private static void EventSink_AnimateRequest(Mobile from, string actionName)
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
|
||||
int action;
|
||||
|
||||
switch (e.Action)
|
||||
int action = actionName switch
|
||||
{
|
||||
case "bow":
|
||||
action = 32;
|
||||
break;
|
||||
case "salute":
|
||||
action = 33;
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
"bow" => 32,
|
||||
"salute" => 33,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
if (from.Alive && !from.Mounted && from.Body.IsHuman)
|
||||
if (action > 0 && from.Alive && !from.Mounted && from.Body.IsHuman)
|
||||
from.Animate(action, 5, 1, true, false, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,4 +59,4 @@ namespace Server.Misc
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
namespace Server.Misc
|
||||
{
|
||||
public class Broadcasts
|
||||
public static class Broadcasts
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Crashed += EventSink_Crashed;
|
||||
EventSink.ServerCrashed += EventSink_Crashed;
|
||||
EventSink.Shutdown += EventSink_Shutdown;
|
||||
}
|
||||
|
||||
public static void EventSink_Crashed(CrashedEventArgs e)
|
||||
public static void EventSink_Crashed(ServerCrashedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -20,16 +20,16 @@ namespace Server.Misc
|
|||
}
|
||||
}
|
||||
|
||||
public static void EventSink_Shutdown(ShutdownEventArgs e)
|
||||
public static void EventSink_Shutdown()
|
||||
{
|
||||
/* try
|
||||
{
|
||||
World.Broadcast(0x35, true, "The server has shut down.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}*/
|
||||
/* try
|
||||
{
|
||||
World.Broadcast(0x35, true, "The server has shut down.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@ namespace Server
|
|||
public static void Initialize()
|
||||
{
|
||||
if (Enabled)
|
||||
EventSink.ClientVersionReceived += delegate(ClientVersionReceivedArgs args)
|
||||
{
|
||||
if (args.State.Mobile is PlayerMobile pm)
|
||||
Timer.DelayCall(TimeSpan.Zero, pm.ResendBuffs);
|
||||
};
|
||||
EventSink.ClientVersionReceived += ResendBuffsOnClientVersionReceived;
|
||||
}
|
||||
|
||||
public static void ResendBuffsOnClientVersionReceived(NetState ns, ClientVersion cv)
|
||||
{
|
||||
if (ns.Mobile is PlayerMobile pm)
|
||||
Timer.DelayCall(TimeSpan.Zero, pm.ResendBuffs);
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
|
@ -284,4 +286,4 @@ namespace Server
|
|||
m_Stream.Fill(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1164,7 +1164,7 @@ namespace Server.Misc
|
|||
if (m_Mobile?.EquipItem(item) == true)
|
||||
return;
|
||||
|
||||
Container pack = m_Mobile.Backpack;
|
||||
Container pack = m_Mobile?.Backpack;
|
||||
|
||||
if (!mustEquip && pack != null)
|
||||
pack.DropItem(item);
|
||||
|
|
|
|||
|
|
@ -56,13 +56,11 @@ namespace Server.Misc
|
|||
}
|
||||
}
|
||||
|
||||
private static void EventSink_ClientVersionReceived(ClientVersionReceivedArgs e)
|
||||
private static void EventSink_ClientVersionReceived(NetState state, ClientVersion version)
|
||||
{
|
||||
string kickMessage = null;
|
||||
NetState state = e.State;
|
||||
ClientVersion version = e.Version;
|
||||
|
||||
if (state.Mobile == null || state.Mobile.AccessLevel > AccessLevel.Player)
|
||||
if (state.Mobile?.AccessLevel != AccessLevel.Player)
|
||||
return;
|
||||
|
||||
if (Required != null && version < Required && (m_OldClientResponse == OldClientResponse.Kick ||
|
||||
|
|
|
|||
|
|
@ -7,20 +7,20 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class CrashGuard
|
||||
public static class CrashGuard
|
||||
{
|
||||
private static bool Enabled = true;
|
||||
private static bool SaveBackup = true;
|
||||
private static bool RestartServer = true;
|
||||
private static bool GenerateReport = true;
|
||||
private static readonly bool Enabled = true;
|
||||
private static readonly bool SaveBackup = true;
|
||||
private static readonly bool RestartServer = true;
|
||||
private static readonly bool GenerateReport = true;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Enabled) // If enabled, register our crash event handler
|
||||
EventSink.Crashed += CrashGuard_OnCrash;
|
||||
EventSink.ServerCrashed += CrashGuard_OnCrash;
|
||||
}
|
||||
|
||||
public static void CrashGuard_OnCrash(CrashedEventArgs e)
|
||||
public static void CrashGuard_OnCrash(ServerCrashedEventArgs e)
|
||||
{
|
||||
if (GenerateReport)
|
||||
GenerateCrashReport(e);
|
||||
|
|
@ -61,7 +61,7 @@ namespace Server.Misc
|
|||
|
||||
private static string Combine(string path1, string path2) => path1.Length == 0 ? path2 : Path.Combine(path1, path2);
|
||||
|
||||
private static void Restart(CrashedEventArgs e)
|
||||
private static void Restart(ServerCrashedEventArgs e)
|
||||
{
|
||||
string root = GetRoot();
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ namespace Server.Misc
|
|||
}
|
||||
}
|
||||
|
||||
private static void GenerateCrashReport(CrashedEventArgs e)
|
||||
private static void GenerateCrashReport(ServerCrashedEventArgs e)
|
||||
{
|
||||
Console.Write("Crash: Generating report...");
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace Server.Misc
|
|||
{
|
||||
// This fastwalk detection is no longer required
|
||||
// As of B36 PlayerMobile implements movement packet throttling which more reliably controls movement speeds
|
||||
public class Fastwalk
|
||||
public static class Fastwalk
|
||||
{
|
||||
private static int MaxSteps = 4; // Maximum number of queued steps until fastwalk is detected
|
||||
private static bool Enabled = false; // Is fastwalk detection enabled?
|
||||
|
|
@ -30,4 +30,4 @@ namespace Server.Misc
|
|||
Console.WriteLine("Client: {0}: Fast movement detected (name={1})", e.NetState, e.NetState.Mobile.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -484,9 +484,7 @@ namespace Server.Guilds
|
|||
|
||||
public class WarTimer : Timer
|
||||
{
|
||||
private static TimeSpan InternalDelay = TimeSpan.FromMinutes(1.0);
|
||||
|
||||
public WarTimer() : base(InternalDelay, InternalDelay) => Priority = TimerPriority.FiveSeconds;
|
||||
public WarTimer() : base(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0)) => Priority = TimerPriority.FiveSeconds;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
|
|
@ -718,7 +716,7 @@ namespace Server.Guilds
|
|||
|
||||
if (o is Guildstone stone)
|
||||
{
|
||||
if (stone?.Guild.Disbanded != false)
|
||||
if (stone.Guild.Disbanded)
|
||||
{
|
||||
from.SendMessage("The guild associated with that Guildstone no longer exists");
|
||||
return;
|
||||
|
|
@ -748,9 +746,9 @@ namespace Server.Guilds
|
|||
|
||||
#region EventSinks
|
||||
|
||||
public static void EventSink_GuildGumpRequest(GuildGumpRequestArgs args)
|
||||
public static void EventSink_GuildGumpRequest(Mobile m)
|
||||
{
|
||||
if (!NewGuildSystem || !(args.Mobile is PlayerMobile pm))
|
||||
if (!NewGuildSystem || !(m is PlayerMobile pm))
|
||||
return;
|
||||
|
||||
if (pm.Guild == null)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using Server.Mobiles;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class Keywords
|
||||
public static class Keywords
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
|
|
@ -51,4 +51,4 @@ namespace Server.Misc
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,10 +54,8 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
public static void OnLogin(LoginEventArgs args)
|
||||
public static void OnLogin(Mobile m)
|
||||
{
|
||||
Mobile m = args.Mobile;
|
||||
|
||||
m.CheckLightLevels(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,17 +10,15 @@ namespace Server.Misc
|
|||
EventSink.Login += EventSink_Login;
|
||||
}
|
||||
|
||||
private static void EventSink_Login(LoginEventArgs args)
|
||||
private static void EventSink_Login(Mobile m)
|
||||
{
|
||||
int userCount = TcpServer.Instances.Count;
|
||||
int itemCount = World.Items.Count;
|
||||
int mobileCount = World.Mobiles.Count;
|
||||
|
||||
Mobile m = args.Mobile;
|
||||
|
||||
m.SendMessage(
|
||||
"Welcome, {0}! There {1} currently {2} user{3} online, with {4} item{5} and {6} mobile{7} in the world.",
|
||||
args.Mobile.Name,
|
||||
m.Name,
|
||||
userCount == 1 ? "is" : "are",
|
||||
userCount, userCount == 1 ? "" : "s",
|
||||
itemCount, itemCount == 1 ? "" : "s",
|
||||
|
|
|
|||
|
|
@ -3,18 +3,15 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class Paperdoll
|
||||
public static class Paperdoll
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.PaperdollRequest += EventSink_PaperdollRequest;
|
||||
}
|
||||
|
||||
public static void EventSink_PaperdollRequest(PaperdollRequestEventArgs e)
|
||||
public static void EventSink_PaperdollRequest(Mobile beholder, Mobile beheld)
|
||||
{
|
||||
Mobile beholder = e.Beholder;
|
||||
Mobile beheld = e.Beheld;
|
||||
|
||||
beholder.Send(new DisplayPaperdoll(beheld, Titles.ComputeTitle(beholder, beheld),
|
||||
beheld.AllowEquipFrom(beholder)));
|
||||
|
||||
|
|
@ -30,4 +27,4 @@ namespace Server.Misc
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Server.Misc
|
|||
Other // some other implementation
|
||||
}
|
||||
|
||||
public class ProfanityProtection
|
||||
public static class ProfanityProtection
|
||||
{
|
||||
private static bool Enabled = false;
|
||||
|
||||
|
|
@ -118,4 +118,4 @@ namespace Server.Misc
|
|||
e.Blocked = !OnProfanityDetected(from, e.Speech);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class Profile
|
||||
public static class Profile
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
|
|
@ -12,21 +12,16 @@ namespace Server.Misc
|
|||
EventSink.ChangeProfileRequest += EventSink_ChangeProfileRequest;
|
||||
}
|
||||
|
||||
public static void EventSink_ChangeProfileRequest(ChangeProfileRequestEventArgs e)
|
||||
public static void EventSink_ChangeProfileRequest(Mobile beholder, Mobile beheld, string text)
|
||||
{
|
||||
Mobile from = e.Beholder;
|
||||
|
||||
if (from.ProfileLocked)
|
||||
from.SendMessage("Your profile is locked. You may not change it.");
|
||||
if (beholder.ProfileLocked)
|
||||
beholder.SendMessage("Your profile is locked. You may not change it.");
|
||||
else
|
||||
from.Profile = e.Text;
|
||||
beholder.Profile = text;
|
||||
}
|
||||
|
||||
public static void EventSink_ProfileRequest(ProfileRequestEventArgs e)
|
||||
public static void EventSink_ProfileRequest(Mobile beholder, Mobile beheld)
|
||||
{
|
||||
Mobile beholder = e.Beholder;
|
||||
Mobile beheld = e.Beheld;
|
||||
|
||||
if (!beheld.Player)
|
||||
return;
|
||||
|
||||
|
|
@ -48,10 +43,7 @@ namespace Server.Misc
|
|||
if (footer.Length == 0 && beholder == beheld)
|
||||
footer = GetAccountDuration(beheld);
|
||||
|
||||
string body = beheld.Profile;
|
||||
|
||||
if (body == null || body.Length <= 0)
|
||||
body = "";
|
||||
string body = beheld.Profile ?? "";
|
||||
|
||||
beholder.Send(new DisplayProfile(beholder != beheld || !beheld.ProfileLocked, beheld, header, body, footer));
|
||||
}
|
||||
|
|
@ -90,4 +82,4 @@ namespace Server.Misc
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,14 @@
|
|||
namespace Server.Misc
|
||||
{
|
||||
public class RenameRequests
|
||||
public static class RenameRequests
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.RenameRequest += EventSink_RenameRequest;
|
||||
}
|
||||
|
||||
private static void EventSink_RenameRequest(RenameRequestEventArgs e)
|
||||
private static void EventSink_RenameRequest(Mobile from, Mobile targ, string name)
|
||||
{
|
||||
Mobile from = e.From;
|
||||
Mobile targ = e.Target;
|
||||
string name = e.Name;
|
||||
|
||||
if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from))
|
||||
{
|
||||
name = name.Trim();
|
||||
|
|
@ -44,4 +40,4 @@ namespace Server.Misc
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,12 +142,12 @@ namespace Server.Misc
|
|||
EventSink.Login += EventSink_Login;
|
||||
}
|
||||
|
||||
private static void EventSink_Login(LoginEventArgs e)
|
||||
private static void EventSink_Login(Mobile m)
|
||||
{
|
||||
if (m_ActivePollers.Count == 0)
|
||||
return;
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), EventSink_Login_Callback, e.Mobile);
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), EventSink_Login_Callback, m);
|
||||
}
|
||||
|
||||
private static void EventSink_Login_Callback(Mobile from)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Server.Misc
|
|||
PainSpike
|
||||
}
|
||||
|
||||
public class WeightOverloading
|
||||
public static class WeightOverloading
|
||||
{
|
||||
public const int OverloadAllowance = 4; // We can be four stones overweight without getting fatigued
|
||||
|
||||
|
|
@ -117,4 +117,4 @@ namespace Server.Misc
|
|||
return Mobile.BodyWeight + m.TotalWeight > GetMaxWeight(m) + OverloadAllowance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue