~ruther/Nostale-Anonymizer

ref: f56393bbc61224da75465542183e478910640a70 Nostale-Anonymizer/src/Anonymizer/Movers/Basic/InPacketMover.cs -rw-r--r-- 1.7 KiB
f56393bb — František Boháček feat: add new movers 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
//  InPacketMover.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.Server.Maps;
using NosSmooth.PacketSerializer.Abstractions.Common;

namespace Anonymizer.Movers.Basic;

/// <inheritdoc />
public class InPacketMover : AbstractMover<InPacket>
{
    /// <inheritdoc />
    public override InPacket Move(IAnonymizer anonymizer, InPacket packet)
    {
        return packet with
        {
            EntityId = packet.EntityId,
            Name = packet.Name is null ? null : (NameString)anonymizer.AnonymizeName(packet.Name),
            PlayerSubPacket = packet.PlayerSubPacket is null
                ? null
                : packet.PlayerSubPacket with
                {
                    GroupId = packet.PlayerSubPacket.GroupId is null
                        ? null
                        : anonymizer.AnonymizeId(packet.PlayerSubPacket.GroupId.Value),
                    FamilyName = packet.PlayerSubPacket.FamilyName is null
                        ? null
                        : anonymizer.AnonymizeName(packet.PlayerSubPacket.FamilyName),
                    FamilySubPacket = packet.PlayerSubPacket.FamilySubPacket with
                    {
                        Value = packet.PlayerSubPacket.FamilySubPacket.Value is null
                            ? null
                            : packet.PlayerSubPacket.FamilySubPacket.Value with
                            {
                                FamilyId = anonymizer.AnonymizeName
                                    (packet.PlayerSubPacket.FamilySubPacket.Value.FamilyId)
                            }
                    }
                }
        };
    }
}
Do not follow this link