fix: Stops creating blocked packets entirely (#944)
Optimizes larger servers where users are logging in and packets are being created for no reason.
This commit is contained in:
parent
5db8b1354c
commit
941452de4a
58 changed files with 5510 additions and 5537 deletions
|
|
@ -16,56 +16,55 @@
|
|||
using System.Buffers;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Network
|
||||
namespace Server.Network;
|
||||
|
||||
public static class OutgoingTargetPackets
|
||||
{
|
||||
public static class OutgoingTargetPackets
|
||||
public static void SendMultiTargetReq(this NetState ns, MultiTarget t)
|
||||
{
|
||||
public static void SendMultiTargetReq(this NetState ns, MultiTarget t)
|
||||
if (ns.CannotSendPackets())
|
||||
{
|
||||
if (ns == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = new SpanWriter(stackalloc byte[ns.HighSeas ? 30 : 26]);
|
||||
writer.Write((byte)0x99); // Packet ID
|
||||
writer.Write(t.AllowGround);
|
||||
writer.Write(t.TargetID);
|
||||
writer.Write((byte)t.Flags);
|
||||
writer.Clear(11);
|
||||
writer.Write((short)t.MultiID);
|
||||
writer.Write((short)t.Offset.X);
|
||||
writer.Write((short)t.Offset.Y);
|
||||
writer.Write((short)t.Offset.Z);
|
||||
if (ns.HighSeas)
|
||||
{
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
ns.Send(writer.Span);
|
||||
return;
|
||||
}
|
||||
|
||||
public static void SendCancelTarget(this NetState ns) =>
|
||||
ns?.Send(stackalloc byte[]
|
||||
{
|
||||
0x6C, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
|
||||
});
|
||||
|
||||
public static void SendTargetReq(this NetState ns, Target t)
|
||||
var writer = new SpanWriter(stackalloc byte[ns.HighSeas ? 30 : 26]);
|
||||
writer.Write((byte)0x99); // Packet ID
|
||||
writer.Write(t.AllowGround);
|
||||
writer.Write(t.TargetID);
|
||||
writer.Write((byte)t.Flags);
|
||||
writer.Clear(11);
|
||||
writer.Write((short)t.MultiID);
|
||||
writer.Write((short)t.Offset.X);
|
||||
writer.Write((short)t.Offset.Y);
|
||||
writer.Write((short)t.Offset.Z);
|
||||
if (ns.HighSeas)
|
||||
{
|
||||
if (ns == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = new SpanWriter(stackalloc byte[19]);
|
||||
writer.Write((byte)0x6C); // Packet ID
|
||||
writer.Write(t.AllowGround);
|
||||
writer.Write(t.TargetID);
|
||||
writer.Write((byte)t.Flags);
|
||||
writer.Clear(12);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
|
||||
public static void SendCancelTarget(this NetState ns) =>
|
||||
ns?.Send(stackalloc byte[]
|
||||
{
|
||||
0x6C, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
|
||||
});
|
||||
|
||||
public static void SendTargetReq(this NetState ns, Target t)
|
||||
{
|
||||
if (ns.CannotSendPackets())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = new SpanWriter(stackalloc byte[19]);
|
||||
writer.Write((byte)0x6C); // Packet ID
|
||||
writer.Write(t.AllowGround);
|
||||
writer.Write(t.TargetID);
|
||||
writer.Write((byte)t.Flags);
|
||||
writer.Clear(12);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue