未完成角色列表数据包结构修复

This commit is contained in:
Longfeng Qin 2024-12-12 11:30:25 +08:00
parent 8ee0076763
commit 575d060422
3 changed files with 34 additions and 31 deletions

View File

@ -39,7 +39,7 @@ namespace PSO2SERVER.Json
// 获取所有公共属性 // 获取所有公共属性
PropertyInfo[] properties = type.GetProperties(); PropertyInfo[] properties = type.GetProperties();
Console.WriteLine("Properties:"); Logger.Write("属性:");
foreach (var property in properties) foreach (var property in properties)
{ {
// 获取属性的值 // 获取属性的值
@ -49,7 +49,7 @@ namespace PSO2SERVER.Json
// 获取所有字段(包括私有字段) // 获取所有字段(包括私有字段)
FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public); FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
Console.WriteLine("\nFields:"); Logger.Write("\n字段:");
foreach (var field in fields) foreach (var field in fields)
{ {
// 获取字段的值 // 获取字段的值

View File

@ -40,7 +40,7 @@ namespace PSO2SERVER.Protocol.Packets
entries[i].sublevel = (byte)character.Jobs.entries.hunter.level2; entries[i].sublevel = (byte)character.Jobs.entries.hunter.level2;
entries[i].mainClass = character.Jobs.mainClass; entries[i].mainClass = character.Jobs.mainClass;
entries[i].subClass = character.Jobs.subClass; entries[i].subClass = character.Jobs.subClass;
entries[i].color = Clients[0].currentParty.AddColor(i); entries[i].color = (PartyColor)i;
entries[i].unk2 = 0; entries[i].unk2 = 0;
entries[i].mapid = 0; entries[i].mapid = 0;
entries[i].unk3 = 0; entries[i].unk3 = 0;

View File

@ -12,6 +12,8 @@ namespace PSO2SERVER.Protocol.Packets
{ {
public class CharacterListPacket : Packet public class CharacterListPacket : Packet
{ {
public uint Characters_count { get; set; } = 0;
public uint unk1 { get; set; } = 0;
// Available characters // Available characters
public List<Character> Characters { get; set; } = new List<Character>(); public List<Character> Characters { get; set; } = new List<Character>();
@ -96,12 +98,14 @@ namespace PSO2SERVER.Protocol.Packets
EquippedItems.Add(ch.EquipedItems); EquippedItems.Add(ch.EquipedItems);
} }
Characters_count = (uint)Characters.Count();
} }
var pkt = new PacketWriter(); var pkt = new PacketWriter();
pkt.Write((uint)Characters.Count()); // 写入玩家数量 pkt.Write(Characters_count); // 写入玩家数量
pkt.Write((uint)0); pkt.Write(unk1);
foreach (var ch in Characters) foreach (var ch in Characters)
{ {
pkt.Write((uint)0); pkt.Write((uint)0);
@ -113,38 +117,37 @@ namespace PSO2SERVER.Protocol.Packets
{ {
foreach (var item in itemsArray) foreach (var item in itemsArray)
{ {
byte[] itemBytes = item.ToByteArray(); // Assume PSO2Items has a ToByteArray method pkt.WriteStruct(item);
pkt.Write(itemBytes); // Write the item bytes
} }
} }
// Write PlayTimes //// Write PlayTimes
foreach (var playTime in PlayTimes) //foreach (var playTime in PlayTimes)
{ //{
pkt.Write(playTime); // pkt.Write(playTime);
} //}
// Write DeletionFlags //// Write DeletionFlags
foreach (var flag in DeletionFlags) //foreach (var flag in DeletionFlags)
{ //{
pkt.Write(flag.flag); // pkt.Write(flag.flag);
pkt.Write(flag.timestamp); // pkt.Write(flag.timestamp);
} //}
// Write TransferFlags //// Write TransferFlags
foreach (var flag in TransferFlags) //foreach (var flag in TransferFlags)
{ //{
pkt.Write(flag.flag); // pkt.Write(flag.flag);
pkt.Write(flag.timestamp); // pkt.Write(flag.timestamp);
} //}
// Write AccountAccessory //// Write AccountAccessory
pkt.Write(AccountAccessory); //pkt.Write(AccountAccessory);
// 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, 2);
return pkt.ToArray(); return pkt.ToArray();