2023-11-14 19:07:45 +00:00
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
namespace Wonderking.Packets.Outgoing;
|
|
|
|
|
|
|
|
[PacketId(OperationCode.CharacterSelectionSetGuildName)]
|
|
|
|
public class CharacterSelectionSetGuildNamePacket : IPacket
|
|
|
|
{
|
|
|
|
public required string[] GuildNames { get; set; }
|
|
|
|
|
|
|
|
public void Deserialize(byte[] data)
|
|
|
|
{
|
|
|
|
throw new NotSupportedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
public byte[] Serialize()
|
|
|
|
{
|
2023-11-15 12:40:25 +00:00
|
|
|
Span<byte> data = stackalloc byte[1 + (1 + 16 + 1) * this.GuildNames.Length];
|
2023-11-14 19:07:45 +00:00
|
|
|
data.Clear();
|
|
|
|
data[0] = (byte)this.GuildNames.Length;
|
|
|
|
for (var i = 0; i < this.GuildNames.Length; i++)
|
|
|
|
{
|
2023-11-15 12:40:25 +00:00
|
|
|
data[1 + (i * (1 + 16 + 1))] = (byte)i;
|
|
|
|
Encoding.ASCII.GetBytes(this.GuildNames[i], data.Slice(2 + (i * (1 + 16 + 1)), 16));
|
2023-11-14 19:07:45 +00:00
|
|
|
// Null terminator
|
2023-11-15 12:40:25 +00:00
|
|
|
data[18 + (i * (1 + 16 + 1))] = 0;
|
2023-11-14 19:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return data.ToArray();
|
|
|
|
}
|
|
|
|
}
|