From 3c60ef8464d38a04ecc1539db023ff65bf4dffe4 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 18 Mar 2026 06:57:15 -0700 Subject: [PATCH] fix: add hex dump diagnostics to spell-go missCount parsing When SMSG_SPELL_GO reads a suspiciously high missCount (>20), log the surrounding packet bytes, castFlags, and position for debugging the persistent offset error causing garbage miss counts (46, 48, 241). --- src/game/world_packets.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/game/world_packets.cpp b/src/game/world_packets.cpp index e6f6d872..d950994e 100644 --- a/src/game/world_packets.cpp +++ b/src/game/world_packets.cpp @@ -3889,7 +3889,27 @@ bool SpellGoParser::parse(network::Packet& packet, SpellGoData& data) { return false; } + const size_t missCountPos = packet.getReadPos(); const uint8_t rawMissCount = packet.readUInt8(); + if (rawMissCount > 20) { + // Likely offset error — dump context bytes for diagnostics. + const auto& raw = packet.getData(); + std::string hexCtx; + size_t dumpStart = (missCountPos >= 8) ? missCountPos - 8 : startPos; + size_t dumpEnd = std::min(missCountPos + 16, raw.size()); + for (size_t i = dumpStart; i < dumpEnd; ++i) { + char buf[4]; + std::snprintf(buf, sizeof(buf), "%02x ", raw[i]); + hexCtx += buf; + if (i == missCountPos - 1) hexCtx += "["; + if (i == missCountPos) hexCtx += "] "; + } + LOG_WARNING("Spell go: suspect missCount=", (int)rawMissCount, + " spell=", data.spellId, " hits=", (int)data.hitCount, + " castFlags=0x", std::hex, data.castFlags, std::dec, + " missCountPos=", missCountPos, " pktSize=", packet.getSize(), + " ctx=", hexCtx); + } if (rawMissCount > 128) { LOG_WARNING("Spell go: missCount capped (requested=", (int)rawMissCount, ") spell=", data.spellId, " hits=", (int)data.hitCount,