fix: replace fragile heuristic in SMSG_INITIAL_SPELLS with explicit Classic format flag

Classic 1.12 uses uint16 spellId + uint16 slot (4 bytes/spell); TBC and WotLK
use uint32 spellId + uint16 unknown (6 bytes/spell). The old size-based heuristic
could misdetect TBC packets that happened to fit both layouts. Add a vanillaFormat
parameter to InitialSpellsParser::parse and override parseInitialSpells in
ClassicPacketParsers to always pass true, eliminating the ambiguity.
This commit is contained in:
Kelsi 2026-03-11 04:38:30 -07:00
parent 9d0da6242d
commit ed48a3c425
3 changed files with 12 additions and 10 deletions

View file

@ -2901,18 +2901,13 @@ bool XpGainParser::parse(network::Packet& packet, XpGainData& data) {
// Phase 3: Spells, Action Bar, Auras
// ============================================================
bool InitialSpellsParser::parse(network::Packet& packet, InitialSpellsData& data) {
size_t packetSize = packet.getSize();
bool InitialSpellsParser::parse(network::Packet& packet, InitialSpellsData& data,
bool vanillaFormat) {
data.talentSpec = packet.readUInt8();
uint16_t spellCount = packet.readUInt16();
// Detect vanilla (uint16 spellId) vs WotLK (uint32 spellId) format
// Vanilla: 4 bytes/spell (uint16 id + uint16 slot), WotLK: 6 bytes/spell (uint32 id + uint16 unk)
size_t remainingAfterHeader = packetSize - 3; // subtract talentSpec(1) + spellCount(2)
bool vanillaFormat = remainingAfterHeader < static_cast<size_t>(spellCount) * 6 + 2;
LOG_DEBUG("SMSG_INITIAL_SPELLS: packetSize=", packetSize, " bytes, spellCount=", spellCount,
vanillaFormat ? " (vanilla uint16 format)" : " (WotLK uint32 format)");
LOG_DEBUG("SMSG_INITIAL_SPELLS: spellCount=", spellCount,
vanillaFormat ? " (vanilla uint16 format)" : " (TBC/WotLK uint32 format)");
data.spellIds.reserve(spellCount);
for (uint16_t i = 0; i < spellCount; ++i) {