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
|
|
@ -487,38 +487,47 @@ namespace Server.Engines.Doom
|
|||
|
||||
public static void PlayerSendASCII(Mobile player, int index)
|
||||
{
|
||||
player.Send(
|
||||
new AsciiMessage(
|
||||
Serial.MinusOne,
|
||||
0xFFFF,
|
||||
MessageType.Label,
|
||||
MsgParams[index][0],
|
||||
MsgParams[index][1],
|
||||
null,
|
||||
Msgs[index]
|
||||
)
|
||||
player.NetState.SendMessage(
|
||||
Serial.MinusOne,
|
||||
0xFFFF,
|
||||
MessageType.Label,
|
||||
MsgParams[index][0],
|
||||
MsgParams[index][1],
|
||||
true,
|
||||
null,
|
||||
null,
|
||||
Msgs[index]
|
||||
);
|
||||
}
|
||||
|
||||
/* I cant find any better way to send "speech" using fonts other than default */
|
||||
public static void POHMessage(Mobile from, int index)
|
||||
{
|
||||
Packet p = new AsciiMessage(
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(Msgs[index])];
|
||||
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
ref buffer,
|
||||
from.Serial,
|
||||
from.Body,
|
||||
MessageType.Regular,
|
||||
MsgParams[index][0],
|
||||
MsgParams[index][1],
|
||||
true,
|
||||
null,
|
||||
from.Name,
|
||||
Msgs[index]
|
||||
);
|
||||
p.Acquire();
|
||||
foreach (var state in from.Map.GetClientsInRange(from.Location))
|
||||
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
|
||||
var eable = from.Map.GetClientsInRange(from.Location);
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
state.Send(p);
|
||||
state.Send(buffer);
|
||||
}
|
||||
|
||||
Packet.Release(p);
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue