-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathCraftingHandler.cs
More file actions
209 lines (168 loc) · 8.16 KB
/
CraftingHandler.cs
File metadata and controls
209 lines (168 loc) · 8.16 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
using WowPacketParser.Enums;
using WowPacketParser.Misc;
using WowPacketParser.Parsing;
namespace WowPacketParserModule.V10_0_0_46181.Parsers
{
public static class CraftingHandler
{
public static void ReadSpellReducedReagent(Packet packet, params object[] indexes)
{
packet.ReadInt32("ItemID", indexes);
packet.ReadInt32("Quantity", indexes);
}
public static void ReadCraftingData(Packet packet, params object[] indexes)
{
packet.ReadInt32("CraftingQualityID", indexes);
if (ClientVersion.AddedInVersion(ClientVersionBuild.V10_0_5_47777))
packet.ReadSingle("QualityProgress", indexes);
packet.ReadInt32("SkillLineAbilityID", indexes);
packet.ReadInt32("CraftingDataID", indexes);
packet.ReadInt32("Multicraft", indexes);
packet.ReadInt32("SkillFromReagents", indexes);
packet.ReadInt32("Skill", indexes);
packet.ReadInt32("CritBonusSkill", indexes);
packet.ReadSingle("field_1C", indexes);
packet.ReadUInt64("field_20", indexes);
var resourcesReturnedCount = packet.ReadUInt32();
packet.ReadUInt32("OperationID", indexes);
packet.ReadPackedGuid128("ItemGUID", indexes);
packet.ReadInt32("Quantity", indexes);
packet.ReadInt32("EnchantID", indexes);
for (var i = 0u; i < resourcesReturnedCount; i++)
ReadSpellReducedReagent(packet, indexes, "ResourcesReturned", i);
packet.ReadBit("IsCrit", indexes);
packet.ReadBit("field_29", indexes);
packet.ReadBit("field_2A", indexes);
packet.ReadBit("BonusCraft", indexes);
packet.ResetBitReader();
Substructures.ItemHandler.ReadItemInstance(packet, "OldItem");
Substructures.ItemHandler.ReadItemInstance(packet, "NewItem");
}
public static void ReadCraftingOrderClientContext(Packet packet, params object[] indexes)
{
packet.ReadByte("OrderType", indexes);
packet.ReadUInt32("Offset", indexes);
packet.ReadBit("ForCrafter", indexes);
packet.ReadBit("IsMyOrders", indexes);
packet.ReadBit("field_3", indexes);
packet.ReadBit("field_4", indexes);
packet.ResetBitReader();
}
public static void ReadCraftingOrderBucketInfo(Packet packet, params object[] indexes)
{
packet.ReadBits("SkillLineAbilityID", 20, indexes);
packet.ResetBitReader();
packet.ReadInt32("NumAvailable", indexes);
packet.ReadUInt64("TipAmountMax", indexes);
packet.ReadUInt64("TipAmountAvg", indexes);
}
public static void ReadCraftingOrderItem(Packet packet, params object[] indexes)
{
packet.ReadUInt64("field_0", indexes);
packet.ReadPackedGuid128("ItemGUID", indexes);
packet.ReadPackedGuid128("OwnerGUID", indexes);
packet.ReadInt32<ItemId>("ItemID", indexes);
packet.ReadUInt32("Quantity", indexes);
packet.ReadInt32("ReagentQuality", indexes);
var hasDataSlotIndex = packet.ReadBit();
packet.ResetBitReader();
if (hasDataSlotIndex)
packet.ReadByte("DataSlotIndex", indexes);
}
public static void ReadCraftingOrderCustomer(Packet packet, params object[] indexes)
{
packet.ReadPackedGuid128("CustomerGUID", indexes);
packet.ReadPackedGuid128("CustomerAccountGUID", indexes);
}
public static void ReadCraftingOrderNpcCustomer(Packet packet, params object[] indexes)
{
packet.ReadInt64("NpcCraftingOrderCustomerID", indexes);
packet.ReadInt32("NpcCraftingOrderSetFlags", indexes);
}
public static void ReadCraftingOrderData(Packet packet, params object[] indexes)
{
packet.ReadInt32("field_0", indexes);
packet.ReadUInt64("OrderID", indexes);
packet.ReadInt32("SkillLineAbilityID", indexes);
if (ClientVersion.AddedInVersion(ClientVersionBuild.V11_1_5_60392))
packet.ReadInt32("OrderState", indexes);
else
packet.ReadByte("OrderState", indexes);
packet.ReadByte("OrderType", indexes);
packet.ReadByte("MinQuality", indexes);
packet.ReadTime64("ExpirationTime", indexes);
packet.ReadTime64("ClaimEndTime", indexes);
packet.ReadUInt64("TipAmount", indexes);
packet.ReadUInt64("ConsortiumCut", indexes);
packet.ReadUInt32("Flags", indexes);
if (ClientVersion.RemovedInVersion(ClientVersionBuild.V11_0_2_55959))
ReadCraftingOrderCustomer(packet, indexes, "Customer");
packet.ReadPackedGuid128("CrafterGUID", indexes);
packet.ReadPackedGuid128("PersonalCrafterGUID", indexes);
if (ClientVersion.AddedInVersion(ClientVersionBuild.V11_0_2_55959))
{
packet.ReadInt32("NpcCraftingOrderSetID", indexes);
packet.ReadInt32("NpcTreasureID", indexes);
}
var reagentsCount = packet.ReadUInt32();
var customerNotesLength = packet.ReadBits(10);
var hasCustomer = false;
var hasNpcCraftingData = false;
if (ClientVersion.AddedInVersion(ClientVersionBuild.V11_0_2_55959))
{
hasCustomer = packet.ReadBit();
hasNpcCraftingData = packet.ReadBit();
}
var hasOutputItem = packet.ReadBit();
var hasOutputItemData = packet.ReadBit();
packet.ResetBitReader();
for (var i = 0u; i < reagentsCount; ++i)
ReadCraftingOrderItem(packet, indexes, "Reagents", i);
packet.ReadWoWString("CustomerNotes", customerNotesLength, indexes);
if (hasCustomer)
ReadCraftingOrderCustomer(packet, indexes, "Customer");
if (hasNpcCraftingData)
ReadCraftingOrderNpcCustomer(packet, indexes, "NpcCustomer");
if (hasOutputItem)
ReadCraftingOrderItem(packet, indexes, "OutputItem");
if (hasOutputItemData)
Substructures.ItemHandler.ReadItemInstance(packet, indexes, "OutputItemInfo");
}
public static void ReadCraftingOrder(Packet packet, params object[] indexes)
{
ReadCraftingOrderData(packet, indexes, "Data");
var hasRecraftItemInfo = packet.ReadBit();
var enchantmentsCount = packet.ReadBits(4);
var gemCount = packet.ReadBits(2);
packet.ResetBitReader();
if (hasRecraftItemInfo)
Substructures.ItemHandler.ReadItemInstance(packet, indexes, "OutputItemInfo");
for (var i = 0u; i < enchantmentsCount; ++i)
{
packet.ReadInt32("ID", indexes, "Enchantments", i);
packet.ReadUInt32("Expiration", indexes, "Enchantments", i);
packet.ReadInt32("Charges", indexes, "Enchantments", i);
packet.ReadByte("Slot", indexes, "Enchantments", i);
}
for (var i = 0u; i < gemCount; ++i)
Substructures.ItemHandler.ReadItemGemData(packet, indexes, "Gems", i);
}
[Parser(Opcode.SMSG_CRAFTING_ORDER_LIST_ORDERS_RESPONSE)]
public static void HandleCraftingOrderListOrdersResponse(Packet packet)
{
packet.ReadByte("Result");
var bucketCount = packet.ReadUInt32();
var orderCount = packet.ReadUInt32();
packet.ReadUInt32("DesiredDelay");
packet.ReadUInt32("NumOrders");
packet.ReadBit("HasMoreResults");
packet.ReadBit("IsSorted");
packet.ResetBitReader();
ReadCraftingOrderClientContext(packet, "ClientContext");
for (var i = 0u; i < bucketCount; ++i)
ReadCraftingOrderBucketInfo(packet, "Buckets", i);
for (var i = 0u; i < orderCount; ++i)
ReadCraftingOrder(packet, "Orders", i);
}
}
}