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:
parent
10d884fe30
commit
b6cd408623
59 changed files with 1160 additions and 1025 deletions
|
|
@ -152,28 +152,23 @@ namespace Server
|
|||
|
||||
public static void Broadcast(int hue, bool ascii, string text)
|
||||
{
|
||||
Packet p;
|
||||
var length = OutgoingMessagePackets.GetMaxMessageLength(text);
|
||||
|
||||
if (ascii)
|
||||
{
|
||||
p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text);
|
||||
}
|
||||
Span<byte> buffer = stackalloc byte[length];
|
||||
length = OutgoingMessagePackets.CreateMessage(
|
||||
ref buffer,
|
||||
Serial.MinusOne, -1, MessageType.Regular, hue, 3, ascii, "ENU", "System", text
|
||||
);
|
||||
|
||||
p.Acquire();
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
|
||||
foreach (var ns in TcpServer.Instances)
|
||||
{
|
||||
if (ns.Mobile != null)
|
||||
{
|
||||
ns.Send(p);
|
||||
ns.Send(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
p.Release();
|
||||
}
|
||||
|
||||
public static void Broadcast(int hue, bool ascii, string format, params object[] args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue