From d51ff5f39a1b093f54ec7bfb39cb01f35d5e89a2 Mon Sep 17 00:00:00 2001 From: Meji Date: Wed, 13 Nov 2024 22:43:33 +0100 Subject: [PATCH] Added parsing for treasure picker opcodes (TWW) --- .../Parsers/QueryHandler.cs | 85 +++++++++++++++++++ .../Parsers/ReputationHandler.cs | 6 +- 2 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 WowPacketParserModule.V11_0_0_55666/Parsers/QueryHandler.cs diff --git a/WowPacketParserModule.V11_0_0_55666/Parsers/QueryHandler.cs b/WowPacketParserModule.V11_0_0_55666/Parsers/QueryHandler.cs new file mode 100644 index 0000000000..5331510720 --- /dev/null +++ b/WowPacketParserModule.V11_0_0_55666/Parsers/QueryHandler.cs @@ -0,0 +1,85 @@ + +using WowPacketParser.Enums; +using WowPacketParser.Misc; +using WowPacketParser.Parsing; + +namespace WowPacketParserModule.V11_0_0_55666.Parsers +{ + public static class QueryHandler + { + [Parser(Opcode.CMSG_QUERY_TREASURE_PICKER)] + public static void HandleQueryQuestRewards(Packet packet) + { + packet.ReadInt32("QuestID"); + packet.ReadInt32("TreasurePickerID"); + } + + public static void ReadTreasurePickItem(Packet packet, params object[] indexes) + { + Substructures.ItemHandler.ReadItemInstance(packet, indexes); + packet.ReadUInt32("Quantity", indexes); + var hasContextFlags = packet.ReadBit("HasContextFlags", indexes); + packet.ResetBitReader(); + + if (hasContextFlags) + packet.ReadInt32("ContextFlags", indexes); + } + + public static void ReadTreasurePickCurrency(Packet packet, params object[] indexes) + { + packet.ReadUInt32("CurrencyID", indexes); + packet.ReadUInt32("Quantity", indexes); + var hasContextFlags = packet.ReadBit("HasContextFlags", indexes); + packet.ResetBitReader(); + + if (hasContextFlags) + packet.ReadInt32("ContextFlags", indexes); + } + + public static void ReadTreasurePickerBonus(Packet packet, params object[] indexes) + { + var bonusItemCount = packet.ReadUInt32("BonusItemCount", indexes); + var bonusCurrencyCount = packet.ReadUInt32("BonusCurrencyCount", indexes); + packet.ReadUInt64("BonusMoney", indexes); + packet.ReadBit("BonusContext", indexes); + packet.ResetBitReader(); + + for (var i = 0; i < bonusItemCount; ++i) + ReadTreasurePickItem(packet, indexes, i); + + for (var i = 0; i < bonusCurrencyCount; ++i) + ReadTreasurePickCurrency(packet, indexes, i); + } + + public static void ReadTreasurePick(Packet packet) + { + var itemCount = packet.ReadUInt32("ItemCount"); + var currencyCount = packet.ReadUInt32("CurrencyCount"); + + packet.ReadUInt64("Money"); + + var bonusCount = packet.ReadUInt32("BonusCount"); + + packet.ReadUInt32("Flags"); + packet.ReadBit("IsChoice"); + packet.ResetBitReader(); + + for (var i = 0; i < itemCount; ++i) + ReadTreasurePickItem(packet, i); + + for (int i = 0; i < currencyCount; i++) + ReadTreasurePickCurrency(packet, i); + + for (var i = 0; i < bonusCount; ++i) + ReadTreasurePickerBonus(packet, i); + } + + [Parser(Opcode.SMSG_TREASURE_PICKER_RESPONSE)] + public static void HandleTreasurePickerResponse(Packet packet) + { + packet.ReadUInt32("QuestID"); + packet.ReadUInt32("TreasurePickerID"); + ReadTreasurePick(packet); + } + } +} diff --git a/WowPacketParserModule.V4_4_0_54481/Parsers/ReputationHandler.cs b/WowPacketParserModule.V4_4_0_54481/Parsers/ReputationHandler.cs index 4db551b32d..edce98b0f6 100644 --- a/WowPacketParserModule.V4_4_0_54481/Parsers/ReputationHandler.cs +++ b/WowPacketParserModule.V4_4_0_54481/Parsers/ReputationHandler.cs @@ -49,7 +49,8 @@ public static void HandleInitializeFactions(Packet packet) if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_4_1_57294)) packet.ReadInt32("FactionID"); - packet.ReadBool("FactionHasBonus", i); + packet.ReadBit("FactionHasBonus", i); + packet.ResetBitReader(); } } @@ -88,8 +89,7 @@ public static void HandleSetFactionStanding(Packet packet) for (int i = 0; i < count; i++) ReadFactionStandingData(packet, i); - packet.ResetBitReader(); - packet.ReadBool("ShowVisual"); + packet.ReadBit("ShowVisual"); } [Parser(Opcode.CMSG_SET_FACTION_AT_WAR)]