tbc: fix SMSG_CAST_RESULT — no castCount prefix in TBC 2.4.3

TBC 2.4.3 SMSG_CAST_RESULT sends spellId(u32) + result(u8) = 5 bytes.
WotLK 3.3.5a added a castCount(u8) prefix making it 6 bytes.  Without
this fix the WotLK parser was reading spellId[0] as castCount, then the
remaining 3 spellId bytes plus result byte as spellId (wrong), and then
whatever follows as result — producing incorrect failure messages and
potentially not clearing the cast bar on TBC.

Add TbcPacketParsers::parseCastResult override and a virtual base method,
then route SMSG_CAST_RESULT through virtual dispatch in the game handler.
This commit is contained in:
Kelsi 2026-03-09 21:46:18 -07:00
parent 1b2c7f595e
commit 921c83df2e
3 changed files with 40 additions and 10 deletions

View file

@ -110,6 +110,19 @@ public:
return CastFailedParser::parse(packet, data);
}
/** Parse SMSG_CAST_RESULT header (spellId + result), expansion-aware.
* WotLK: castCount(u8) + spellId(u32) + result(u8)
* TBC/Classic: spellId(u32) + result(u8) (no castCount prefix)
*/
virtual bool parseCastResult(network::Packet& packet, uint32_t& spellId, uint8_t& result) {
// WotLK default: skip castCount, read spellId + result
if (packet.getSize() - packet.getReadPos() < 6) return false;
packet.readUInt8(); // castCount
spellId = packet.readUInt32();
result = packet.readUInt8();
return true;
}
/** Parse SMSG_AURA_UPDATE / SMSG_AURA_UPDATE_ALL */
virtual bool parseAuraUpdate(network::Packet& packet, AuraUpdateData& data, bool isAll = false) {
return AuraUpdateParser::parse(packet, data, isAll);
@ -307,6 +320,8 @@ public:
bool parseMonsterMove(network::Packet& packet, MonsterMoveData& data) override;
// TBC 2.4.3 SMSG_GOSSIP_MESSAGE quests lack questFlags(u32)+isRepeatable(u8) (WotLK added them)
bool parseGossipMessage(network::Packet& packet, GossipMessageData& data) override;
// TBC 2.4.3 SMSG_CAST_RESULT: spellId(u32) + result(u8) — WotLK added castCount(u8) prefix
bool parseCastResult(network::Packet& packet, uint32_t& spellId, uint8_t& result) override;
// TBC 2.4.3 SMSG_MAIL_LIST_RESULT: uint8 count (not uint32+uint8), no body field,
// attachment uses uint64 itemGuid (not uint32), enchants are 7×u32 id-only (not 7×{id+dur+charges})
bool parseMailList(network::Packet& packet, std::vector<MailMessage>& inbox) override;