From 070ddd926879bc8005da920c21a58638f3d84a89 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Fri, 6 Jan 2023 22:55:58 +0100 Subject: [PATCH] feat(packets): fix pinit packet for various entity types --- .../Server/Groups/PinitMateSubPacket.cs | 26 +++++++++++++ .../Server/Groups/PinitPacket.cs | 5 ++- .../Server/Groups/PinitPlayerSubPacket.cs | 35 +++++++++++++++++ .../Server/Groups/PinitSubPacket.cs | 38 ++++--------------- 4 files changed, 72 insertions(+), 32 deletions(-) create mode 100644 Packets/NosSmooth.Packets/Server/Groups/PinitMateSubPacket.cs create mode 100644 Packets/NosSmooth.Packets/Server/Groups/PinitPlayerSubPacket.cs diff --git a/Packets/NosSmooth.Packets/Server/Groups/PinitMateSubPacket.cs b/Packets/NosSmooth.Packets/Server/Groups/PinitMateSubPacket.cs new file mode 100644 index 0000000000000000000000000000000000000000..9d1b345dbdab44f421d839fd7dc17a558840232a --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Groups/PinitMateSubPacket.cs @@ -0,0 +1,26 @@ +// +// PinitMateSubPacket.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Enums.Entities; +using NosSmooth.Packets.Enums.Mates; +using NosSmooth.PacketSerializer.Abstractions.Attributes; +using NosSmooth.PacketSerializer.Abstractions.Common; + +namespace NosSmooth.Packets.Server.Groups; + +public record PinitMateSubPacket +( + [PacketIndex(0)] + MateType MateType, + [PacketIndex(1)] + byte Level, + [PacketIndex(2)] + NameString? Name, + [PacketIndex(3)] + int? Unknown, + [PacketIndex(4)] + long? VNum +) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Groups/PinitPacket.cs b/Packets/NosSmooth.Packets/Server/Groups/PinitPacket.cs index 7d765bf35cc8591a922cbef74ca5f798bcb6d6f3..e1341a81e07ec591d93068fdd3c96ecaeb5a2fd0 100644 --- a/Packets/NosSmooth.Packets/Server/Groups/PinitPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Groups/PinitPacket.cs @@ -14,13 +14,14 @@ namespace NosSmooth.Packets.Server.Groups; /// /// Contains pet and group information. /// -/// The size of the group. +/// The number of sub packets. /// The members of the group. (including pet and partner, if any) [GenerateSerializer(true)] [PacketHeader("pinit", PacketSource.Server)] public record PinitPacket ( - [PacketIndex(0)] int GroupSize, + [PacketIndex(0)] + byte SubPacketsCount, [PacketListIndex(1, ListSeparator = ' ', InnerSeparator = '|', IsOptional = true)] IReadOnlyList? PinitSubPackets ) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Groups/PinitPlayerSubPacket.cs b/Packets/NosSmooth.Packets/Server/Groups/PinitPlayerSubPacket.cs new file mode 100644 index 0000000000000000000000000000000000000000..8c30820f836e4919cb04400fdc4a39bb981a1f3f --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Groups/PinitPlayerSubPacket.cs @@ -0,0 +1,35 @@ +// +// PinitPlayerSubPacket.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Enums.Entities; +using NosSmooth.Packets.Enums.Mates; +using NosSmooth.Packets.Enums.Players; +using NosSmooth.PacketSerializer.Abstractions.Attributes; +using NosSmooth.PacketSerializer.Abstractions.Common; + +namespace NosSmooth.Packets.Server.Groups; + +[PacketHeader(null, PacketSource.Server)] +[GenerateSerializer(true)] +public record PinitPlayerSubPacket +( + [PacketIndex(0)] + byte GroupPosition, + [PacketIndex(1)] + byte Level, + [PacketIndex(2)] + NameString? Name, + [PacketIndex(3)] + int? GroupId, + [PacketIndex(4)] + SexType Sex, + [PacketIndex(5)] + PlayerClass Class, + [PacketIndex(6)] + short MorphVNum, + [PacketIndex(7)] + byte? HeroLevel +) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Groups/PinitSubPacket.cs b/Packets/NosSmooth.Packets/Server/Groups/PinitSubPacket.cs index b4bebc136c623dd9d378f0e47701e65481df9416..c40517a8772d458e59800f47397ecc02a8c2b17e 100644 --- a/Packets/NosSmooth.Packets/Server/Groups/PinitSubPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Groups/PinitSubPacket.cs @@ -6,6 +6,8 @@ using NosSmooth.Packets.Enums; using NosSmooth.Packets.Enums.Entities; +using NosSmooth.Packets.Enums.Mates; +using NosSmooth.Packets.Enums.Players; using NosSmooth.PacketSerializer.Abstractions.Attributes; using NosSmooth.PacketSerializer.Abstractions.Common; @@ -17,16 +19,8 @@ namespace NosSmooth.Packets.Server.Groups; /// /// The type of the entity. /// The id of the entity. -/// The position in the group. -/// The level of the entity. -/// The name of the entity. -/// Unknown. -/// The VNum of the pet for pets. -/// The race of the entity. -/// The morph of the entity. -/// The hero level of the entity. -/// Unknown. -/// Unknown. +/// Present for pets and partners. +/// Present for players. [GenerateSerializer(true)] [PacketHeader(null, PacketSource.Server)] public record PinitSubPacket @@ -35,24 +29,8 @@ public record PinitSubPacket EntityType EntityType, [PacketIndex(1)] long EntityId, - [PacketIndex(2)] - int GroupPosition, - [PacketIndex(3)] - byte Level, - [PacketIndex(4)] - NameString? Name, - [PacketIndex(5)] - int? Unknown, - [PacketIndex(6)] - long VNum, - [PacketIndex(7)] - short Race, - [PacketIndex(8)] - short MorphVNum, - [PacketConditionalIndex(9, "EntityType", false, EntityType.Player)] - byte? HeroLevel, - [PacketConditionalIndex(10, "EntityType", false, EntityType.Player)] - int? Unknown1, - [PacketConditionalIndex(11, "EntityType", false, EntityType.Player)] - int? Unknown2 + [PacketConditionalIndex(2, "EntityType", false, EntityType.Npc, InnerSeparator = '|')] + PinitMateSubPacket? MateSubPacket, + [PacketConditionalIndex(3, "EntityType", false, EntityType.Player, InnerSeparator = '|')] + PinitPlayerSubPacket? PlayerSubPacket ) : IPacket; \ No newline at end of file