From 7857314e81d079122f80f1d417dcf82ec02ea4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Fri, 31 Dec 2021 21:59:06 +0100 Subject: [PATCH] feat: add condition parameters to pinit sub packet --- .../Packets/Server/Groups/PinitSubPacket.cs | 11 +++++++++-- .../Packets/PinitPacketConverterTest.cs | 18 +++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Core/NosSmooth.Packets/Packets/Server/Groups/PinitSubPacket.cs b/Core/NosSmooth.Packets/Packets/Server/Groups/PinitSubPacket.cs index 4ed9a9a2fc82aa2a219ab9e2e2aff393b1fbd878..e611d9eac526e61c06e6bcd4413b309494b96d96 100644 --- a/Core/NosSmooth.Packets/Packets/Server/Groups/PinitSubPacket.cs +++ b/Core/NosSmooth.Packets/Packets/Server/Groups/PinitSubPacket.cs @@ -6,6 +6,7 @@ using NosCore.Shared.Enumerations; using NosSmooth.Packets.Attributes; +using NosSmooth.Packets.Common; namespace NosSmooth.Packets.Packets.Server.Groups; @@ -36,7 +37,7 @@ public record PinitSubPacket [PacketIndex(3)] byte Level, [PacketIndex(4)] - string? Name, + NameString? Name, [PacketIndex(5)] int Unknown, [PacketIndex(6)] @@ -44,5 +45,11 @@ public record PinitSubPacket [PacketIndex(7)] short Race, [PacketIndex(8)] - short Morph + short Morph, + [PacketConditionalIndex(9, "EntityType", false, VisualType.Player)] + byte? HeroLevel, + [PacketConditionalIndex(10, "EntityType", false, VisualType.Player)] + int? Unknown1, + [PacketConditionalIndex(11, "EntityType", false, VisualType.Player)] + int? Unknown2 ) : IPacket; \ No newline at end of file diff --git a/Tests/NosSmooth.Packets.Tests/Converters/Packets/PinitPacketConverterTest.cs b/Tests/NosSmooth.Packets.Tests/Converters/Packets/PinitPacketConverterTest.cs index 3c66989f443a104fe6b4d1da47ede27fb6349816..ee62ae6efe5a1ce55404b5cae0cf66e9dbd28d0d 100644 --- a/Tests/NosSmooth.Packets.Tests/Converters/Packets/PinitPacketConverterTest.cs +++ b/Tests/NosSmooth.Packets.Tests/Converters/Packets/PinitPacketConverterTest.cs @@ -4,13 +4,13 @@ // 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 System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; using NosCore.Shared.Enumerations; using NosSmooth.Packets.Attributes; using NosSmooth.Packets.Converters; using NosSmooth.Packets.Extensions; using NosSmooth.Packets.Packets.Server.Groups; -using NosSmooth.Packets.Packets.Server.Map; using Xunit; namespace NosSmooth.Packets.Tests.Converters.Packets; @@ -43,8 +43,8 @@ public class PinitPacketConverterTest { var packet = new PinitPacket(2, new[] { - new PinitSubPacket(VisualType.Npc, 345377, 0, 83, "Kliff", -1, 319, 1, 0), - new PinitSubPacket(VisualType.Npc, 345384, 1, 83, "@", -1, 2105, 0, 0) + new PinitSubPacket(VisualType.Npc, 345377, 0, 83, "Kliff", -1, 319, 1, 0, null, null, null), + new PinitSubPacket(VisualType.Npc, 345384, 1, 83, "@", -1, 2105, 0, 0, null, null, null) }); var result = _packetSerializer.Serialize(packet); Assert.True(result.IsSuccess); @@ -62,11 +62,11 @@ public class PinitPacketConverterTest var result = _packetSerializer.Deserialize(packetString, PacketSource.Server); Assert.True(result.IsSuccess); - var actualPacket = new PinitPacket(2, new[] - { - new PinitSubPacket(VisualType.Npc, 345377, 0, 83, "Kliff", -1, 319, 1, 0), - new PinitSubPacket(VisualType.Npc, 345384, 1, 83, "@", -1, 2105, 0, 0) - }); - Assert.Equal(result.Entity, actualPacket); + var actualPacket = (PinitPacket)result.Entity; + + Assert.Equal(2, actualPacket.GroupSize); + Assert.Equal(2, actualPacket.PinitSubPackets.Count); + Assert.StrictEqual(new PinitSubPacket(VisualType.Npc, 345377, 0, 83, "Kliff", -1, 319, 1, 0, null, null, null), actualPacket.PinitSubPackets[0]); + Assert.StrictEqual(new PinitSubPacket(VisualType.Npc, 345384, 1, 83, "@", -1, 2105, 0, 0, null, null, null), actualPacket.PinitSubPackets[1]); } } \ No newline at end of file