AddMemberPacket

This commit is contained in:
Longfeng Qin 2024-12-11 20:47:36 +08:00
parent f86e6ab1ce
commit 8ee0076763
9 changed files with 149 additions and 28 deletions

View File

@ -178,12 +178,12 @@ namespace PSO2SERVER.Models
pkt.WriteFixedLengthASCII(Date, 0x20); pkt.WriteFixedLengthASCII(Date, 0x20);
pkt.WriteObjectHeader(QuestObj); pkt.WriteObjectHeader(QuestObj);
pkt.Write(NameId); pkt.Write(NameId);
pkt.WriteUintArray(Unk3); pkt.WriteIntArray(Unk3);
pkt.Write(Unk4); pkt.Write(Unk4);
pkt.Write(Unk5); pkt.Write(Unk5);
pkt.Write(Unk6); pkt.Write(Unk6);
pkt.WriteUintArray(Unk7); pkt.WriteIntArray(Unk7);
pkt.WriteUshortArray(Unk8); pkt.WriteShortArray(Unk8);
pkt.Write(Length); pkt.Write(Length);
pkt.Write((byte)PartyType); pkt.Write((byte)PartyType);
pkt.Write((byte)Difficulties); pkt.Write((byte)Difficulties);
@ -196,7 +196,7 @@ namespace PSO2SERVER.Models
pkt.Write((byte)QuestType); pkt.Write((byte)QuestType);
pkt.Write(Unk11); pkt.Write(Unk11);
pkt.Write(Unk12); pkt.Write(Unk12);
pkt.WriteUintArray(Unk13); pkt.WriteIntArray(Unk13);
pkt.Write(Unk14); pkt.Write(Unk14);
pkt.Write(Unk15); pkt.Write(Unk15);
pkt.Write(Unk16); pkt.Write(Unk16);

View File

@ -226,12 +226,7 @@ namespace PSO2SERVER.Protocol
} }
} }
public void WriteByteArray(byte[] b) public void WriteIntArray(uint[] array)
{
Write(b);
}
public void WriteUintArray(uint[] array)
{ {
foreach (var item in 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) foreach (var item in array)
{ {
@ -378,15 +373,23 @@ namespace PSO2SERVER.Protocol
{ {
Write((byte)underlyingValue); Write((byte)underlyingValue);
} }
else if (underlyingType == typeof(short)) else if (underlyingType == typeof(short) || underlyingType == typeof(ushort))
{ {
Write((short)underlyingValue); 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); 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); Write((long)underlyingValue);
} }

View File

@ -39,7 +39,7 @@ namespace PSO2SERVER.Protocol.Packets
pkt.Write(unk2); pkt.Write(unk2);
unk3.WriteObjectHeaderToStream(pkt); unk3.WriteObjectHeaderToStream(pkt);
unk4.WriteObjectHeaderToStream(pkt); unk4.WriteObjectHeaderToStream(pkt);
pkt.WriteByteArray(unk5); pkt.Write(unk5);
pkt.WriteAscii(action, 0x83EF, 0x40); pkt.WriteAscii(action, 0x83EF, 0x40);
return pkt.ToArray(); return pkt.ToArray();
} }

View File

@ -49,7 +49,7 @@ namespace PSO2SERVER.Protocol.Packets
pkt.WritePosition(objPosition); pkt.WritePosition(objPosition);
pkt.Write(unk1); // Padding? pkt.Write(unk1); // Padding?
pkt.WriteFixedLengthASCII(objName, 0x20); pkt.WriteFixedLengthASCII(objName, 0x20);
pkt.WriteUintArray(unk2); pkt.WriteIntArray(unk2);
pkt.Write(flags); pkt.Write(flags);
pkt.Write(_obj.Things.Length); pkt.Write(_obj.Things.Length);
foreach (PSOObjectThing thing in _obj.Things) foreach (PSOObjectThing thing in _obj.Things)

View File

