fix(core): Converts death animation (#356)

- [X] Converts death animation
- [X] Fixes tests for movement packets
This commit is contained in:
Kamron Batman 2020-12-21 23:43:45 -08:00 committed by GitHub
parent 77ce2e1980
commit 90393fea2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 65 additions and 89 deletions

View file

@ -21,6 +21,7 @@ namespace Server.Network
public static class OutgoingMobilePackets
{
public const int BondedStatusPacketLength = 11;
public const int DeathAnimationPacketLength = 13;
public static void CreateBondedStatus(ref Span<byte> buffer, Serial serial, bool bonded)
{
@ -41,14 +42,35 @@ namespace Server.Network
}
var writer = new CircularBufferWriter(buffer);
writer.Write((byte)0xBF); // Packet ID
writer.Write((ushort)11); // Length
writer.Write((byte)0xBF); // Packet ID
writer.Write((ushort)11); // Length
writer.Write((ushort)0x19); // Subpacket ID
writer.Write((byte)0); // Command
writer.Write((byte)0); // Command
writer.Write(serial);
writer.Write(bonded);
ns.Send(ref buffer, writer.Position);
}
public static void CreateDeathAnimation(ref Span<byte> buffer, Serial killed, Serial corpse)
{
var writer = new SpanWriter(buffer);
writer.Write((byte)0xAF); // Packet ID
writer.Write(killed);
writer.Write(corpse);
writer.Write(0); // ??
}
public static void SendDeathAnimation(this NetState ns, Serial killed, Serial corpse)
{
if (ns == null)
{
return;
}
Span<byte> span = stackalloc byte[DeathAnimationPacketLength];
CreateDeathAnimation(ref span, killed, corpse);
ns.Send(span);
}
}
}

View file

@ -14,6 +14,7 @@
*************************************************************************/
using System.Buffers;
using System.IO;
namespace Server.Network
{
@ -99,6 +100,7 @@ namespace Server.Network
var writer = new CircularBufferWriter(buffer);
writer.Write((byte)0xBF); // Packet ID
writer.Seek(2, SeekOrigin.Current);
writer.Write((ushort)0x1); // Subpacket
writer.Write(keys[0]);
writer.Write(keys[1]);
@ -107,6 +109,7 @@ namespace Server.Network
writer.Write(keys[4]);
writer.Write(keys[5]);
writer.WritePacketLength();
ns.Send(ref buffer, writer.Position);
}