diff --git a/include/game/world_packets.hpp b/include/game/world_packets.hpp index 3d9695cd..0809ac43 100644 --- a/include/game/world_packets.hpp +++ b/include/game/world_packets.hpp @@ -717,7 +717,9 @@ struct TextEmoteData { */ class TextEmoteParser { public: - static bool parse(network::Packet& packet, TextEmoteData& data); + // legacyFormat: Classic 1.12 and TBC 2.4.3 send textEmoteId+emoteNum first, then senderGuid. + // WotLK 3.3.5a reverses this: senderGuid first, then textEmoteId+emoteNum. + static bool parse(network::Packet& packet, TextEmoteData& data, bool legacyFormat = false); }; // ============================================================ diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 415e5295..d5cbbba5 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -8560,8 +8560,11 @@ void GameHandler::sendTextEmote(uint32_t textEmoteId, uint64_t targetGuid) { } void GameHandler::handleTextEmote(network::Packet& packet) { + // Classic 1.12 and TBC 2.4.3 send: textEmoteId(u32) + emoteNum(u32) + senderGuid(u64) + nameLen(u32) + name + // WotLK 3.3.5a reversed this to: senderGuid(u64) + textEmoteId(u32) + emoteNum(u32) + nameLen(u32) + name + const bool legacyFormat = isClassicLikeExpansion() || isActiveExpansion("tbc"); TextEmoteData data; - if (!TextEmoteParser::parse(packet, data)) { + if (!TextEmoteParser::parse(packet, data, legacyFormat)) { LOG_WARNING("Failed to parse SMSG_TEXT_EMOTE"); return; } diff --git a/src/game/world_packets.cpp b/src/game/world_packets.cpp index d23210c3..275ad5b8 100644 --- a/src/game/world_packets.cpp +++ b/src/game/world_packets.cpp @@ -1510,20 +1510,30 @@ network::Packet TextEmotePacket::build(uint32_t textEmoteId, uint64_t targetGuid return packet; } -bool TextEmoteParser::parse(network::Packet& packet, TextEmoteData& data) { +bool TextEmoteParser::parse(network::Packet& packet, TextEmoteData& data, bool legacyFormat) { size_t bytesLeft = packet.getSize() - packet.getReadPos(); if (bytesLeft < 20) { LOG_WARNING("SMSG_TEXT_EMOTE too short: ", bytesLeft, " bytes"); return false; } - data.senderGuid = packet.readUInt64(); - data.textEmoteId = packet.readUInt32(); - data.emoteNum = packet.readUInt32(); + + if (legacyFormat) { + // Classic 1.12 / TBC 2.4.3: textEmoteId(u32) + emoteNum(u32) + senderGuid(u64) + data.textEmoteId = packet.readUInt32(); + data.emoteNum = packet.readUInt32(); + data.senderGuid = packet.readUInt64(); + } else { + // WotLK 3.3.5a: senderGuid(u64) + textEmoteId(u32) + emoteNum(u32) + data.senderGuid = packet.readUInt64(); + data.textEmoteId = packet.readUInt32(); + data.emoteNum = packet.readUInt32(); + } + uint32_t nameLen = packet.readUInt32(); if (nameLen > 0 && nameLen <= 256) { data.targetName = packet.readString(); } else if (nameLen > 0) { - // Skip garbage + // Implausible name length — misaligned read return false; } return true;