PSO2SERVER/Server/Protocol/Packets/1A-MailPacket/1A-01-MailListPacket.cs

74 lines
2.3 KiB
C#
Raw Normal View History

2024-09-16 17:09:36 +08:00
using PSO2SERVER.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PSO2SERVER.Protocol.Packets
2024-09-16 17:09:36 +08:00
{
public class MailListPacket : Packet
2024-09-16 17:09:36 +08:00
{
2024-12-11 14:07:19 +08:00
// Unk1 to Unk6 fields - Assuming these are some form of metadata
public ushort Unk1 { get; set; } = 0;
public ushort Unk2 { get; set; } = 0;
public ushort Unk3 { get; set; } = 0;
public ushort Unk4 { get; set; } = 0;
public byte[] Unk5 { get; set; } = new byte[4]; // byte[4] for unk5
public uint Unk6 { get; set; } = 0;
2024-09-16 17:09:36 +08:00
2024-12-11 14:07:19 +08:00
// Player name (?)
public string Name { get; set; } = string.Empty;
// Character name (?)
public string Nickname { get; set; } = string.Empty;
// Mail headers (List of MailHeader objects)
public List<MailHeader> Headers { get; set; } = new List<MailHeader>();
// Default constructor
public MailListPacket()
2024-09-16 17:09:36 +08:00
{
2024-12-11 14:07:19 +08:00
// Initialize properties with default values
Unk5 = new byte[4]; // assuming it's a byte array of size 4
Headers = new List<MailHeader>();
}
// Custom constructor to initialize values
public MailListPacket(ushort unk1, ushort unk2, ushort unk3, ushort unk4, byte[] unk5, uint unk6, string name, string nickname, List<MailHeader> headers)
{
Unk1 = unk1;
Unk2 = unk2;
Unk3 = unk3;
Unk4 = unk4;
Unk5 = unk5;
Unk6 = unk6;
Name = name;
Nickname = nickname;
Headers = headers;
2024-09-16 17:09:36 +08:00
}
#region implemented abstract members of Packet
public override byte[] Build()
{
2024-09-17 11:29:41 +08:00
var pkt = new PacketWriter();
2024-12-11 14:07:19 +08:00
pkt.Write(Unk1);
pkt.Write(Unk2);
pkt.Write(Unk3);
pkt.Write(Unk4);
pkt.Write(Unk5);
pkt.WriteUtf16(Name, 0x36A1, 0xBF);
pkt.WriteUtf16(Nickname, 0x36A1, 0xBF);
pkt.WriteMagic(Headers.Count, 0x36A1, 0xBF);
foreach (var header in Headers) { pkt.WriteStruct(header); }
2024-09-17 11:29:41 +08:00
return pkt.ToArray();
2024-09-16 17:09:36 +08:00
}
public override PacketHeader GetHeader()
{
2024-12-11 14:07:19 +08:00
return new PacketHeader(0x1A, 0x01, PacketFlags.PACKED);
2024-09-16 17:09:36 +08:00
}
#endregion
}
}