~ruther/NosSmooth

7857314e81d079122f80f1d417dcf82ec02ea4d2 — František Boháček 3 years ago 6f88222
feat: add condition parameters to pinit sub packet
M Core/NosSmooth.Packets/Packets/Server/Groups/PinitSubPacket.cs => Core/NosSmooth.Packets/Packets/Server/Groups/PinitSubPacket.cs +9 -2
@@ 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

M Tests/NosSmooth.Packets.Tests/Converters/Packets/PinitPacketConverterTest.cs => Tests/NosSmooth.Packets.Tests/Converters/Packets/PinitPacketConverterTest.cs +9 -9
@@ 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

Do not follow this link