@ -73,7 +73,7 @@ namespace PSO2SERVER.Protocol.Packets
pkt.Write(unk6); pkt.Write(unk6);
pkt.Write(unk7); pkt.Write(unk7);
pkt.Write(unk8); pkt.Write(unk8);
pkt.WriteUintArray(unk9); pkt.WriteIntArray(unk9);
pkt.WriteAscii(unk10, 0x258B, 0x32); pkt.WriteAscii(unk10, 0x258B, 0x32);
pkt.Write(unk11); pkt.Write(unk11);
pkt.Write(unk12); pkt.Write(unk12);

View File

@ -43,7 +43,7 @@ namespace PSO2SERVER.Protocol.Packets
{ {
var pkt = new PacketWriter(); var pkt = new PacketWriter();
pkt.WriteAscii(scene_name, 0xB65A, 0x7D); pkt.WriteAscii(scene_name, 0xB65A, 0x7D);
pkt.WriteUintArray(unk1); pkt.WriteIntArray(unk1);
pkt.WriteObjectHeaderList(unk2); pkt.WriteObjectHeaderList(unk2);
pkt.Write(unk3); pkt.Write(unk3);
pkt.Write(unk4); pkt.Write(unk4);

View File

@ -24,12 +24,12 @@ namespace PSO2SERVER.Protocol.Packets
pkt.WriteFixedLengthASCII(qd.Date, 0x20); pkt.WriteFixedLengthASCII(qd.Date, 0x20);
pkt.WriteObjectHeader(qd.QuestObj); pkt.WriteObjectHeader(qd.QuestObj);
pkt.Write(qd.NameId); pkt.Write(qd.NameId);
pkt.WriteUintArray(qd.Unk3); pkt.WriteIntArray(qd.Unk3);
pkt.Write(qd.Unk4); pkt.Write(qd.Unk4);
pkt.Write(qd.Unk5); pkt.Write(qd.Unk5);
pkt.Write(qd.Unk6); pkt.Write(qd.Unk6);
pkt.WriteUintArray(qd.Unk7); pkt.WriteIntArray(qd.Unk7);
pkt.WriteUshortArray(qd.Unk8); pkt.WriteShortArray(qd.Unk8);
pkt.Write(qd.Length); pkt.Write(qd.Length);
pkt.Write((byte)qd.PartyType); pkt.Write((byte)qd.PartyType);
pkt.Write((byte)qd.Difficulties); pkt.Write((byte)qd.Difficulties);
@ -42,7 +42,7 @@ namespace PSO2SERVER.Protocol.Packets
pkt.Write((byte)qd.QuestType); pkt.Write((byte)qd.QuestType);
pkt.Write(qd.Unk11); pkt.Write(qd.Unk11);
pkt.Write(qd.Unk12); pkt.Write(qd.Unk12);
pkt.WriteUintArray(qd.Unk13); pkt.WriteIntArray(qd.Unk13);
pkt.Write(qd.Unk14); pkt.Write(qd.Unk14);
pkt.Write(qd.Unk15); pkt.Write(qd.Unk15);
pkt.Write(qd.Unk16); pkt.Write(qd.Unk16);

View File

@ -1,4 +1,5 @@
using PSO2SERVER.Models; using PSO2SERVER.Models;
using PSO2SERVER.Party;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -8,9 +9,102 @@ namespace PSO2SERVER.Protocol.Packets
{ {
public class AddMemberPacket : Packet 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() 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 #region implemented abstract members of Packet
@ -18,12 +112,36 @@ namespace PSO2SERVER.Protocol.Packets
public override byte[] Build() public override byte[] Build()
{ {
var pkt = new PacketWriter(); 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(); return pkt.ToArray();
} }
public override PacketHeader GetHeader() public override PacketHeader GetHeader()
{ {
return new PacketHeader(0x0E, 0x00, PacketFlags.None); return new PacketHeader(0x0E, 0x00, PacketFlags.PACKED);
} }
#endregion #endregion

View File

@ -8,17 +8,17 @@ namespace PSO2SERVER.Protocol.Packets
public class PartyInitPacket : Packet 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个成员。
/// <summary> /// <summary>
/// 未知 /// 未知
/// </summary> /// </summary>
private string unk2 = string.Empty; public string unk2 = string.Empty;
private List<Client> Clients = new List<Client>(); private List<Client> Clients = new List<Client>();
public PartyInitPacket(List<Client> clients) public PartyInitPacket(List<Client> clients)