From 092bded0f73a136ec4fada42e881a913337fc454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sat, 7 Jan 2023 12:31:36 +0100 Subject: [PATCH] fix(packets): correctly represent finfo --- .../Relations/FriendInitResponder.cs | 7 +++-- .../Server/Groups/PinitMateSubPacket.cs | 2 ++ .../Server/Relations/FInfoPacket.cs | 13 +++------ .../Server/Relations/FInfoSubPacket.cs | 29 +++++++++++++++++++ 4 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 Packets/NosSmooth.Packets/Server/Relations/FInfoSubPacket.cs diff --git a/Core/NosSmooth.Game/PacketHandlers/Relations/FriendInitResponder.cs b/Core/NosSmooth.Game/PacketHandlers/Relations/FriendInitResponder.cs index 816f6c8..f069c08 100644 --- a/Core/NosSmooth.Game/PacketHandlers/Relations/FriendInitResponder.cs +++ b/Core/NosSmooth.Game/PacketHandlers/Relations/FriendInitResponder.cs @@ -40,10 +40,11 @@ public class FriendInitResponder : IPacketResponder, IPacketRespond .Select( x => { - if (x.PlayerId == packet.PlayerId) + var subPacket = packet.FriendSubPackets.FirstOrDefault(y => x.PlayerId == y.PlayerId); + if (subPacket is not null) { - x.IsConnected = packet.IsConnected; - x.CharacterName = packet.Name; + x.IsConnected = subPacket.IsConnected; + x.CharacterName = subPacket.Name; } return x; diff --git a/Packets/NosSmooth.Packets/Server/Groups/PinitMateSubPacket.cs b/Packets/NosSmooth.Packets/Server/Groups/PinitMateSubPacket.cs index c4bc766..4a0dd6c 100644 --- a/Packets/NosSmooth.Packets/Server/Groups/PinitMateSubPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Groups/PinitMateSubPacket.cs @@ -20,6 +20,8 @@ namespace NosSmooth.Packets.Server.Groups; /// The name of the mate. /// Unknown TODO. /// The VNum of the mate entity. +[PacketHeader(null, PacketSource.Server)] +[GenerateSerializer(true)] public record PinitMateSubPacket ( [PacketIndex(0)] diff --git a/Packets/NosSmooth.Packets/Server/Relations/FInfoPacket.cs b/Packets/NosSmooth.Packets/Server/Relations/FInfoPacket.cs index c708c06..140c96e 100644 --- a/Packets/NosSmooth.Packets/Server/Relations/FInfoPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Relations/FInfoPacket.cs @@ -12,16 +12,11 @@ namespace NosSmooth.Packets.Server.Relations; /// /// Information update of friend of a character. /// -/// The id of the friend. -/// Whether the friend is connected. -/// The name of the friend.[PacketHeader("finfo", PacketSource.Server)] +/// +[PacketHeader("finfo", PacketSource.Server)] [GenerateSerializer(true)] public record FInfoPacket ( - [PacketIndex(0)] - long PlayerId, - [PacketIndex(1)] - bool IsConnected, - [PacketIndex(2)] - NameString Name + [PacketListIndex(0, InnerSeparator = '.', ListSeparator = ' ')] + IReadOnlyList FriendSubPackets ) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Relations/FInfoSubPacket.cs b/Packets/NosSmooth.Packets/Server/Relations/FInfoSubPacket.cs new file mode 100644 index 0000000..cc7c0ee --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Relations/FInfoSubPacket.cs @@ -0,0 +1,29 @@ +// +// FInfoSubPacket.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.PacketSerializer.Abstractions.Attributes; +using NosSmooth.PacketSerializer.Abstractions.Common; + +namespace NosSmooth.Packets.Server.Relations; + +/// +/// A sub packet of +/// containing information about a friend. +/// +/// The id of the player. +/// Whether the player is connected. +/// The name of the player. +[PacketHeader(null, PacketSource.Server)] +[GenerateSerializer(true)] +public record FInfoSubPacket +( + [PacketIndex(0)] + long PlayerId, + [PacketIndex(1)] + bool IsConnected, + [PacketIndex(2)] + NameString Name +); \ No newline at end of file -- 2.48.1