mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 17:43:52 +00:00
fix: use uniform 22-byte loot item size for Classic/TBC/Turtle
SMSG_LOOT_RESPONSE items include randomSuffix and randomPropertyId fields across all expansions, not just WotLK. Using 14-byte size for Classic/TBC caused item data to be read at wrong offsets.
This commit is contained in:
parent
203514abc7
commit
3667ff4998
2 changed files with 16 additions and 22 deletions
|
|
@ -2060,8 +2060,9 @@ public:
|
||||||
/** SMSG_LOOT_RESPONSE parser */
|
/** SMSG_LOOT_RESPONSE parser */
|
||||||
class LootResponseParser {
|
class LootResponseParser {
|
||||||
public:
|
public:
|
||||||
// isWotlkFormat: true for WotLK 3.3.5a (22 bytes/item with randomSuffix+randomProp),
|
// isWotlkFormat: true for WotLK (has trailing quest item section),
|
||||||
// false for Classic 1.12 and TBC 2.4.3 (14 bytes/item).
|
// false for Classic/TBC (no quest item section).
|
||||||
|
// Per-item size is 22 bytes across all expansions.
|
||||||
static bool parse(network::Packet& packet, LootResponseData& data, bool isWotlkFormat = true);
|
static bool parse(network::Packet& packet, LootResponseData& data, bool isWotlkFormat = true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4257,10 +4257,9 @@ bool LootResponseParser::parse(network::Packet& packet, LootResponseData& data,
|
||||||
data.gold = packet.readUInt32();
|
data.gold = packet.readUInt32();
|
||||||
uint8_t itemCount = packet.readUInt8();
|
uint8_t itemCount = packet.readUInt8();
|
||||||
|
|
||||||
// Item wire size:
|
// Per-item wire size is 22 bytes across all expansions:
|
||||||
// WotLK 3.3.5a: slot(1)+itemId(4)+count(4)+displayInfo(4)+randSuffix(4)+randProp(4)+slotType(1) = 22
|
// slot(1)+itemId(4)+count(4)+displayInfo(4)+randSuffix(4)+randProp(4)+slotType(1) = 22
|
||||||
// Classic/TBC: slot(1)+itemId(4)+count(4)+displayInfo(4)+slotType(1) = 14
|
constexpr size_t kItemSize = 22u;
|
||||||
const size_t kItemSize = isWotlkFormat ? 22u : 14u;
|
|
||||||
|
|
||||||
auto parseLootItemList = [&](uint8_t listCount, bool markQuestItems) -> bool {
|
auto parseLootItemList = [&](uint8_t listCount, bool markQuestItems) -> bool {
|
||||||
for (uint8_t i = 0; i < listCount; ++i) {
|
for (uint8_t i = 0; i < listCount; ++i) {
|
||||||
|
|
@ -4270,21 +4269,14 @@ bool LootResponseParser::parse(network::Packet& packet, LootResponseData& data,
|
||||||
}
|
}
|
||||||
|
|
||||||
LootItem item;
|
LootItem item;
|
||||||
item.slotIndex = packet.readUInt8();
|
item.slotIndex = packet.readUInt8();
|
||||||
item.itemId = packet.readUInt32();
|
item.itemId = packet.readUInt32();
|
||||||
item.count = packet.readUInt32();
|
item.count = packet.readUInt32();
|
||||||
item.displayInfoId = packet.readUInt32();
|
item.displayInfoId = packet.readUInt32();
|
||||||
|
item.randomSuffix = packet.readUInt32();
|
||||||
if (isWotlkFormat) {
|
item.randomPropertyId = packet.readUInt32();
|
||||||
item.randomSuffix = packet.readUInt32();
|
item.lootSlotType = packet.readUInt8();
|
||||||
item.randomPropertyId = packet.readUInt32();
|
item.isQuestItem = markQuestItems;
|
||||||
} else {
|
|
||||||
item.randomSuffix = 0;
|
|
||||||
item.randomPropertyId = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
item.lootSlotType = packet.readUInt8();
|
|
||||||
item.isQuestItem = markQuestItems;
|
|
||||||
data.items.push_back(item);
|
data.items.push_back(item);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -4296,8 +4288,9 @@ bool LootResponseParser::parse(network::Packet& packet, LootResponseData& data,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Quest item section only present in WotLK 3.3.5a
|
||||||
uint8_t questItemCount = 0;
|
uint8_t questItemCount = 0;
|
||||||
if (packet.getSize() - packet.getReadPos() >= 1) {
|
if (isWotlkFormat && packet.getSize() - packet.getReadPos() >= 1) {
|
||||||
questItemCount = packet.readUInt8();
|
questItemCount = packet.readUInt8();
|
||||||
data.items.reserve(data.items.size() + questItemCount);
|
data.items.reserve(data.items.size() + questItemCount);
|
||||||
if (!parseLootItemList(questItemCount, true)) {
|
if (!parseLootItemList(questItemCount, true)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue