Adds more packets (#177)
This commit is contained in:
parent
c0805850c1
commit
5052bf9af3
15 changed files with 609 additions and 109 deletions
|
|
@ -136,7 +136,10 @@ namespace System.Buffers
|
|||
{
|
||||
int length = value.Length;
|
||||
pos += Encoding.ASCII.GetBytes(value.AsSpan(0, length), span.Slice(pos, length));
|
||||
span[pos++] = 0; // Null terminator
|
||||
#if NO_LOCAL_INIT
|
||||
span[pos] = 0; // Null terminator
|
||||
#endif
|
||||
pos++;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
|
@ -145,7 +148,10 @@ namespace System.Buffers
|
|||
var length = value.Length < max ? value.Length : max - 1;
|
||||
|
||||
pos += Encoding.ASCII.GetBytes(value.AsSpan(0, length), span.Slice(pos, length));
|
||||
span[pos++] = 0; // Null terminator
|
||||
#if NO_LOCAL_INIT
|
||||
span[pos] = 0; // Null terminator
|
||||
#endif
|
||||
pos++;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
|
@ -164,22 +170,6 @@ namespace System.Buffers
|
|||
pos += amount;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void WriteAsciiFixedNull(this Span<byte> span, ref int pos, string value, int amount)
|
||||
{
|
||||
var length = value.Length < amount ? value.Length : amount - 1;
|
||||
#if NO_LOCAL_INIT
|
||||
int bytesWritten = Encoding.ASCII.GetBytes(value.AsSpan(0, amount), span.Slice(pos, amount));
|
||||
|
||||
if (bytesWritten < amount)
|
||||
span.Slice(pos + bytesWritten, amount - bytesWritten).Clear();
|
||||
#else
|
||||
Encoding.ASCII.GetBytes(value.AsSpan(0, length), span.Slice(pos, length));
|
||||
#endif
|
||||
|
||||
pos += amount;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void WriteBigUni(this Span<byte> span, ref int pos, string value)
|
||||
{
|
||||
|
|
@ -191,5 +181,34 @@ namespace System.Buffers
|
|||
{
|
||||
pos += Encoding.Unicode.GetBytes(value, span.Slice(pos));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void WriteBigUniNull(this Span<byte> span, ref int pos, string value)
|
||||
{
|
||||
pos += Encoding.BigEndianUnicode.GetBytes(value, span.Slice(pos));
|
||||
#if NO_LOCAL_INIT
|
||||
BinaryPrimitives.WriteUInt16BigEndian(span.Slice(pos, 2), 0); // Null terminator
|
||||
#endif
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void WriteLittleUniNull(this Span<byte> span, ref int pos, string value)
|
||||
{
|
||||
pos += Encoding.Unicode.GetBytes(value, span.Slice(pos));
|
||||
#if NO_LOCAL_INIT
|
||||
BinaryPrimitives.WriteUInt16BigEndian(span.Slice(pos, 2), 0); // Null terminator
|
||||
#endif
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Write(this Span<byte> span, ref int pos, Point3D p)
|
||||
{
|
||||
BinaryPrimitives.WriteUInt16BigEndian(span.Slice(pos, 2), (ushort)p.X);
|
||||
BinaryPrimitives.WriteUInt16BigEndian(span.Slice(pos + 2, 2), (ushort)p.Y);
|
||||
span[pos + 4] = (byte)p.Z;
|
||||
pos += 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1040,7 +1040,7 @@ namespace Server
|
|||
|
||||
public static bool FwdEnabled { get; set; } = true;
|
||||
|
||||
public static bool FwdUOTDOverride { get; set; } = false;
|
||||
public static bool FwdUOTDOverride { get; set; }
|
||||
|
||||
public static int FwdMaxSteps { get; set; } = 4;
|
||||
|
||||
|
|
@ -2079,7 +2079,7 @@ namespace Server
|
|||
if (ns != null)
|
||||
{
|
||||
if (m_Map != null)
|
||||
ns.Send(new ServerChange(this, m_Map));
|
||||
ns.Send(new ServerChange(m_Location, m_Map));
|
||||
|
||||
ns.Sequence = 0;
|
||||
ClearFastwalkStack();
|
||||
|
|
@ -2210,7 +2210,7 @@ namespace Server
|
|||
if (ns != null)
|
||||
{
|
||||
if (m_Map != null)
|
||||
Send(new ServerChange(this, m_Map));
|
||||
Send(new ServerChange(m_Location, m_Map));
|
||||
|
||||
ns.Sequence = 0;
|
||||
ClearFastwalkStack();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ namespace Server.Network
|
|||
|
||||
public sealed class DisplayProfile : Packet
|
||||
{
|
||||
public DisplayProfile(bool realSerial, Mobile m, string header, string body, string footer) : base(0xB8)
|
||||
public DisplayProfile(Serial m, string header, string body, string footer) : base(0xB8)
|
||||
{
|
||||
header ??= "";
|
||||
body ??= "";
|
||||
|
|
@ -109,7 +109,7 @@ namespace Server.Network
|
|||
|
||||
EnsureCapacity(12 + header.Length + footer.Length * 2 + body.Length * 2);
|
||||
|
||||
Stream.Write(realSerial ? m.Serial : Serial.Zero);
|
||||
Stream.Write(m);
|
||||
Stream.WriteAsciiNull(header);
|
||||
Stream.WriteBigUniNull(footer);
|
||||
Stream.WriteBigUniNull(body);
|
||||
|
|
@ -144,19 +144,19 @@ namespace Server.Network
|
|||
|
||||
public sealed class RemoveEntity : Packet
|
||||
{
|
||||
public RemoveEntity(IEntity entity) : base(0x1D, 5)
|
||||
public RemoveEntity(Serial entity) : base(0x1D, 5)
|
||||
{
|
||||
Stream.Write(entity.Serial);
|
||||
Stream.Write(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ServerChange : Packet
|
||||
{
|
||||
public ServerChange(Mobile m, Map map) : base(0x76, 16)
|
||||
public ServerChange(Point3D p, Map map) : base(0x76, 16)
|
||||
{
|
||||
Stream.Write((short)m.X);
|
||||
Stream.Write((short)m.Y);
|
||||
Stream.Write((short)m.Z);
|
||||
Stream.Write((short)p.X);
|
||||
Stream.Write((short)p.Y);
|
||||
Stream.Write((short)p.Z);
|
||||
Stream.Write((byte)0);
|
||||
Stream.Write((short)0);
|
||||
Stream.Write((short)0);
|
||||
|
|
@ -289,18 +289,18 @@ namespace Server.Network
|
|||
|
||||
public sealed class DisplayPaperdoll : Packet
|
||||
{
|
||||
public DisplayPaperdoll(Mobile m, string text, bool canLift) : base(0x88, 66)
|
||||
public DisplayPaperdoll(Serial m, string title, bool warmode, bool canLift) : base(0x88, 66)
|
||||
{
|
||||
byte flags = 0x00;
|
||||
|
||||
if (m.Warmode)
|
||||
if (warmode)
|
||||
flags |= 0x01;
|
||||
|
||||
if (canLift)
|
||||
flags |= 0x02;
|
||||
|
||||
Stream.Write(m.Serial);
|
||||
Stream.WriteAsciiFixed(text, 60);
|
||||
Stream.Write(m);
|
||||
Stream.WriteAsciiFixed(title, 60);
|
||||
Stream.Write(flags);
|
||||
}
|
||||
}
|
||||
|
|
@ -370,19 +370,21 @@ namespace Server.Network
|
|||
|
||||
public sealed class CurrentTime : Packet
|
||||
{
|
||||
public CurrentTime() : base(0x5B, 4)
|
||||
public CurrentTime() : this(DateTime.Now)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
Stream.Write((byte)now.Hour);
|
||||
Stream.Write((byte)now.Minute);
|
||||
Stream.Write((byte)now.Second);
|
||||
public CurrentTime(DateTime date) : base(0x5B, 4)
|
||||
{
|
||||
Stream.Write((byte)date.Hour);
|
||||
Stream.Write((byte)date.Minute);
|
||||
Stream.Write((byte)date.Second);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class PathfindMessage : Packet
|
||||
{
|
||||
public PathfindMessage(IPoint3D p) : base(0x38, 7)
|
||||
public PathfindMessage(Point3D p) : base(0x38, 7)
|
||||
{
|
||||
Stream.Write((short)p.X);
|
||||
Stream.Write((short)p.Y);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace Server.Network
|
|||
{
|
||||
return RemoveEntityPackets.GetOrAdd(entity, value =>
|
||||
{
|
||||
var packet = new RemoveEntity(value);
|
||||
var packet = new RemoveEntity(value.Serial);
|
||||
packet.SetStatic();
|
||||
return packet;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue