From 15b8a44d211d71aee9e231baff7cc6d694ced298 Mon Sep 17 00:00:00 2001 From: Sancaros Date: Sun, 29 Dec 2024 17:07:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E6=9C=AA=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E5=88=86=E6=9E=90=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8C=85=E6=9A=82=E6=97=B6=E9=87=87=E7=94=A8=E5=81=87=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BD=BD=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/Database/ServerEf.cs | 2 + .../03-24-LoadingLevelPacket.cs | 6 +- .../11-03-CharacterListPacket.cs | 70 ++++++++++++++----- .../21-01-LoadPalettePacket.cs | 28 ++++---- .../21-03-FullPaletteInfoPacket.cs | 5 +- 5 files changed, 78 insertions(+), 33 deletions(-) diff --git a/Server/Database/ServerEf.cs b/Server/Database/ServerEf.cs index 51d0fe3..0f09a03 100644 --- a/Server/Database/ServerEf.cs +++ b/Server/Database/ServerEf.cs @@ -157,6 +157,8 @@ namespace PSO2SERVER.Database } } + public uint Playe_time { get; set; } + public byte[] BuildCharacterByteArray() { PacketWriter writer = new PacketWriter(); diff --git a/Server/Protocol/Packets/03-ServerPacket/03-24-LoadingLevelPacket.cs b/Server/Protocol/Packets/03-ServerPacket/03-24-LoadingLevelPacket.cs index 693cbab..f43f5d7 100644 --- a/Server/Protocol/Packets/03-ServerPacket/03-24-LoadingLevelPacket.cs +++ b/Server/Protocol/Packets/03-ServerPacket/03-24-LoadingLevelPacket.cs @@ -84,8 +84,10 @@ namespace PSO2SERVER.Protocol.Packets public override byte[] Build() { - var setAreaPacket = File.ReadAllBytes("Resources\\quests\\" + _file + ".bin"); - return setAreaPacket; + var pkt = new PacketWriter(); + 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() diff --git a/Server/Protocol/Packets/11-ClientPacket/11-03-CharacterListPacket.cs b/Server/Protocol/Packets/11-ClientPacket/11-03-CharacterListPacket.cs index 614b810..f0cb5f3 100644 --- a/Server/Protocol/Packets/11-ClientPacket/11-03-CharacterListPacket.cs +++ b/Server/Protocol/Packets/11-ClientPacket/11-03-CharacterListPacket.cs @@ -22,13 +22,13 @@ namespace PSO2SERVER.Protocol.Packets public List EquippedItems { get; set; } = new List(); // Character play times (30 times) - public uint[] PlayTimes { get; set; } = new uint[30]; + public List PlayTimes { get; set; } = new List(); // 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)) - 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) public ushort AccountAccessory { get; set; } @@ -56,6 +56,14 @@ namespace PSO2SERVER.Protocol.Packets public CharacterListPacket(int AccountId) { + Characters = new List(); + EquippedItems = new List(); + PlayTimes = new List(); + DeletionFlags = new List<(uint, uint)>(); + TransferFlags = new List<(uint, uint)>(); + AccountAccessory = 0; + LoginSurvey = 0; + Ad = 0; this.AccountId = AccountId; } @@ -74,12 +82,6 @@ namespace PSO2SERVER.Protocol.Packets { Characters.Add(ch); - //// 创建一个 Consumable 类型的物品 - //PSO2ItemConsumable consumableItem = new PSO2ItemConsumable - //{ - // amount = 10, - //}; - //PSO2Items[] items = new PSO2Items[10]; //for (var i = 0; i < 10; i++) @@ -93,13 +95,33 @@ namespace PSO2SERVER.Protocol.Packets // Id = 1, // 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(); @@ -109,9 +131,19 @@ namespace PSO2SERVER.Protocol.Packets for (var i = 0; i < rest_count; i++) { - //Character character = 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(); @@ -130,7 +162,7 @@ namespace PSO2SERVER.Protocol.Packets //{ // foreach (var item in itemsArray) // { - // pkt.WriteStruct(item); + // pkt.Write(item.ToByteArray()); // } //} //// Write PlayTimes @@ -138,6 +170,9 @@ namespace PSO2SERVER.Protocol.Packets //{ // pkt.Write(playTime); //} + + //pkt.WriteBytes(0, 32); + //// Write DeletionFlags //foreach (var flag in DeletionFlags) //{ @@ -154,14 +189,17 @@ namespace PSO2SERVER.Protocol.Packets //// Write AccountAccessory //pkt.Write(AccountAccessory); + //pkt.WriteBytes(0, 6); + //// Write LoginSurvey //pkt.Write(LoginSurvey); //// Write Ad //pkt.Write(Ad); - //pkt.WriteBytes(0, 2); + //pkt.WriteBytes(0, 4); + //pkt.WriteBytes(0, 4); return pkt.ToArray(); } diff --git a/Server/Protocol/Packets/21-PalettePacket/21-01-LoadPalettePacket.cs b/Server/Protocol/Packets/21-PalettePacket/21-01-LoadPalettePacket.cs index ecf284b..553ac30 100644 --- a/Server/Protocol/Packets/21-PalettePacket/21-01-LoadPalettePacket.cs +++ b/Server/Protocol/Packets/21-PalettePacket/21-01-LoadPalettePacket.cs @@ -1,4 +1,5 @@ using PSO2SERVER.Models; +using System.IO; using static PSO2SERVER.Models.PSOPalette; namespace PSO2SERVER.Protocol.Packets @@ -35,21 +36,21 @@ namespace PSO2SERVER.Protocol.Packets public override byte[] Build() { var pkt = new PacketWriter(); - pkt.Write(CurPalette); - pkt.Write(CurSubpalette); - pkt.Write(CurBook); + //pkt.Write(CurPalette); + //pkt.Write(CurSubpalette); + //pkt.Write(CurBook); - // 初始化 Palettes - for (int i = 0; i < Palettes.Length; i++) - { - Palettes[i].WriteToStream(pkt); - } + //// 初始化 Palettes + //for (int i = 0; i < Palettes.Length; i++) + //{ + // Palettes[i].WriteToStream(pkt); + //} - // 初始化 Subpalettes(根据需要可以进行自定义初始化) - for (int i = 0; i < Subpalettes.Length; i++) - { - Subpalettes[i].WriteToStream(pkt); - } + //// 初始化 Subpalettes(根据需要可以进行自定义初始化) + //for (int i = 0; i < Subpalettes.Length; i++) + //{ + // Subpalettes[i].WriteToStream(pkt); + //} //// Enable flag //pkt.Write((byte) 1); @@ -58,6 +59,7 @@ namespace PSO2SERVER.Protocol.Packets //for (var i = 0; i < 1091; i++) // pkt.Write((byte) 0); + pkt.Write(File.ReadAllBytes("packets/0000_10_45_17_271399100.bin")); return pkt.ToArray(); } diff --git a/Server/Protocol/Packets/21-PalettePacket/21-03-FullPaletteInfoPacket.cs b/Server/Protocol/Packets/21-PalettePacket/21-03-FullPaletteInfoPacket.cs index 807f4ed..19b4a26 100644 --- a/Server/Protocol/Packets/21-PalettePacket/21-03-FullPaletteInfoPacket.cs +++ b/Server/Protocol/Packets/21-PalettePacket/21-03-FullPaletteInfoPacket.cs @@ -22,8 +22,9 @@ namespace PSO2SERVER.Protocol.Packets public override byte[] Build() { var pkt = new PacketWriter(); - Palette.WriteToStream(pkt); - byte[] byteArray = pkt.ToArray(); + pkt.Write(File.ReadAllBytes("packets/0000_10_45_16_531893700.bin")); + //Palette.WriteToStream(pkt); + //byte[] byteArray = pkt.ToArray(); //var info = string.Format("[-->] 发送的数据 (hex): {0} 字节", byteArray.Length); //Logger.WriteHex(info, byteArray);