PSO2SERVER/Server/Protocol/Handlers/23-FlagHandler/23-02-SetFlagHandler.cs
2024-11-27 18:05:53 +08:00

40 lines
1.2 KiB
C#

using System;
using PSO2SERVER.Models;
using PSO2SERVER.Protocol.Packets;
using static PSO2SERVER.Models.Flags;
namespace PSO2SERVER.Protocol.Handlers
{
[PacketHandlerAttr(0x23, 0x02)]
class SetFlagHandler : PacketHandler
{
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;
//var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
//Logger.WriteHex(info, data);
var reader = new PacketReader(data);
var flag = reader.ReadStruct<SetFlagPacket>();
if(context._flags == null)
context._flags = new Flags();
if (flag.flag_type == FlagType.Account)
context._flags.Set((int)flag.id, (byte)flag.value);
}
}
}