部分未完成结构分析的数据包暂时采用假数据载入

This commit is contained in:
Sancaros 2024-12-29 17:07:20 +08:00
parent cf622beedc
commit 15b8a44d21
5 changed files with 78 additions and 33 deletions

View File

@ -157,6 +157,8 @@ namespace PSO2SERVER.Database
} }
} }
public uint Playe_time { get; set; }
public byte[] BuildCharacterByteArray() public byte[] BuildCharacterByteArray()
{ {
PacketWriter writer = new PacketWriter(); PacketWriter writer = new PacketWriter();

View File

@ -84,8 +84,10 @@ namespace PSO2SERVER.Protocol.Packets
public override byte[] Build() public override byte[] Build()
{ {
var setAreaPacket = File.ReadAllBytes("Resources\\quests\\" + _file + ".bin"); var pkt = new PacketWriter();
return setAreaPacket; pkt.Write(File.ReadAllBytes("packets/0400_10_45_16_560940600.bin"));
//var setAreaPacket = File.ReadAllBytes("Resources\\quests\\" + _file + ".bin");
return pkt.ToArray();
} }
public override PacketHeader GetHeader() public override PacketHeader GetHeader()

View File

@ -22,13 +22,13 @@ namespace PSO2SERVER.Protocol.Packets
public List<PSO2Items[]> EquippedItems { get; set; } = new List<PSO2Items[]>(); public List<PSO2Items[]> EquippedItems { get; set; } = new List<PSO2Items[]>();
// Character play times (30 times) // Character play times (30 times)
public uint[] PlayTimes { get; set; } = new uint[30]; public List<uint> PlayTimes { get; set; } = new List<uint>();
// Character deletion flags (flag, deletion timestamp) (30 pairs of (u32, u32)) // Character deletion flags (flag, deletion timestamp) (30 pairs of (u32, u32))
public (uint flag, uint timestamp)[] DeletionFlags { get; set; } = new (uint, uint)[30]; public List<(uint flag, uint timestamp)> DeletionFlags { get; set; } = new List<(uint, uint)>();
// Character ship transfer flags (30 pairs of (u32, u32)) // Character ship transfer flags (30 pairs of (u32, u32))
public (uint flag, uint timestamp)[] TransferFlags { get; set; } = new (uint, uint)[30]; public List<(uint flag, uint timestamp)> TransferFlags { get; set; } = new List<(uint, uint)>();
// Account accessory flag (unknown) // Account accessory flag (unknown)
public ushort AccountAccessory { get; set; } public ushort AccountAccessory { get; set; }
@ -56,6 +56,14 @@ namespace PSO2SERVER.Protocol.Packets
public CharacterListPacket(int AccountId) public CharacterListPacket(int AccountId)
{ {
Characters = new List<Character>();
EquippedItems = new List<PSO2Items[]>();
PlayTimes = new List<uint>();
DeletionFlags = new List<(uint, uint)>();
TransferFlags = new List<(uint, uint)>();
AccountAccessory = 0;
LoginSurvey = 0;
Ad = 0;
this.AccountId = AccountId; this.AccountId = AccountId;
} }
@ -74,12 +82,6 @@ namespace PSO2SERVER.Protocol.Packets
{ {
Characters.Add(ch); Characters.Add(ch);
//// 创建一个 Consumable 类型的物品
//PSO2ItemConsumable consumableItem = new PSO2ItemConsumable
//{
// amount = 10,
//};
//PSO2Items[] items = new PSO2Items[10]; //PSO2Items[] items = new PSO2Items[10];
//for (var i = 0; i < 10; i++) //for (var i = 0; i < 10; i++)
@ -93,13 +95,33 @@ namespace PSO2SERVER.Protocol.Packets
// Id = 1, // Id = 1,
// Subid = 0, // Subid = 0,
// }, // },
// data = new Items { Consumable = consumableItem } // data = new Items
// {
// Consumable = new PSO2ItemConsumable
// {
// flags = 0,
// amount = 10,
// },
// }
// }; // };
//} //}
ch.EquipedItems = new PSO2Items[10]; //ch.EquipedItems = items;
//EquippedItems.Add(ch.EquipedItems);
//ch.Playe_time = 0xFFFFFFFF;
//PlayTimes.Add(ch.Playe_time);
//var deletionFlags = (0, 0);
//DeletionFlags.Add(((uint flag, uint timestamp))deletionFlags);
//var transferFlags = (0, 0);
//TransferFlags.Add(((uint flag, uint timestamp))transferFlags);
EquippedItems.Add(ch.EquipedItems);
} }
Characters_count = (uint)Characters.Count(); Characters_count = (uint)Characters.Count();
@ -109,9 +131,19 @@ namespace PSO2SERVER.Protocol.Packets
for (var i = 0; i < rest_count; i++) for (var i = 0; i < rest_count; i++)
{ {
//Character character = Characters[0];
Characters.Add(Characters[0]); Characters.Add(Characters[0]);
EquippedItems.Add(EquippedItems[0]);
//EquippedItems.Add(EquippedItems[0]);
//PlayTimes.Add(0x12345678);
//var deletionFlags = (1, 3);
//DeletionFlags.Add(((uint flag, uint timestamp))deletionFlags);
//var transferFlags = (2, 4);
//TransferFlags.Add(((uint flag, uint timestamp))transferFlags);
} }
var pkt = new PacketWriter(); var pkt = new PacketWriter();
@ -130,7 +162,7 @@ namespace PSO2SERVER.Protocol.Packets
//{ //{
// foreach (var item in itemsArray) // foreach (var item in itemsArray)
// { // {
// pkt.WriteStruct(item); // pkt.Write(item.ToByteArray());
// } // }
//} //}
//// Write PlayTimes //// Write PlayTimes
@ -138,6 +170,9 @@ namespace PSO2SERVER.Protocol.Packets
//{ //{
// pkt.Write(playTime); // pkt.Write(playTime);
//} //}
//pkt.WriteBytes(0, 32);
//// Write DeletionFlags //// Write DeletionFlags
//foreach (var flag in DeletionFlags) //foreach (var flag in DeletionFlags)
//{ //{
@ -154,14 +189,17 @@ namespace PSO2SERVER.Protocol.Packets
//// Write AccountAccessory //// Write AccountAccessory
//pkt.Write(AccountAccessory); //pkt.Write(AccountAccessory);
//pkt.WriteBytes(0, 6);
//// Write LoginSurvey //// Write LoginSurvey
//pkt.Write(LoginSurvey); //pkt.Write(LoginSurvey);
//// Write Ad //// Write Ad
//pkt.Write(Ad); //pkt.Write(Ad);
//pkt.WriteBytes(0, 2); //pkt.WriteBytes(0, 4);
//pkt.WriteBytes(0, 4);
return pkt.ToArray(); return pkt.ToArray();
} }

