~ruther/NosSmooth

070ddd926879bc8005da920c21a58638f3d84a89 — Rutherther 2 years ago dcf5299
feat(packets): fix pinit packet for various entity types
A Packets/NosSmooth.Packets/Server/Groups/PinitMateSubPacket.cs => Packets/NosSmooth.Packets/Server/Groups/PinitMateSubPacket.cs +26 -0
@@ 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

M Packets/NosSmooth.Packets/Server/Groups/PinitPacket.cs => Packets/NosSmooth.Packets/Server/Groups/PinitPacket.cs +3 -2
@@ 14,13 14,14 @@ namespace NosSmooth.Packets.Server.Groups;
/// <remarks>
/// Contains pet and group information.
/// </remarks>
/// <param name="GroupSize">The size of the group.</param>
/// <param name="SubPacketsCount">The number of sub packets.</param>
/// <param name="PinitSubPackets">The members of the group. (including pet and partner, if any)</param>
[GenerateSerializer(true)]
[PacketHeader("pinit", PacketSource.Server)]
public record PinitPacket
(
    [PacketIndex(0)] int GroupSize,
    [PacketIndex(0)]
    byte SubPacketsCount,
    [PacketListIndex(1, ListSeparator = ' ', InnerSeparator = '|', IsOptional = true)]
    IReadOnlyList<PinitSubPacket>? PinitSubPackets
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Groups/PinitPlayerSubPacket.cs => Packets/NosSmooth.Packets/Server/Groups/PinitPlayerSubPacket.cs +35 -0
@@ 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

M Packets/NosSmooth.Packets/Server/Groups/PinitSubPacket.cs => Packets/NosSmooth.Packets/Server/Groups/PinitSubPacket.cs +8 -30
@@ 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;
/// </summary>
/// <param name="EntityType">The type of the entity.</param>
/// <param name="EntityId">The id of the entity.</param>
/// <param name="GroupPosition">The position in the group.</param>
/// <param name="Level">The level of the entity.</param>
/// <param name="Name">The name of the entity.</param>
/// <param name="Unknown">Unknown.</param>
/// <param name="VNum">The VNum of the pet for pets.</param>
/// <param name="Race">The race of the entity.</param>
/// <param name="MorphVNum">The morph of the entity.</param>
/// <param name="HeroLevel">The hero level of the entity.</param>
/// <param name="Unknown1">Unknown.</param>
/// <param name="Unknown2">Unknown.</param>
/// <param name="MateSubPacket">Present for pets and partners.</param>
/// <param name="PlayerSubPacket">Present for players.</param>
[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