Updates Message Packets (#321)

### API Breaking Change
Combined `AsciiMessage` and `UnicodeMessage` into a single function that takes two arguments, `bool ascii` and `string lang`. Lang can be null (or anything) if ascii is true. 

- [X] Changes message packets
- [X] Cleans up some code
- [X] Uses benchmarks to determine if the spanwriter + copyfrom
This commit is contained in:
Kamron Batman 2020-11-20 21:50:13 -08:00 • committed by GitHub
parent 10d884fe30
commit b6cd408623
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 1160 additions and 1025 deletions

View file

@ -25,6 +25,19 @@ namespace Server.Network
public const int HuedEffectLength = 36;
public const int BoltEffectLength = 36;
public static void SendSoundEffect(this NetState ns, int soundID, IPoint3D target)
{
if (ns == null)
{
return;
}
Span<byte> buffer = stackalloc byte[SoundPacketLength];
CreateSoundEffect(ref buffer, soundID, target);
ns.Send(buffer);
}
public static void CreateSoundEffect(ref Span<byte> buffer, int soundID, IPoint3D target)
{
var writer = new SpanWriter(buffer);
@ -37,25 +50,6 @@ namespace Server.Network
writer.Write((short)target.Z);
}
public static void SendSoundEffect(this NetState ns, int soundID, IPoint3D target)
{
if (ns == null || !ns.GetSendBuffer(out var buffer))
{
return;
}
var writer = new CircularBufferWriter(buffer);
writer.Write((byte)0x54); // Packet ID
writer.Write((byte)1); // flags
writer.Write((short)soundID);
writer.Write((short)0); // volume
writer.Write((short)target.X);
writer.Write((short)target.Y);
writer.Write((short)target.Z);
ns.Send(ref buffer, writer.Position);
}
public static void CreateParticleEffect(
ref Span<byte> buffer,
EffectType type, Serial from, Serial to, int itemID, IPoint3D fromPoint, IPoint3D toPoint,