From 01ba3e4b83336c6b929cfbaf1474fca4641843b2 Mon Sep 17 00:00:00 2001 From: Longfeng Qin Date: Sun, 8 Dec 2024 11:33:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Ejson=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/Config.cs | 2 +- Server/ConsoleSystem.cs | 8 +- Server/Database/ServerEf.cs | 2 +- Server/{Zone => Json}/MapJson.cs | 157 +++++++++--------- Server/Json/QuestJson.cs | 46 +++++ Server/Object/ObjectManager.cs | 2 +- Server/Party/PartyManager.cs | 2 +- Server/Program.cs | 16 +- .../04-07-MovementHandlers.cs | 4 +- .../04-08-MovementActionHandler.cs | 2 +- .../04-ObjectHandler/04-14-ObjectInteract.cs | 2 +- .../04-71-MovementEndHandler.cs | 2 +- .../0E-0C-QuestCounterHandler.cs | 4 +- .../23-0B-SkitItemAddRequest.cs | 2 +- .../03-24-LoadingLevelPacket.cs | 4 +- .../08-04-CharacterSpawnPacket.cs | 13 +- .../08-05-TransporterSpawnPacket.cs | 10 +- .../08-SpawnPacket/08-09-EventSpawnPacket.cs | 13 +- .../08-SpawnPacket/08-0B-ObjectSpawnPacket.cs | 11 +- .../08-SpawnPacket/08-0C-NPCSpawnPacket.cs | 13 +- .../08-SpawnPacket/08-0D-EnemySpawnPacket.cs | 10 +- .../0B-18-QuestCategoryPacket.cs | 2 +- .../0E-PartyPacket/0E-02-PartyInitPacket.cs | 2 +- .../0E-25-SetQuestInfoPacket.cs | 2 +- .../1C-1F-GuildInfoPacket.cs | 2 +- Server/Server.csproj | 3 +- Server/Zone/ZoneAdditional.cs | 2 +- 27 files changed, 227 insertions(+), 111 deletions(-) rename Server/{Zone => Json}/MapJson.cs (77%) create mode 100644 Server/Json/QuestJson.cs diff --git a/Server/Config.cs b/Server/Config.cs index 4a18204..d936e0a 100644 --- a/Server/Config.cs +++ b/Server/Config.cs @@ -22,7 +22,7 @@ namespace PSO2SERVER private readonly string _configFile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "config\\Server.cfg"; - // Settings + // settings [ConfigComment("服务器对外绑定的地址(支持域名或者IP,优先获取IPV4)")] public IPAddress BindAddress = IPAddress.Loopback; diff --git a/Server/ConsoleSystem.cs b/Server/ConsoleSystem.cs index 53de384..1caff39 100644 --- a/Server/ConsoleSystem.cs +++ b/Server/ConsoleSystem.cs @@ -243,7 +243,7 @@ namespace PSO2SERVER // Config var config = new ConsoleCommand(Config, "config", "c"); - config.Arguments.Add(new ConsoleCommandArgument("Save | Load | List | Option Name", false)); + config.Arguments.Add(new ConsoleCommandArgument("Save | Load | List | Option name", false)); config.Arguments.Add(new ConsoleCommandArgument("Value", true)); config.Help = "Set a configuration variable to the specified value"; Commands.Add(config); @@ -277,7 +277,7 @@ namespace PSO2SERVER // SpawnClone var spawnClone = new ConsoleCommand(SpawnClone, "spawnclone"); spawnClone.Arguments.Add(new ConsoleCommandArgument("Username", false)); - spawnClone.Arguments.Add(new ConsoleCommandArgument("Accounts Name", false)); + spawnClone.Arguments.Add(new ConsoleCommandArgument("Accounts name", false)); spawnClone.Arguments.Add(new ConsoleCommandArgument("X", false)); spawnClone.Arguments.Add(new ConsoleCommandArgument("Y", false)); spawnClone.Arguments.Add(new ConsoleCommandArgument("Z", false)); @@ -286,7 +286,7 @@ namespace PSO2SERVER // SendPacket var sendPacket = new ConsoleCommand(SendPacket, "sendpacket", "sendp"); - sendPacket.Arguments.Add(new ConsoleCommandArgument("Name", false)); + sendPacket.Arguments.Add(new ConsoleCommandArgument("name", false)); sendPacket.Arguments.Add(new ConsoleCommandArgument("Type", false)); sendPacket.Arguments.Add(new ConsoleCommandArgument("SubType", false)); sendPacket.Arguments.Add(new ConsoleCommandArgument("Flags", false)); @@ -507,7 +507,7 @@ namespace PSO2SERVER { var help = string.Empty; - // Name + // name help += command.Names[0]; // Arguments diff --git a/Server/Database/ServerEf.cs b/Server/Database/ServerEf.cs index 2ee51b8..49972a8 100644 --- a/Server/Database/ServerEf.cs +++ b/Server/Database/ServerEf.cs @@ -166,7 +166,7 @@ namespace PSO2SERVER.Database writer.Write((ushort)Unk2); writer.Write(VoicePitch); - // 序列化 Name (假设固定长度字符串16个字节,UTF-16 编码) + // 序列化 name (假设固定长度字符串16个字节,UTF-16 编码) writer.WriteFixedLengthUtf16(Name, 0x10); // 序列化 Looks diff --git a/Server/Zone/MapJson.cs b/Server/Json/MapJson.cs similarity index 77% rename from Server/Zone/MapJson.cs rename to Server/Json/MapJson.cs index 9dd7351..b9c1450 100644 --- a/Server/Zone/MapJson.cs +++ b/Server/Json/MapJson.cs @@ -1,13 +1,14 @@ using Newtonsoft.Json; using Org.BouncyCastle.Asn1.Pkcs; using PSO2SERVER.Protocol.Packets; +using PSO2SERVER.Zone; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace PSO2SERVER.Zone +namespace PSO2SERVER.Json { public class MapData { @@ -30,7 +31,7 @@ namespace PSO2SERVER.Zone public Dictionary Luas { get; set; } [JsonProperty("init_map")] - public uint InitMap { get; set; }//ZoneId + public uint InitMap { get; set; }//zone_id [JsonProperty("zones")] public List Zones { get; set; } @@ -52,30 +53,97 @@ namespace PSO2SERVER.Zone public class ObjectData { + [JsonProperty("zone_id")] public uint zone_id { get; set; } + [JsonProperty("is_active")] public bool is_active { get; set; } + [JsonProperty("data")] public ObjectSpawnPacket data { get; set; } + [JsonProperty("lua_data")] public string lua_data { get; set; } } + public class EventData + { + [JsonProperty("zone_id")] + public uint zone_id { get; set; } + [JsonProperty("is_active")] + public bool is_active { get; set; } + [JsonProperty("data")] + public EventSpawnPacket data { get; set; } + [JsonProperty("lua_data")] + public string lua_data { get; set; } + } + + public class NPCData + { + [JsonProperty("zone_id")] + public uint zone_id { get; set; } + [JsonProperty("is_active")] + public bool is_active { get; set; } + [JsonProperty("data")] + public NPCSpawnPacket data { get; set; } + [JsonProperty("lua_data")] + public string lua_data { get; set; } + } + + public class TransporterData + { + [JsonProperty("zone_id")] + public uint zone_id { get; set; } + [JsonProperty("is_active")] + public bool is_active { get; set; } + [JsonProperty("data")] + public TransporterSpawnPacket data { get; set; } + [JsonProperty("lua_data")] + public string lua_data { get; set; } + } + + public class EnemySpawn + { + public string EnemyName { get; set; } + public uint SpawnCategory { get; set; } + + // 默认构造函数 + public EnemySpawn() + { + EnemyName = string.Empty; + SpawnCategory = 0; + } + + // 带参构造函数 + public EnemySpawn(string enemyName, uint spawnCategory) + { + EnemyName = enemyName; + SpawnCategory = spawnCategory; + } + } + public class ZoneData { + [JsonProperty("name")] public string Name { get; set; } - public bool IsSpecialZone { get; set; } - public uint ZoneId { get; set; } + [JsonProperty("is_special_zone")] + public bool Is_special_zone { get; set; } + [JsonProperty("zone_id")] + public uint Zone_id { get; set; } + [JsonProperty("settings")] public ZoneSettings Settings { get; set; } - public PSOLocation DefaultLocation { get; set; } + [JsonProperty("default_location")] + public PSOLocation Default_location { get; set; } + [JsonProperty("enemies")] public List Enemies { get; set; } + [JsonProperty("chunks")] public List Chunks { get; set; } // 默认构造函数 public ZoneData() { Name = string.Empty; - IsSpecialZone = false; - ZoneId = new uint(); + Is_special_zone = false; + Zone_id = new uint(); Settings = new ZoneSettings(); - DefaultLocation = new PSOLocation(); + Default_location = new PSOLocation(); Enemies = new List(); Chunks = new List(); } @@ -83,9 +151,13 @@ namespace PSO2SERVER.Zone public class ZoneChunk { + [JsonProperty("zone_id")] public uint ZoneId { get; set; } + [JsonProperty("chunk_id")] public uint ChunkId { get; set; } + [JsonProperty("enemy_spawn_type")] public EnemySpawnType EnemySpawnType { get; set; } + [JsonProperty("enemy_spawn_points")] public List EnemySpawnPoints { get; set; } // 默认构造函数 @@ -133,73 +205,4 @@ namespace PSO2SERVER.Zone } public class Manual : EnemySpawnType { } - - public class EventData - { - public uint zone_id { get; set; } - public bool is_active { get; set; } - public EventSpawnPacket data { get; set; } - public string lua_data { get; set; } - } - - public class NPCData - { - public uint zone_id { get; set; } - public bool is_active { get; set; } - public NPCSpawnPacket data { get; set; } - public string lua_data { get; set; } - } - - public class TransporterData - { - public uint zone_id { get; set; } - public bool is_active { get; set; } - public TransporterSpawnPacket data { get; set; } - public string lua_data { get; set; } - } - - public class EnemySpawn - { - public string EnemyName { get; set; } - public uint SpawnCategory { get; set; } - - // 默认构造函数 - public EnemySpawn() - { - EnemyName = string.Empty; - SpawnCategory = 0; - } - - // 带参构造函数 - public EnemySpawn(string enemyName, uint spawnCategory) - { - EnemyName = enemyName; - SpawnCategory = spawnCategory; - } - } - - public class AutomaticEnemySpawn - { - public uint Min { get; set; } - public uint Max { get; set; } - - public AutomaticEnemySpawn() { } - public AutomaticEnemySpawn(uint min, uint max) - { - Min = min; - Max = max; - } - } - - public class AutomaticWithRespawnEnemySpawn : AutomaticEnemySpawn - { - public TimeSpan RespawnTime { get; set; } - - public AutomaticWithRespawnEnemySpawn() { } - public AutomaticWithRespawnEnemySpawn(uint min, uint max, TimeSpan respawnTime) - : base(min, max) - { - RespawnTime = respawnTime; - } - } } diff --git a/Server/Json/QuestJson.cs b/Server/Json/QuestJson.cs new file mode 100644 index 0000000..300b62f --- /dev/null +++ b/Server/Json/QuestJson.cs @@ -0,0 +1,46 @@ +using Newtonsoft.Json; +using PSO2SERVER.Models; +using PSO2SERVER.Protocol.Packets; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PSO2SERVER.Json +{ + public class QuestData + { + [JsonProperty("definition")] + public QuestDefiniton QuestDefiniton { get; set; } + [JsonProperty("difficulties")] + public QuestDifficulty Difficulty { get; set; } + [JsonProperty("map")] + public MapData Mapdata { get; set; } + [JsonProperty("enemies")] + public List Enemies { get; set; } + [JsonProperty("immediate_move")] + public bool ImmediateMove { get; set; } + + public QuestData() + { + QuestDefiniton = new QuestDefiniton(); + Difficulty = new QuestDifficulty(); + Mapdata = new MapData(); + Enemies = new List(); + ImmediateMove = false; + } + } + + public class EnemyData + { + [JsonProperty("difficulty")] + public ushort Difficulty { get; set; } + [JsonProperty("mapid")] + public uint mapid { get; set; } + [JsonProperty("data")] + public EnemySpawnPacket data { get; set; } + [JsonProperty("lua_data")] + public string lua_data { get; set; } + } +} diff --git a/Server/Object/ObjectManager.cs b/Server/Object/ObjectManager.cs index 6326738..5afe937 100644 --- a/Server/Object/ObjectManager.cs +++ b/Server/Object/ObjectManager.cs @@ -51,7 +51,7 @@ namespace PSO2SERVER.Object var newObject = PSOObject.FromDBObject(dbObject); objects.Add(newObject.Header.ID, newObject); allTheObjects.Add(newObject.Header.ID, newObject); - //Logger.WriteInternal("[OBJ] 从数据库中载入对象 {0} 所属区域 {1}.", newObject.Name, zone); + //Logger.WriteInternal("[OBJ] 从数据库中载入对象 {0} 所属区域 {1}.", newObject.name, zone); } } diff --git a/Server/Party/PartyManager.cs b/Server/Party/PartyManager.cs index 55d32ad..dc681b3 100644 --- a/Server/Party/PartyManager.cs +++ b/Server/Party/PartyManager.cs @@ -9,7 +9,7 @@ namespace PSO2SERVER.Party { public static readonly PartyManager instance = new PartyManager(); - public Dictionary parties = new Dictionary(); // Key: Party, Value: Name? (for now) + public Dictionary parties = new Dictionary(); // Key: Party, Value: name? (for now) public static PartyManager Instance { diff --git a/Server/Program.cs b/Server/Program.cs index baa0460..762c516 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -16,6 +16,7 @@ using Newtonsoft.Json.Linq; using Google.Protobuf.Compiler; using Newtonsoft.Json; using PSO2SERVER.Zone; +using PSO2SERVER.Json; namespace PSO2SERVER { @@ -101,7 +102,20 @@ namespace PSO2SERVER // 输出结果 Logger.Write($"map_object ID: {map.Mapdata.map_object.ID}"); Logger.Write($"Zones[0].Name: {map.Zones[0].Name}"); - Logger.Write($"Zones[0].IsSpecialZone: {map.Zones[0].IsSpecialZone}"); + Logger.Write($"Zones[0].Is_special_zone: {map.Zones[0].Is_special_zone}"); + + string jsonFilePath2 = "data\\maps\\lobby\\events\\main_lobby_1\\all_events.json"; + + // 读取 JSON 文件 + string json2 = File.ReadAllText(jsonFilePath2); + + // 反序列化为 C# 对象 + EventData map_event = JsonConvert.DeserializeObject>(json2).FirstOrDefault(); + + // 输出结果 + Logger.Write($"map_event zone_id: {map_event.zone_id}"); + Logger.Write($"map_event is_active: {map_event.is_active}"); + Logger.Write($"map_event objName: {map_event.data.objName}"); try { diff --git a/Server/Protocol/Handlers/04-ObjectHandler/04-07-MovementHandlers.cs b/Server/Protocol/Handlers/04-ObjectHandler/04-07-MovementHandlers.cs index 9c3c3d3..0b6f96c 100644 --- a/Server/Protocol/Handlers/04-ObjectHandler/04-07-MovementHandlers.cs +++ b/Server/Protocol/Handlers/04-ObjectHandler/04-07-MovementHandlers.cs @@ -24,7 +24,7 @@ namespace PSO2SERVER.Protocol.Handlers PackedData theFlags = (PackedData)dataFlags; // Debug - //Logger.WriteInternal("[移动] Movement 数据包来自 {0} 包含 {1} 数据.", context.Character.Name, theFlags); + //Logger.WriteInternal("[移动] Movement 数据包来自 {0} 包含 {1} 数据.", context.Character.name, theFlags); // TODO: Maybe do this better someday MovementPacket.FullMovementData dstData = new MovementPacket.FullMovementData(); @@ -129,7 +129,7 @@ namespace PSO2SERVER.Protocol.Handlers } - //Logger.WriteInternal("[移动] 玩家 {0} 移动中 (坐标: X{1}, Y{2}, Z{3})", context.Character.Name, context.CurrentLocation.PosX, + //Logger.WriteInternal("[移动] 玩家 {0} 移动中 (坐标: X{1}, Y{2}, Z{3})", context.Character.name, context.CurrentLocation.PosX, //context.CurrentLocation.PosY, context.CurrentLocation.PosZ); foreach (var c in Server.Instance.Clients) diff --git a/Server/Protocol/Handlers/04-ObjectHandler/04-08-MovementActionHandler.cs b/Server/Protocol/Handlers/04-ObjectHandler/04-08-MovementActionHandler.cs index e7d3ddb..c099c12 100644 --- a/Server/Protocol/Handlers/04-ObjectHandler/04-08-MovementActionHandler.cs +++ b/Server/Protocol/Handlers/04-ObjectHandler/04-08-MovementActionHandler.cs @@ -30,7 +30,7 @@ namespace PSO2SERVER.Protocol.Handlers byte[] final = reader.ReadBytes(4); - //Logger.WriteInternal("[动作] {0} 发送动作 {1}", context.Character.Name, command); + //Logger.WriteInternal("[动作] {0} 发送动作 {1}", context.Character.name, command); foreach (var c in Server.Instance.Clients) { diff --git a/Server/Protocol/Handlers/04-ObjectHandler/04-14-ObjectInteract.cs b/Server/Protocol/Handlers/04-ObjectHandler/04-14-ObjectInteract.cs index 2fdc492..63e490d 100644 --- a/Server/Protocol/Handlers/04-ObjectHandler/04-14-ObjectInteract.cs +++ b/Server/Protocol/Handlers/04-ObjectHandler/04-14-ObjectInteract.cs @@ -40,7 +40,7 @@ namespace PSO2SERVER.Protocol.Handlers srcObj = null; } - //Logger.WriteInternal("[OBJ] {0} (ID {1}) <{2}> --> Ent {3} (ID {4})", srcObj.Name, srcObj.Header.ID, command, (ObjectType)dstObject.ObjectType, dstObject.ID); + //Logger.WriteInternal("[OBJ] {0} (ID {1}) <{2}> --> Ent {3} (ID {4})", srcObj.name, srcObj.Header.ID, command, (ObjectType)dstObject.ObjectType, dstObject.ID); // TODO: Delete this code and do this COMPLETELY correctly!!! if (command == "Transfer" && context.CurrentZone.Name == "lobby") diff --git a/Server/Protocol/Handlers/04-ObjectHandler/04-71-MovementEndHandler.cs b/Server/Protocol/Handlers/04-ObjectHandler/04-71-MovementEndHandler.cs index 8d8ab57..43203ba 100644 --- a/Server/Protocol/Handlers/04-ObjectHandler/04-71-MovementEndHandler.cs +++ b/Server/Protocol/Handlers/04-ObjectHandler/04-71-MovementEndHandler.cs @@ -24,7 +24,7 @@ namespace PSO2SERVER.Protocol.Handlers movData.timestamp = 0; - //Logger.WriteInternal("[移动] 玩家 {0} 停止移动 (坐标:{1}, {2}, {3})", context.Character.Name, + //Logger.WriteInternal("[移动] 玩家 {0} 停止移动 (坐标:{1}, {2}, {3})", context.Character.name, // Helper.FloatFromHalfPrecision(movData.currentPos.x), Helper.FloatFromHalfPrecision(movData.currentPos.y), // Helper.FloatFromHalfPrecision(movData.currentPos.z)); diff --git a/Server/Protocol/Handlers/0E-PartyHandler/0E-0C-QuestCounterHandler.cs b/Server/Protocol/Handlers/0E-PartyHandler/0E-0C-QuestCounterHandler.cs index 829bb76..b921ad6 100644 --- a/Server/Protocol/Handlers/0E-PartyHandler/0E-0C-QuestCounterHandler.cs +++ b/Server/Protocol/Handlers/0E-PartyHandler/0E-0C-QuestCounterHandler.cs @@ -34,10 +34,10 @@ namespace PSO2SERVER.Protocol.Handlers partyFlags = (PartyFlags)reader.ReadByte(); unk = reader.ReadUInt64(); // 打印输出 - Logger.Write($"Name: {name}"); + Logger.Write($"name: {name}"); Logger.Write($"Password: {password}"); Logger.Write($"Comments: {comments}"); - Logger.Write($"Quest Name: {questname}"); + Logger.Write($"Quest name: {questname}"); Logger.Write($"Min Level: {min_level}"); Logger.Write($"Max Level: {max_level}"); Logger.Write($"Playstyle: {playstyle}"); diff --git a/Server/Protocol/Handlers/23-FlagHandler/23-0B-SkitItemAddRequest.cs b/Server/Protocol/Handlers/23-FlagHandler/23-0B-SkitItemAddRequest.cs index 9be5791..796bdf1 100644 --- a/Server/Protocol/Handlers/23-FlagHandler/23-0B-SkitItemAddRequest.cs +++ b/Server/Protocol/Handlers/23-FlagHandler/23-0B-SkitItemAddRequest.cs @@ -53,7 +53,7 @@ namespace PSO2SERVER.Protocol.Handlers var packet = new SkitItemAddRequestPacket(Encoding.ASCII.GetString(skitNameBytes).TrimEnd('\0'), unk); // 打印处理结果(仅作示例) - Console.WriteLine("Skit Name: " + packet.GetSkitName()); + Console.WriteLine("Skit name: " + packet.GetSkitName()); Console.WriteLine("Unk Value: " + packet.unk); context.SendPacket(new SkitItemAddResponsePacket(packet.GetSkitName(), packet.unk)); diff --git a/Server/Protocol/Packets/03-ServerPacket/03-24-LoadingLevelPacket.cs b/Server/Protocol/Packets/03-ServerPacket/03-24-LoadingLevelPacket.cs index 20d819b..693cbab 100644 --- a/Server/Protocol/Packets/03-ServerPacket/03-24-LoadingLevelPacket.cs +++ b/Server/Protocol/Packets/03-ServerPacket/03-24-LoadingLevelPacket.cs @@ -16,13 +16,13 @@ namespace PSO2SERVER.Protocol.Packets public ObjectHeader map_object { get; set; } = new ObjectHeader(); /// Receiving player. public ObjectHeader receiver { get; set; } = new ObjectHeader(); - /// Settings for the initial zone (i.e. first zone that the player will appear in). + /// settings for the initial zone (i.e. first zone that the player will appear in). public ZoneSettings settings { get; set; } = new ZoneSettings(); public byte[] unk4 { get; set; } = new byte[0x0C]; public byte[] unk5 { get; set; } = new byte[0x0C]; public byte[] unk6 { get; set; } = new byte[0x0C]; public string unk7 { get; set; } = string.Empty;//Ascii - /// Settings for other zones. + /// settings for other zones. public List other_settings { get; set; } = new List(); public List warps { get; set; } = new List(); public List unk10 { get; set; } = new List(); diff --git a/Server/Protocol/Packets/08-SpawnPacket/08-04-CharacterSpawnPacket.cs b/Server/Protocol/Packets/08-SpawnPacket/08-04-CharacterSpawnPacket.cs index cc40281..25a896d 100644 --- a/Server/Protocol/Packets/08-SpawnPacket/08-04-CharacterSpawnPacket.cs +++ b/Server/Protocol/Packets/08-SpawnPacket/08-04-CharacterSpawnPacket.cs @@ -1,4 +1,5 @@ -using PSO2SERVER.Database; +using Newtonsoft.Json; +using PSO2SERVER.Database; using PSO2SERVER.Models; using PSO2SERVER.Zone; using System.IO; @@ -28,10 +29,14 @@ namespace PSO2SERVER.Protocol.Packets /// CharacterSpawnPacket Struct /// /// Spawned character's player object. + [JsonProperty("object")] public ObjectHeader ObjHeader { get; set; } = new ObjectHeader(); + [JsonProperty("position")] public PSOLocation ObjPosition { get; set; } = new PSOLocation(); + [JsonProperty("unk1")] public ushort Unk1 { get; set; } = 0; - /// Always `Character`. (?) + /// Enemy name. + [JsonProperty("name")] public string ObjName { get; set; } = "Character";//Ascii 0x20 public ushort Unk3 { get; set; } = 1; public ushort Unk4 { get; set; } @@ -53,6 +58,10 @@ namespace PSO2SERVER.Protocol.Packets //#[SeekAfter(0x60)] public byte[] Unk12 { get; set; } = new byte[0x40]; + public CharacterSpawnPacket() + { + } + public CharacterSpawnPacket(Character character, PSOLocation locatiion) { ObjHeader = new ObjectHeader((uint)character.Account.AccountId, ObjectType.Player); diff --git a/Server/Protocol/Packets/08-SpawnPacket/08-05-TransporterSpawnPacket.cs b/Server/Protocol/Packets/08-SpawnPacket/08-05-TransporterSpawnPacket.cs index 08395d6..e9a4a12 100644 --- a/Server/Protocol/Packets/08-SpawnPacket/08-05-TransporterSpawnPacket.cs +++ b/Server/Protocol/Packets/08-SpawnPacket/08-05-TransporterSpawnPacket.cs @@ -1,4 +1,5 @@ -using PSO2SERVER.Models; +using Newtonsoft.Json; +using PSO2SERVER.Models; using PSO2SERVER.Zone; using System; using System.Collections.Generic; @@ -9,10 +10,13 @@ namespace PSO2SERVER.Protocol.Packets { public class TransporterSpawnPacket : Packet { + [JsonProperty("object")] public ObjectHeader objHeader { get; set; } = new ObjectHeader(); + [JsonProperty("position")] public PSOLocation objPosition { get; set; } = new PSOLocation(); public ushort unk1 { get; set; } = 0; /// Enemy name. + [JsonProperty("name")] public string objName { get; set; } = string.Empty;//0x20 public uint unk2 { get; set; } = 0; public ushort unk3 { get; set; } = 0; @@ -30,6 +34,10 @@ namespace PSO2SERVER.Protocol.Packets objName = obj.Name; } + public TransporterSpawnPacket() + { + } + #region implemented abstract members of Packet public override byte[] Build() diff --git a/Server/Protocol/Packets/08-SpawnPacket/08-09-EventSpawnPacket.cs b/Server/Protocol/Packets/08-SpawnPacket/08-09-EventSpawnPacket.cs index 3ad35b7..f401538 100644 --- a/Server/Protocol/Packets/08-SpawnPacket/08-09-EventSpawnPacket.cs +++ b/Server/Protocol/Packets/08-SpawnPacket/08-09-EventSpawnPacket.cs @@ -1,4 +1,5 @@ -using PSO2SERVER.Models; +using Newtonsoft.Json; +using PSO2SERVER.Models; using PSO2SERVER.Zone; using System; using System.Collections.Generic; @@ -11,10 +12,14 @@ namespace PSO2SERVER.Protocol.Packets public class EventSpawnPacket : Packet { public readonly PSOObject _obj; + [JsonProperty("object")] public ObjectHeader objHeader { get; set; } = new ObjectHeader(); + [JsonProperty("position")] public PSOLocation objPosition { get; set; } = new PSOLocation(); public ushort unk1 { get; set; } = 0; - public string objName { get; set; } = string.Empty; + /// Enemy name. + [JsonProperty("name")] + public string objName { get; set; } = string.Empty;//0x20 public uint unk3 { get; set; } = 0; public byte[] unk4 { get; set; } = new byte[0x0C]; public ushort unk5 { get; set; } = 0; @@ -40,6 +45,10 @@ namespace PSO2SERVER.Protocol.Packets _obj = obj; } + public EventSpawnPacket() + { + } + #region implemented abstract members of Packet public override byte[] Build() diff --git a/Server/Protocol/Packets/08-SpawnPacket/08-0B-ObjectSpawnPacket.cs b/Server/Protocol/Packets/08-SpawnPacket/08-0B-ObjectSpawnPacket.cs index 68edf50..697ebc4 100644 --- a/Server/Protocol/Packets/08-SpawnPacket/08-0B-ObjectSpawnPacket.cs +++ b/Server/Protocol/Packets/08-SpawnPacket/08-0B-ObjectSpawnPacket.cs @@ -1,4 +1,5 @@ -using Org.BouncyCastle.Utilities; +using Newtonsoft.Json; +using Org.BouncyCastle.Utilities; using PSO2SERVER.Models; using PSO2SERVER.Zone; using System; @@ -14,9 +15,13 @@ namespace PSO2SERVER.Protocol.Packets public class ObjectSpawnPacket : Packet { public readonly PSOObject _obj; + [JsonProperty("object")] public ObjectHeader objHeader { get; set; } = new ObjectHeader(); + [JsonProperty("position")] public PSOLocation objPosition { get; set; } = new PSOLocation(); public ushort unk1 { get; set; } = 0; + /// Enemy name. + [JsonProperty("name")] public string objName { get; set; } = string.Empty;//0x20 public uint[] unk2 { get; set; } = new uint[0x05]; public uint flags { get; set; } = 0; @@ -31,6 +36,10 @@ namespace PSO2SERVER.Protocol.Packets _obj = obj; } + public ObjectSpawnPacket() + { + } + #region implemented abstract members of Packet public override byte[] Build() diff --git a/Server/Protocol/Packets/08-SpawnPacket/08-0C-NPCSpawnPacket.cs b/Server/Protocol/Packets/08-SpawnPacket/08-0C-NPCSpawnPacket.cs index 51d6b47..6a1af99 100644 --- a/Server/Protocol/Packets/08-SpawnPacket/08-0C-NPCSpawnPacket.cs +++ b/Server/Protocol/Packets/08-SpawnPacket/08-0C-NPCSpawnPacket.cs @@ -1,4 +1,5 @@ -using Org.BouncyCastle.Utilities; +using Newtonsoft.Json; +using Org.BouncyCastle.Utilities; using PSO2SERVER.Models; using PSO2SERVER.Zone; using System; @@ -13,10 +14,14 @@ namespace PSO2SERVER.Protocol.Packets { public class NPCSpawnPacket : Packet { + [JsonProperty("object")] public ObjectHeader objHeader { get; set; } = new ObjectHeader(); + [JsonProperty("position")] public PSOLocation objPosition { get; set; } = new PSOLocation(); public ushort unk1 { get; set; } = 0; - public string objName { get; set; } = string.Empty; + /// Enemy name. + [JsonProperty("name")] + public string objName { get; set; } = string.Empty;//0x20 public uint unk2 { get; set; } = 0; public byte[] unk3 { get; set; } = new byte[0x0C]; public ushort unk4 { get; set; } = 0; @@ -39,6 +44,10 @@ namespace PSO2SERVER.Protocol.Packets unk12 = 1; } + public NPCSpawnPacket() + { + } + #region implemented abstract members of Packet public override byte[] Build() diff --git a/Server/Protocol/Packets/08-SpawnPacket/08-0D-EnemySpawnPacket.cs b/Server/Protocol/Packets/08-SpawnPacket/08-0D-EnemySpawnPacket.cs index 593c828..95f74c6 100644 --- a/Server/Protocol/Packets/08-SpawnPacket/08-0D-EnemySpawnPacket.cs +++ b/Server/Protocol/Packets/08-SpawnPacket/08-0D-EnemySpawnPacket.cs @@ -1,4 +1,5 @@ -using PSO2SERVER.Models; +using Newtonsoft.Json; +using PSO2SERVER.Models; using PSO2SERVER.Zone; using System; using System.Collections.Generic; @@ -9,10 +10,13 @@ namespace PSO2SERVER.Protocol.Packets { public class EnemySpawnPacket : Packet { + [JsonProperty("object")] public ObjectHeader objHeader { get; set; } = new ObjectHeader(); + [JsonProperty("position")] public PSOLocation objPosition { get; set; } = new PSOLocation(); public ushort unk1 { get; set; } = 0; /// Enemy name. + [JsonProperty("name")] public string objName { get; set; } = string.Empty;//0x20 public uint unk2 { get; set; } = 0; /// Enemy HP. @@ -48,6 +52,10 @@ namespace PSO2SERVER.Protocol.Packets unk12 = 255; } + public EnemySpawnPacket() + { + } + #region implemented abstract members of Packet public override byte[] Build() diff --git a/Server/Protocol/Packets/0B-QuestPacket/0B-18-QuestCategoryPacket.cs b/Server/Protocol/Packets/0B-QuestPacket/0B-18-QuestCategoryPacket.cs index 238c194..e4f7e8b 100644 --- a/Server/Protocol/Packets/0B-QuestPacket/0B-18-QuestCategoryPacket.cs +++ b/Server/Protocol/Packets/0B-QuestPacket/0B-18-QuestCategoryPacket.cs @@ -34,7 +34,7 @@ namespace PSO2SERVER.Protocol.Packets /* [K873] What I've currently mapped out 24 -> Start - 38 -> Quest Name/Type Index? + 38 -> Quest name/Type Index? 100 -> Bitfield 1 102 -> Estimated Play Time 103 -> Party Type diff --git a/Server/Protocol/Packets/0E-PartyPacket/0E-02-PartyInitPacket.cs b/Server/Protocol/Packets/0E-PartyPacket/0E-02-PartyInitPacket.cs index 7d9d920..9249ce5 100644 --- a/Server/Protocol/Packets/0E-PartyPacket/0E-02-PartyInitPacket.cs +++ b/Server/Protocol/Packets/0E-PartyPacket/0E-02-PartyInitPacket.cs @@ -151,7 +151,7 @@ namespace PSO2SERVER.Protocol.Packets //{ // PartyEntry pe = new PartyEntry(); // writer.WriteStruct(new ObjectHeader((uint)players[i].Accounts.AccountId, ObjectType.Player)); // Header of player - // writer.WriteUtf16(players[i].Name, 0xD863, 0xA9); + // writer.WriteUtf16(players[i].name, 0xD863, 0xA9); // writer.WriteUtf16(players[i].Accounts.Nickname, 0xD863, 0xA9); // writer.Write((byte)players[i].Jobs.entries.hunter.level); // Active class level // writer.Write((byte)players[i].Jobs.entries.hunter.level2); // idk diff --git a/Server/Protocol/Packets/0E-PartyPacket/0E-25-SetQuestInfoPacket.cs b/Server/Protocol/Packets/0E-PartyPacket/0E-25-SetQuestInfoPacket.cs index 4e532ea..f3cfe83 100644 --- a/Server/Protocol/Packets/0E-PartyPacket/0E-25-SetQuestInfoPacket.cs +++ b/Server/Protocol/Packets/0E-PartyPacket/0E-25-SetQuestInfoPacket.cs @@ -10,7 +10,7 @@ namespace PSO2SERVER.Protocol.Packets public class SetQuestInfoPacket : Packet { /// - /// Name ID of the quest. + /// name ID of the quest. /// public uint Name { get; set; } diff --git a/Server/Protocol/Packets/1C-AlliancePacket/1C-1F-GuildInfoPacket.cs b/Server/Protocol/Packets/1C-AlliancePacket/1C-1F-GuildInfoPacket.cs index 8248148..06bd33e 100644 --- a/Server/Protocol/Packets/1C-AlliancePacket/1C-1F-GuildInfoPacket.cs +++ b/Server/Protocol/Packets/1C-AlliancePacket/1C-1F-GuildInfoPacket.cs @@ -46,7 +46,7 @@ namespace PSO2SERVER.Protocol.Packets for (var i = 0; i < 24; i++) writer.Write((byte) 0); - // Team Name + // Team name // We don't actually have team names anywhere, just dump a test here writer.WriteFixedLengthUtf16("TEAMNAME", 16); diff --git a/Server/Server.csproj b/Server/Server.csproj index 1bf45b4..f96086d 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -167,6 +167,7 @@ + @@ -448,7 +449,7 @@ - + diff --git a/Server/Zone/ZoneAdditional.cs b/Server/Zone/ZoneAdditional.cs index 51e9188..7d72ac9 100644 --- a/Server/Zone/ZoneAdditional.cs +++ b/Server/Zone/ZoneAdditional.cs @@ -45,7 +45,7 @@ namespace PSO2SERVER.Zone // 重写 ToString 方法(可选) public override string ToString() { - return $"WorldId: {WorldId}, ZoneId: {ZoneId}, MapId: {MapId}, SizeX: {SizeX}, SizeY: {SizeY}"; + return $"WorldId: {WorldId}, zone_id: {ZoneId}, MapId: {MapId}, SizeX: {SizeX}, SizeY: {SizeY}"; } }