Skip to content

Commit

Permalink
Added parsing for treasure picker opcodes (TWW)
Browse files Browse the repository at this point in the history
  • Loading branch information
meji46 committed Nov 13, 2024
1 parent 7052e1f commit d51ff5f
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 3 deletions.
85 changes: 85 additions & 0 deletions WowPacketParserModule.V11_0_0_55666/Parsers/QueryHandler.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit d51ff5f

Please sign in to comment.