修正数据包

This commit is contained in:
Longfeng Qin 2024-11-24 23:52:52 +08:00
parent 3e74d13348
commit 89465c789c
3 changed files with 16 additions and 18 deletions

View File

@ -9,10 +9,13 @@ using System.Linq;
namespace PSO2SERVER.Packets.Handlers
{
[PacketHandlerAttr(0x11, 0x9B)]
class CharacterNewNameRequestPacket : PacketHandler
class CharacterNewNameRequest : PacketHandler
{
public uint player_id { get; set; }
public string Name { get; set; }
public struct CharacterNewNameRequestPacket
{
public uint player_id;
public string Name;
}
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
@ -22,9 +25,13 @@ namespace PSO2SERVER.Packets.Handlers
if (context._account == null)
return;
// 创建一个结构体实例
var packet = new CharacterNewNameRequestPacket();
// 读取数据并填充到结构体中
var reader = new PacketReader(data, position, size);
player_id = reader.ReadUInt32();
Name = reader.ReadFixedLengthUtf16(16);
packet.player_id = reader.ReadUInt32();
packet.Name = reader.ReadFixedLengthUtf16(16); // 读取16字节长度的名字
NewNameStatus isdone = NewNameStatus.Failure;
@ -40,7 +47,7 @@ namespace PSO2SERVER.Packets.Handlers
if (character != null)
{
// 确保名字不为空并且是16字节长度
character.Name = Name; // 用0填充至16字节
character.Name = packet.Name.PadRight(16, '\0'); // 确保名字是16字节
db.SaveChanges(); // 保存修改
isdone = NewNameStatus.Success;
}
@ -48,7 +55,7 @@ namespace PSO2SERVER.Packets.Handlers
}
context.SendPacket(new CharacterNewNamePacket(isdone, player_id, Name));
context.SendPacket(new CharacterNewNamePacket(isdone, packet.player_id, packet.Name));
}
}
}

View File

@ -8,13 +8,8 @@ namespace PSO2SERVER.Packets.PSOPackets
{
public class LoadingScreenTransitionPacket : Packet
{
private readonly byte _subtype;
private readonly byte _type;
public LoadingScreenTransitionPacket()
{
_type = 0x03;
_subtype = 0x04;
}
#region implemented abstract members of Packet
@ -26,11 +21,7 @@ namespace PSO2SERVER.Packets.PSOPackets
public override PacketHeader GetHeader()
{
return new PacketHeader
{
Type = _type,
Subtype = _subtype
};
return new PacketHeader(0x03, 0x04, PacketFlags.None);
}
#endregion

View File

@ -198,7 +198,7 @@
<Compile Include="Packets\Handlers\0E-PartyHandler\0E-29-PlayerIsNotBusyState.cs" />
<Compile Include="Packets\Handlers\0E-PartyHandler\0E-28-PlayerIsBusyState.cs" />
<Compile Include="Packets\Handlers\0E-PartyHandler\0E-19-ChatStatusHandler.cs" />
<Compile Include="Packets\Handlers\11-ClientHandler\11-9B-CharacterNewNameRequestPacket.cs" />
<Compile Include="Packets\Handlers\11-ClientHandler\11-9B-CharacterNewNameRequest.cs" />
<Compile Include="Packets\Handlers\11-ClientHandler\11-97-CharacterRenameRequest.cs" />
<Compile Include="Packets\Handlers\11-ClientHandler\11-BC-CharacterShipTransferCanceldRequest.cs" />
<Compile Include="Packets\Handlers\11-ClientHandler\11-B8-CharacterShipTransferRightsRequest.cs" />