From 451c5c0c10dad9b378ec801ec9c7e19e3fd866e2 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Wed, 4 Jan 2023 23:20:56 +0100 Subject: [PATCH] feat(packets): add inventory packets --- .../Enums/Inventory/BagType.cs | 43 +++++++++++++++++++ .../Server/Inventory/InvPacket.cs | 30 +++++++++++++ .../Server/Inventory/InvSubPacket.cs | 37 ++++++++++++++++ .../Server/Inventory/IvnPacket.cs | 27 ++++++++++++ .../FileClient/Properties/launchSettings.json | 8 ++++ 5 files changed, 145 insertions(+) create mode 100644 Packets/NosSmooth.Packets/Enums/Inventory/BagType.cs create mode 100644 Packets/NosSmooth.Packets/Server/Inventory/InvPacket.cs create mode 100644 Packets/NosSmooth.Packets/Server/Inventory/InvSubPacket.cs create mode 100644 Packets/NosSmooth.Packets/Server/Inventory/IvnPacket.cs create mode 100644 Samples/FileClient/Properties/launchSettings.json diff --git a/Packets/NosSmooth.Packets/Enums/Inventory/BagType.cs b/Packets/NosSmooth.Packets/Enums/Inventory/BagType.cs new file mode 100644 index 0000000000000000000000000000000000000000..e7e79a77d4077ff77ce2848eff78b8c2cf96d681 --- /dev/null +++ b/Packets/NosSmooth.Packets/Enums/Inventory/BagType.cs @@ -0,0 +1,43 @@ +// +// BagType.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. + +namespace NosSmooth.Packets.Enums.Inventory; + +/// +/// A bag in an inventory storing a given type of items. +/// +public enum BagType +{ + /// + /// Equipment bag (first bag inside regular inventory). + /// + Equipment = 0, + + /// + /// Main bag (second bag inside regular inventory). + /// + Main = 1, + + /// + /// Etc bag (first bag inside the inventory). + /// + Etc = 2, + + /// + /// Miniland bag (can be seen after pressing L). + /// + Miniland = 3, + + /// + /// Specialist bag (last bag inside regular inventory, in a new window). + /// + Specialist = 6, + + /// + /// Costume bag (last bag inside regular inventory, in a new window, right under specialist tab.). + /// + Costume = 7 +} \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Inventory/InvPacket.cs b/Packets/NosSmooth.Packets/Server/Inventory/InvPacket.cs new file mode 100644 index 0000000000000000000000000000000000000000..1b968b93949bf938a55fc3c55364a7c2b61ec805 --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Inventory/InvPacket.cs @@ -0,0 +1,30 @@ +// +// InvPacket.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.Inventory; +using NosSmooth.PacketSerializer.Abstractions.Attributes; + +namespace NosSmooth.Packets.Server.Inventory; + +/// +/// Contents of inventory bag. +/// +/// +/// This is sent at startup. +/// For updates, , +/// that is sent after changes. +/// +/// The bag that the items are in. +/// The items inside the bag. +[PacketHeader("inv", PacketSource.Server)] +[GenerateSerializer(true)] +public record InvPacket +( + [PacketIndex(0)] + BagType Bag, + [PacketListIndex(1, InnerSeparator = '.', ListSeparator = ' ')] + IReadOnlyList InvSubPackets +) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Inventory/InvSubPacket.cs b/Packets/NosSmooth.Packets/Server/Inventory/InvSubPacket.cs new file mode 100644 index 0000000000000000000000000000000000000000..ce25170470e769d6f8e77f3bd3227a2b30d2014f --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Inventory/InvSubPacket.cs @@ -0,0 +1,37 @@ +// +// InvSubPacket.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; + +namespace NosSmooth.Packets.Server.Inventory; + +/// +/// A sub packet of +/// containing items in the given bag. +/// +/// The slot the item is in. +/// The vnum of the item. +/// Rare for equipment, otherwise amount. +/// Upgrade for equipment, otherwise design. May not be present. +/// A stone upgrade of sp. Zero for other equipment. Not present otherwise. +/// The rune count for equipment. +[PacketHeader(null, PacketSource.Server)] +[GenerateSerializer(true)] +public record InvSubPacket +( + [PacketIndex(0)] + short Slot, + [PacketIndex(1)] + short? VNum, + [PacketIndex(2)] + short RareOrAmount, + [PacketIndex(3, IsOptional = true)] + short? UpgradeOrDesign, + [PacketIndex(4, IsOptional = true)] + byte? SpStoneUpgrade, + [PacketIndex(5, IsOptional = true)] + int? RuneCount +) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Inventory/IvnPacket.cs b/Packets/NosSmooth.Packets/Server/Inventory/IvnPacket.cs new file mode 100644 index 0000000000000000000000000000000000000000..892c2d2cbd60012eb174e94c0e584c98d097b7a4 --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Inventory/IvnPacket.cs @@ -0,0 +1,27 @@ +// +// IvnPacket.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.Inventory; +using NosSmooth.PacketSerializer.Abstractions.Attributes; + +namespace NosSmooth.Packets.Server.Inventory; + +/// +/// An update of inventory. +/// For inventory initialization, +/// . +/// +/// The bag that should be updated. +/// The data to be updated. +[PacketHeader("ivn", PacketSource.Server)] +[GenerateSerializer(true)] +public record IvnPacket +( + [PacketIndex(0)] + BagType Bag, + [PacketIndex(1, InnerSeparator = '.')] + InvSubPacket InvSubPacket +) : IPacket; \ No newline at end of file diff --git a/Samples/FileClient/Properties/launchSettings.json b/Samples/FileClient/Properties/launchSettings.json new file mode 100644 index 0000000000000000000000000000000000000000..a0a948089d9339fbd7862afde2746ce6e77e9b14 --- /dev/null +++ b/Samples/FileClient/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "FileClient": { + "commandName": "Project", + "commandLineArgs": "D:\\Shared\\Documents\\my_projects\\cheats\\NosSmooth\\Samples\\FileClient\\bin\\Debug\\net7.0\\gf_login" + } + } +} \ No newline at end of file