fix: fire CHAT_MSG_* events for player's own messages and system text

addLocalChatMessage only pushed to chatHistory and called the C++
display callback — it never fired Lua addon events. This meant the
player's own sent messages (local echoes from sendChatMessage) and
system messages (loot, XP gains, errors) were invisible to Lua chat
frame addons.

Now fires CHAT_MSG_{type} with the full 12-arg WoW signature from
addLocalChatMessage, matching the incoming message path. Uses the
active character name as sender for player-originated messages.
This commit is contained in:
Kelsi 2026-03-22 16:43:13 -07:00
parent f37a83fc52
commit a8c241f6bd

View file

@ -14972,6 +14972,24 @@ void GameHandler::addLocalChatMessage(const MessageChatData& msg) {
chatHistory.pop_front();
}
if (addonChatCallback_) addonChatCallback_(msg);
// Fire CHAT_MSG_* for local echoes (player's own messages, system messages)
// so Lua chat frame addons display them.
if (addonEventCallback_) {
std::string eventName = "CHAT_MSG_";
eventName += getChatTypeString(msg.type);
const Character* ac = getActiveCharacter();
std::string senderName = msg.senderName.empty()
? (ac ? ac->name : std::string{}) : msg.senderName;
char guidBuf[32];
snprintf(guidBuf, sizeof(guidBuf), "0x%016llX",
(unsigned long long)(msg.senderGuid != 0 ? msg.senderGuid : playerGuid));
addonEventCallback_(eventName, {
msg.message, senderName,
std::to_string(static_cast<int>(msg.language)),
msg.channelName, senderName, "", "0", "0", "", "0", "0", guidBuf
});
}
}
// ============================================================