2024-02-07 15:40:36 +00:00
|
|
|
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
|
2023-11-20 18:58:30 +00:00
|
|
|
|
2023-11-14 19:07:45 +00:00
|
|
|
using System.Text;
|
2024-04-04 14:57:42 +00:00
|
|
|
using RaiNote.PacketMediator;
|
2023-11-14 19:07:45 +00:00
|
|
|
|
|
|
|
namespace Wonderking.Packets.Outgoing;
|
|
|
|
|
2024-02-04 18:52:45 +00:00
|
|
|
[WonderkingPacketId(OperationCode.CharacterSelectionSetGuildName)]
|
|
|
|
public class CharacterSelectionSetGuildNamePacket : IOutgoingPacket
|
2023-11-14 19:07:45 +00:00
|
|
|
{
|
|
|
|
public required string[] GuildNames { get; set; }
|
2024-02-07 15:40:36 +00:00
|
|
|
|
2023-11-14 19:07:45 +00:00
|
|
|
public byte[] Serialize()
|
|
|
|
{
|
2023-11-19 16:07:28 +00:00
|
|
|
Span<byte> data = stackalloc byte[1 + (1 + 16 + 1) * GuildNames.Length];
|
2023-11-14 19:07:45 +00:00
|
|
|
data.Clear();
|
2023-11-19 16:07:28 +00:00
|
|
|
data[0] = (byte)GuildNames.Length;
|
|
|
|
for (var i = 0; i < GuildNames.Length; i++)
|
2023-11-14 19:07:45 +00:00
|
|
|
{
|
2023-11-19 16:07:28 +00:00
|
|
|
data[1 + i * (1 + 16 + 1)] = (byte)i;
|
|
|
|
Encoding.ASCII.GetBytes(GuildNames[i], data.Slice(2 + i * (1 + 16 + 1), 16));
|
2023-11-14 19:07:45 +00:00
|
|
|
// Null terminator
|
2023-11-19 16:07:28 +00:00
|
|
|
data[18 + i * (1 + 16 + 1)] = 0;
|
2023-11-14 19:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return data.ToArray();
|
|
|
|
}
|
|
|
|
}
|