PSO2SERVER/Server/Protocol/Handlers/23-FlagHandler/23-02-SetFlagHandler.cs

40 lines
1.2 KiB
C#
Raw Normal View History

2024-09-21 12:35:09 +08:00
using System;
using PSO2SERVER.Models;
using PSO2SERVER.Protocol.Packets;
2024-09-21 12:35:09 +08:00
using static PSO2SERVER.Models.Flags;
namespace PSO2SERVER.Protocol.Handlers
2024-09-21 12:35:09 +08:00
{
[PacketHandlerAttr(0x23, 0x02)]
2024-12-03 13:18:58 +08:00
public class SetFlagHandler : PacketHandler
2024-09-21 12:35:09 +08:00
{
public struct SetFlagPacket
{
/// Flag type.
public FlagType flag_type { get; set; }
/// Flag ID.
public uint id { get; set; }
/// Flag value.
public uint value { get; set; }
}
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
if (context._account == null || context.Character == null)
return;
2024-09-22 00:08:44 +08:00
//var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
2024-09-21 15:40:13 +08:00
//Logger.WriteHex(info, data);
2024-09-21 12:35:09 +08:00
var reader = new PacketReader(data);
var flag = reader.ReadStruct<SetFlagPacket>();
2024-09-21 15:40:13 +08:00
2024-09-22 00:08:44 +08:00
if(context._flags == null)
context._flags = new Flags();
2024-09-21 15:40:13 +08:00
if (flag.flag_type == FlagType.Account)
context._flags.Set((int)flag.id, (byte)flag.value);
2024-09-21 12:35:09 +08:00
}
}
}