View File

@ -1,4 +1,5 @@
using PSO2SERVER.Models; using PSO2SERVER.Models;
using System.IO;
using static PSO2SERVER.Models.PSOPalette; using static PSO2SERVER.Models.PSOPalette;
namespace PSO2SERVER.Protocol.Packets namespace PSO2SERVER.Protocol.Packets
@ -35,21 +36,21 @@ namespace PSO2SERVER.Protocol.Packets
public override byte[] Build() public override byte[] Build()
{ {
var pkt = new PacketWriter(); var pkt = new PacketWriter();
pkt.Write(CurPalette); //pkt.Write(CurPalette);
pkt.Write(CurSubpalette); //pkt.Write(CurSubpalette);
pkt.Write(CurBook); //pkt.Write(CurBook);
// 初始化 Palettes //// 初始化 Palettes
for (int i = 0; i < Palettes.Length; i++) //for (int i = 0; i < Palettes.Length; i++)
{ //{
Palettes[i].WriteToStream(pkt); // Palettes[i].WriteToStream(pkt);
} //}
// 初始化 Subpalettes根据需要可以进行自定义初始化 //// 初始化 Subpalettes根据需要可以进行自定义初始化
for (int i = 0; i < Subpalettes.Length; i++) //for (int i = 0; i < Subpalettes.Length; i++)
{ //{
Subpalettes[i].WriteToStream(pkt); // Subpalettes[i].WriteToStream(pkt);
} //}
//// Enable flag //// Enable flag
//pkt.Write((byte) 1); //pkt.Write((byte) 1);
@ -58,6 +59,7 @@ namespace PSO2SERVER.Protocol.Packets
//for (var i = 0; i < 1091; i++) //for (var i = 0; i < 1091; i++)
// pkt.Write((byte) 0); // pkt.Write((byte) 0);
pkt.Write(File.ReadAllBytes("packets/0000_10_45_17_271399100.bin"));
return pkt.ToArray(); return pkt.ToArray();
} }

View File

@ -22,8 +22,9 @@ namespace PSO2SERVER.Protocol.Packets
public override byte[] Build() public override byte[] Build()
{ {
var pkt = new PacketWriter(); var pkt = new PacketWriter();
Palette.WriteToStream(pkt); pkt.Write(File.ReadAllBytes("packets/0000_10_45_16_531893700.bin"));
byte[] byteArray = pkt.ToArray(); //Palette.WriteToStream(pkt);
//byte[] byteArray = pkt.ToArray();
//var info = string.Format("[-->] 发送的数据 (hex): {0} 字节", byteArray.Length); //var info = string.Format("[-->] 发送的数据 (hex): {0} 字节", byteArray.Length);
//Logger.WriteHex(info, byteArray); //Logger.WriteHex(info, byteArray);