using Org.BouncyCastle.Bcpg; using Org.BouncyCastle.Utilities.Encoders; using PSO2SERVER.Models; using PSO2SERVER.Protocol.Packets; using System; using System.Collections.Generic; using System.Linq; using System.Security.Policy; using System.Text; using System.Threading.Tasks; using static PSO2SERVER.Protocol.Handlers.CharacterSelected; using static PSO2SERVER.Protocol.Packets.QuestDifficultyPacket; namespace PSO2SERVER.Protocol.Handlers { [PacketHandlerAttr(0x0B, 0x19)] class QuestDifficultyRequestHandler : PacketHandler { /// List of objects of requested quests. public List Quests { get; set; } = new List(); public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { var info = string.Format("[<--] 接收到的数据 (hex): {0}字节", data.Length); Logger.WriteHex(info, data); var reader = new PacketReader(data, position, size); Quests = reader.ReadList(); // 现在可以对任务列表(Quests)进行处理 // 例如,可以记录任务的信息或进行其他处理 foreach (var quest in Quests) { if(quest.ObjectType == ObjectType.Quest) { QuestDifficulty[] diffs = new QuestDifficulty[1]; for (int i = 0; i < diffs.Length; i++) { diffs[i].dateOrSomething = "2017/2/20"; diffs[i].quest_obj.ID = quest.ID; diffs[i].quest_obj.padding = 0; diffs[i].quest_obj.ObjectType = ObjectType.Quest; diffs[i].name_id = 30010; diffs[i].area = 0x01; diffs[i].planet = 0x03; diffs[i].unk1 = 0x03; diffs[i].unk2 = 0x00; diffs[i].difficulty1 = new QuestDifficultyEntry(); diffs[i].difficulty2 = new QuestDifficultyEntry(); diffs[i].difficulty3 = new QuestDifficultyEntry(); diffs[i].difficulty4 = new QuestDifficultyEntry(); diffs[i].difficulty5 = new QuestDifficultyEntry(); diffs[i].difficulty6 = new QuestDifficultyEntry(); diffs[i].difficulty7 = new QuestDifficultyEntry(); diffs[i].difficulty8 = new QuestDifficultyEntry(); } // 打印每个任务的 ID 和类型,方便调试 Logger.Write($"任务 ID: {quest.ID}, 任务类型: {quest.ObjectType}"); context.SendPacket(new QuestDifficultyPacket(diffs)); } } // [K873] I believe this is the correct packet, but it causes an infinite send/recieve loop, we're probably just missing something else context.SendPacket(new QuestDifficultySendFinishedPacket()); } } }