2024-09-18 01:50:29 +08:00
|
|
|
|
using PSO2SERVER.Models;
|
|
|
|
|
using System;
|
2024-11-25 23:33:41 +08:00
|
|
|
|
using System.Runtime.InteropServices;
|
2024-09-18 01:50:29 +08:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
2024-11-27 18:05:53 +08:00
|
|
|
|
namespace PSO2SERVER.Protocol.Packets
|
2024-09-18 01:50:29 +08:00
|
|
|
|
{
|
|
|
|
|
public class SkitItemAddResponsePacket : Packet
|
|
|
|
|
{
|
2024-11-25 23:33:41 +08:00
|
|
|
|
// Skit name - fixed length of 0x20 bytes (32 bytes).
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)]
|
|
|
|
|
public byte[] skit_name;
|
2024-09-18 01:50:29 +08:00
|
|
|
|
|
2024-11-25 23:33:41 +08:00
|
|
|
|
// Unknown field (u32)
|
|
|
|
|
public uint unk;
|
|
|
|
|
|
|
|
|
|
// 默认构造函数
|
2024-09-18 01:50:29 +08:00
|
|
|
|
public SkitItemAddResponsePacket()
|
|
|
|
|
{
|
2024-11-25 23:33:41 +08:00
|
|
|
|
// 默认情况下,skit_name 初始化为空的字节数组
|
|
|
|
|
skit_name = new byte[0x20];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 带参数的构造函数,方便直接初始化字段
|
|
|
|
|
public SkitItemAddResponsePacket(string skitName, uint unkValue)
|
|
|
|
|
{
|
|
|
|
|
// 初始化 skit_name 字段为 32 字节
|
|
|
|
|
skit_name = new byte[0x20];
|
|
|
|
|
// 将字符串转换为字节数组并填充到 skit_name 中
|
|
|
|
|
byte[] nameBytes = Encoding.ASCII.GetBytes(skitName);
|
|
|
|
|
Array.Copy(nameBytes, skit_name, Math.Min(nameBytes.Length, 0x20));
|
|
|
|
|
// 设置 unk 字段的值
|
|
|
|
|
unk = unkValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取 skit_name 字段作为字符串,去除 null 字符
|
|
|
|
|
public string GetSkitName()
|
|
|
|
|
{
|
|
|
|
|
return Encoding.ASCII.GetString(skit_name).TrimEnd('\0');
|
2024-09-18 01:50:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region implemented abstract members of Packet
|
|
|
|
|
|
2024-11-25 23:33:41 +08:00
|
|
|
|
// 构建数据包的方法
|
2024-09-18 01:50:29 +08:00
|
|
|
|
public override byte[] Build()
|
|
|
|
|
{
|
|
|
|
|
var pkt = new PacketWriter();
|
2024-11-25 23:33:41 +08:00
|
|
|
|
|
|
|
|
|
// 写入 skit_name 字段
|
|
|
|
|
pkt.Write(skit_name, 0, skit_name.Length);
|
|
|
|
|
|
|
|
|
|
// 写入 unk 字段
|
|
|
|
|
pkt.Write(unk);
|
|
|
|
|
|
|
|
|
|
// 返回构建好的字节数组
|
2024-09-18 01:50:29 +08:00
|
|
|
|
return pkt.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-25 23:33:41 +08:00
|
|
|
|
// 获取数据包头
|
2024-09-18 01:50:29 +08:00
|
|
|
|
public override PacketHeader GetHeader()
|
|
|
|
|
{
|
|
|
|
|
return new PacketHeader(0x23, 0x0C, PacketFlags.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
2024-11-25 23:33:41 +08:00
|
|
|
|
}
|