PSO2SERVER/Server/Protocol/Packets/0E-PartyPacket/0E-0D-PartySettingsPacket.cs

88 lines
2.5 KiB
C#
Raw Normal View History

2024-09-16 17:09:36 +08:00
using PSO2SERVER.Models;
2024-12-11 14:07:19 +08:00
using PSO2SERVER.Party;
2024-09-16 17:09:36 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PSO2SERVER.Protocol.Packets
2024-09-16 17:09:36 +08:00
{
2024-09-18 04:21:17 +08:00
public class PartySettingsPacket : Packet
2024-09-16 17:09:36 +08:00
{
2024-12-11 14:07:19 +08:00
// Name of the party
public string name { get; set; } = string.Empty;
// Party password
public string password { get; set; } = string.Empty;
// Party comments
public string comments { get; set; } = string.Empty;
// Minimum acceptable level
public byte min_level { get; set; } = 0;
// Maximum acceptable level
public byte max_level { get; set; } = 0;
// Party playstyle
public byte playstyle { get; set; } = 0;
// Party flags
public PartyFlags flags { get; set; } = new PartyFlags();
// Unknown field, presumably a 64-bit unsigned integer
public ulong unk { get; set; } = 0;
2024-09-16 17:09:36 +08:00
2024-09-18 04:21:17 +08:00
public PartySettingsPacket()
2024-09-16 17:09:36 +08:00
{
2024-12-11 14:07:19 +08:00
// 初始化默认值
}
public PartySettingsPacket(PartySettingsPacket packet)
{
name = packet.name;
password = packet.password;
comments = packet.comments;
min_level = packet.min_level;
max_level = packet.max_level;
playstyle = packet.playstyle;
flags = packet.flags;
unk = packet.unk;
}
public PartySettingsPacket(string name, string password, string comments, byte minLevel, byte maxLevel, byte playstyle, PartyFlags flags, ulong unk)
{
this.name = name;
this.password = password;
this.comments = comments;
min_level = minLevel;
max_level = maxLevel;
this.playstyle = playstyle;
this.flags = flags;
this.unk = unk;
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.WriteUtf16(name, 0x9789, 0xE3);
pkt.WriteUtf16(password, 0x9789, 0xE3);
pkt.WriteUtf16(comments, 0x9789, 0xE3);
pkt.Write(min_level);
pkt.Write(max_level);
pkt.Write(playstyle);
pkt.WriteEnum(flags);
pkt.Write(unk);
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(0x0E, 0x0D, PacketFlags.PACKED);
2024-09-16 17:09:36 +08:00
}
#endregion
}
}