diff --git a/Server/Models/PartyQuest.cs b/Server/Models/PartyQuest.cs index f4286a0..3bd7fdf 100644 --- a/Server/Models/PartyQuest.cs +++ b/Server/Models/PartyQuest.cs @@ -178,12 +178,12 @@ namespace PSO2SERVER.Models pkt.WriteFixedLengthASCII(Date, 0x20); pkt.WriteObjectHeader(QuestObj); pkt.Write(NameId); - pkt.WriteUintArray(Unk3); + pkt.WriteIntArray(Unk3); pkt.Write(Unk4); pkt.Write(Unk5); pkt.Write(Unk6); - pkt.WriteUintArray(Unk7); - pkt.WriteUshortArray(Unk8); + pkt.WriteIntArray(Unk7); + pkt.WriteShortArray(Unk8); pkt.Write(Length); pkt.Write((byte)PartyType); pkt.Write((byte)Difficulties); @@ -196,7 +196,7 @@ namespace PSO2SERVER.Models pkt.Write((byte)QuestType); pkt.Write(Unk11); pkt.Write(Unk12); - pkt.WriteUintArray(Unk13); + pkt.WriteIntArray(Unk13); pkt.Write(Unk14); pkt.Write(Unk15); pkt.Write(Unk16); diff --git a/Server/Protocol/PacketWriter.cs b/Server/Protocol/PacketWriter.cs index 6568375..aa08b52 100644 --- a/Server/Protocol/PacketWriter.cs +++ b/Server/Protocol/PacketWriter.cs @@ -226,12 +226,7 @@ namespace PSO2SERVER.Protocol } } - public void WriteByteArray(byte[] b) - { - Write(b); - } - - public void WriteUintArray(uint[] array) + public void WriteIntArray(uint[] array) { foreach (var item in array) { @@ -247,7 +242,7 @@ namespace PSO2SERVER.Protocol } } - public void WriteUshortArray(ushort[] array) + public void WriteShortArray(ushort[] array) { foreach (var item in array) { @@ -378,15 +373,23 @@ namespace PSO2SERVER.Protocol { Write((byte)underlyingValue); } - else if (underlyingType == typeof(short)) + else if (underlyingType == typeof(short) || underlyingType == typeof(ushort)) { Write((short)underlyingValue); } - else if (underlyingType == typeof(int)) + else if (underlyingType == typeof(Half) || underlyingType == typeof(Half)) + { + WriteHalf((Half)underlyingValue); + } + else if (underlyingType == typeof(int) || underlyingType == typeof(uint)) { Write((int)underlyingValue); } - else if (underlyingType == typeof(long)) + else if (underlyingType == typeof(float)) + { + Write((float)underlyingValue); + } + else if (underlyingType == typeof(long) || underlyingType == typeof(ulong)) { Write((long)underlyingValue); } diff --git a/Server/Protocol/Packets/04-ObjectRelatedPacket/04-75-ActionEndPacket.cs b/Server/Protocol/Packets/04-ObjectRelatedPacket/04-75-ActionEndPacket.cs index 5e69c47..fa5f9b8 100644 --- a/Server/Protocol/Packets/04-ObjectRelatedPacket/04-75-ActionEndPacket.cs +++ b/Server/Protocol/Packets/04-ObjectRelatedPacket/04-75-ActionEndPacket.cs @@ -39,7 +39,7 @@ namespace PSO2SERVER.Protocol.Packets pkt.Write(unk2); unk3.WriteObjectHeaderToStream(pkt); unk4.WriteObjectHeaderToStream(pkt); - pkt.WriteByteArray(unk5); + pkt.Write(unk5); pkt.WriteAscii(action, 0x83EF, 0x40); return pkt.ToArray(); } diff --git a/Server/Protocol/Packets/08-SpawnPacket/08-0B-ObjectSpawnPacket.cs b/Server/Protocol/Packets/08-SpawnPacket/08-0B-ObjectSpawnPacket.cs index e320e4e..18d5e4d 100644 --- a/Server/Protocol/Packets/08-SpawnPacket/08-0B-ObjectSpawnPacket.cs +++ b/Server/Protocol/Packets/08-SpawnPacket/08-0B-ObjectSpawnPacket.cs @@ -49,7 +49,7 @@ namespace PSO2SERVER.Protocol.Packets pkt.WritePosition(objPosition); pkt.Write(unk1); // Padding? pkt.WriteFixedLengthASCII(objName, 0x20); - pkt.WriteUintArray(unk2); + pkt.WriteIntArray(unk2); pkt.Write(flags); pkt.Write(_obj.Things.Length); foreach (PSOObjectThing thing in _obj.Things) diff --git a/Server/Protocol/Packets/08-SpawnPacket/08-0D-EnemySpawnPacket.cs b/Server/Protocol/Packets/08-SpawnPacket/08-0D-EnemySpawnPacket.cs index b4603d8..44627f7 100644 --- a/Server/Protocol/Packets/08-SpawnPacket/08-0D-EnemySpawnPacket.cs +++ b/Server/Protocol/Packets/08-SpawnPacket/08-0D-EnemySpawnPacket.cs @@ -73,7 +73,7 @@ namespace PSO2SERVER.Protocol.Packets pkt.Write(unk6); pkt.Write(unk7); pkt.Write(unk8); - pkt.WriteUintArray(unk9); + pkt.WriteIntArray(unk9); pkt.WriteAscii(unk10, 0x258B, 0x32); pkt.Write(unk11); pkt.Write(unk12); diff --git a/Server/Protocol/Packets/0B-QuestPacket/0B-06-StartCutscenePacket.cs b/Server/Protocol/Packets/0B-QuestPacket/0B-06-StartCutscenePacket.cs index c7ae363..1e7ab37 100644 --- a/Server/Protocol/Packets/0B-QuestPacket/0B-06-StartCutscenePacket.cs +++ b/Server/Protocol/Packets/0B-QuestPacket/0B-06-StartCutscenePacket.cs @@ -43,7 +43,7 @@ namespace PSO2SERVER.Protocol.Packets { var pkt = new PacketWriter(); pkt.WriteAscii(scene_name, 0xB65A, 0x7D); - pkt.WriteUintArray(unk1); + pkt.WriteIntArray(unk1); pkt.WriteObjectHeaderList(unk2); pkt.Write(unk3); pkt.Write(unk4); diff --git a/Server/Protocol/Packets/0B-QuestPacket/0B-18-QuestCategoryPacket.cs b/Server/Protocol/Packets/0B-QuestPacket/0B-18-QuestCategoryPacket.cs index eb54781..fbddc8d 100644 --- a/Server/Protocol/Packets/0B-QuestPacket/0B-18-QuestCategoryPacket.cs +++ b/Server/Protocol/Packets/0B-QuestPacket/0B-18-QuestCategoryPacket.cs @@ -24,12 +24,12 @@ namespace PSO2SERVER.Protocol.Packets pkt.WriteFixedLengthASCII(qd.Date, 0x20); pkt.WriteObjectHeader(qd.QuestObj); pkt.Write(qd.NameId); - pkt.WriteUintArray(qd.Unk3); + pkt.WriteIntArray(qd.Unk3); pkt.Write(qd.Unk4); pkt.Write(qd.Unk5); pkt.Write(qd.Unk6); - pkt.WriteUintArray(qd.Unk7); - pkt.WriteUshortArray(qd.Unk8); + pkt.WriteIntArray(qd.Unk7); + pkt.WriteShortArray(qd.Unk8); pkt.Write(qd.Length); pkt.Write((byte)qd.PartyType); pkt.Write((byte)qd.Difficulties); @@ -42,7 +42,7 @@ namespace PSO2SERVER.Protocol.Packets pkt.Write((byte)qd.QuestType); pkt.Write(qd.Unk11); pkt.Write(qd.Unk12); - pkt.WriteUintArray(qd.Unk13); + pkt.WriteIntArray(qd.Unk13); pkt.Write(qd.Unk14); pkt.Write(qd.Unk15); pkt.Write(qd.Unk16); diff --git a/Server/Protocol/Packets/0E-PartyPacket/0E-00-AddMemberPacket.cs b/Server/Protocol/Packets/0E-PartyPacket/0E-00-AddMemberPacket.cs index 021b28a..44f2b0b 100644 --- a/Server/Protocol/Packets/0E-PartyPacket/0E-00-AddMemberPacket.cs +++ b/Server/Protocol/Packets/0E-PartyPacket/0E-00-AddMemberPacket.cs @@ -1,4 +1,5 @@ using PSO2SERVER.Models; +using PSO2SERVER.Party; using System; using System.Collections.Generic; using System.Linq; @@ -8,9 +9,102 @@ namespace PSO2SERVER.Protocol.Packets { public class AddMemberPacket : Packet { + // New player object. + public ObjectHeader NewMember { get; set; } + // Party color of the player. + public PartyColor Color { get; set; } + + // Level of the main class. + public uint Level { get; set; } + + // Level of the subclass. + public uint Sublevel { get; set; } + + // Class of the player. + public ClassType PlayerClass { get; set; } + + // Subclass of the player. + public ClassType SubClass { get; set; } + + // Padding (3 bytes). + public byte[] Padding { get; set; } = new byte[3]; + + // Nickname of the player. + public string Nickname { get; set; } + + // Name of the character. + public string CharName { get; set; } + + // Unk5 (12 bytes). + public byte[] Unk5 { get; set; } = new byte[0xC]; + + // Unk6 (16-bit). + public ushort Unk6 { get; set; } + + // Unk7 (2 bytes). + public byte[] Unk7 { get; set; } = new byte[2]; + + // HP of the player (3 values). + public uint[] Hp { get; set; } = new uint[3]; + + // Map ID where the player is located. + public ushort MapId { get; set; } + + // Unk10 (4 bytes). + public byte[] Unk10 { get; set; } = new byte[4]; + + // Unk11 (16-bit). + public ushort Unk11 { get; set; } + + // Unk12 (32-bit). + public uint Unk12 { get; set; } + + // Unk13 (12 bytes). + public byte[] Unk13 { get; set; } = new byte[0xC]; + + // Unk14 (3 values of uint). + public uint[] Unk14 { get; set; } = new uint[3]; + + // Unk15 (string). + public string Unk15 { get; set; } + + // Unk16 (AsciiString). + public string Unk16 { get; set; } + + // NGS Packet Only (if applicable). + public string Unk17 { get; set; } // Only if feature is enabled + + // Constructor public AddMemberPacket() { + Padding = new byte[3]; + Unk5 = new byte[0xC]; + Unk7 = new byte[2]; + Hp = new uint[3]; + Unk10 = new byte[4]; + Unk13 = new byte[0xC]; + Unk14 = new uint[3]; + } + + public AddMemberPacket(Client client) + { + NewMember = new ObjectHeader((uint)client._account.AccountId, ObjectType.Player); + Color = client.currentParty.AddColor(0); + var character = client.Character; + Level = character.Jobs.entries.hunter.level; + Sublevel = character.Jobs.entries.ranger.level; + PlayerClass = character.Jobs.mainClass; + SubClass = character.Jobs.subClass; + Nickname = client._account.Nickname; + CharName = character.Name; + MapId = (ushort)client.CurrentMap.MapID; + } + + public AddMemberPacket(PartyInitPacket pkt) + { + NewMember = pkt.leader; + Color = PartyColor.Red; } #region implemented abstract members of Packet @@ -18,12 +112,36 @@ namespace PSO2SERVER.Protocol.Packets public override byte[] Build() { var pkt = new PacketWriter(); + pkt.WriteObjectHeader(NewMember); + pkt.Write((byte)Color); + pkt.Write(Level); + pkt.Write(Sublevel); + pkt.WriteEnum(PlayerClass); + pkt.WriteEnum(SubClass); + pkt.Write(Padding); + pkt.WriteUtf16(Nickname, 0xCCE7, 0x13); + pkt.WriteUtf16(CharName, 0xCCE7, 0x13); + pkt.Write(Unk5); + pkt.Write(Unk6); + pkt.Write(Unk7); + pkt.WriteIntArray(Hp); + pkt.Write(MapId); + pkt.Write(Unk10); + pkt.Write(Unk11); + pkt.Write(Unk12); + pkt.Write(Unk13); + pkt.WriteIntArray(Unk14); + pkt.WriteUtf16(Unk15, 0xCCE7, 0x13); + pkt.WriteAscii(Unk16, 0xCCE7, 0x13); + //NGS + //pkt.WriteAscii(Unk17, 0xCCE7, 0x13); + return pkt.ToArray(); } public override PacketHeader GetHeader() { - return new PacketHeader(0x0E, 0x00, PacketFlags.None); + return new PacketHeader(0x0E, 0x00, PacketFlags.PACKED); } #endregion diff --git a/Server/Protocol/Packets/0E-PartyPacket/0E-02-PartyInitPacket.cs b/Server/Protocol/Packets/0E-PartyPacket/0E-02-PartyInitPacket.cs index f2bb3c2..afd8fb6 100644 --- a/Server/Protocol/Packets/0E-PartyPacket/0E-02-PartyInitPacket.cs +++ b/Server/Protocol/Packets/0E-PartyPacket/0E-02-PartyInitPacket.cs @@ -8,17 +8,17 @@ namespace PSO2SERVER.Protocol.Packets public class PartyInitPacket : Packet { /// 队伍实例. - private ObjectHeader party_object; + public ObjectHeader party_object; /// 队伍队长实例. - private ObjectHeader leader; + public ObjectHeader leader; /// 队伍人数. - private uint people_amount; + public uint people_amount; /// 队伍成员. - private PartyEntry[] entries = new PartyEntry[4]; // 这个是一个包含 4 个 `PartyEntry` 结构的数组,表示队伍中的4个成员。 + public PartyEntry[] entries = new PartyEntry[4]; // 这个是一个包含 4 个 `PartyEntry` 结构的数组,表示队伍中的4个成员。 /// /// 未知 /// - private string unk2 = string.Empty; + public string unk2 = string.Empty; private List Clients = new List(); public PartyInitPacket(List clients)