From e4da47b0d72f7bee8cb4f0c143118937283cb751 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 22 Mar 2026 16:53:35 -0700 Subject: [PATCH] feat: add UI_ERROR_MESSAGE events and quest removal notifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fire UI_ERROR_MESSAGE from addUIError() so Lua addons can react to error messages like "Not enough mana" or "Target is too far away". Previously only the C++ overlay callback was notified. Also add addUIInfoMessage() helper for informational system messages. Fire QUEST_REMOVED and QUEST_LOG_UPDATE when quests are removed from the quest log — both via server-driven removal (SMSG_QUEST_UPDATE_FAILED etc.) and player-initiated abandon (CMSG_QUESTLOG_REMOVE_QUEST). Quest tracking addons like Questie register for these events to update their map markers and objective displays. --- include/game/game_handler.hpp | 8 +++++++- src/game/game_handler.cpp | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/game/game_handler.hpp b/include/game/game_handler.hpp index 5bb40efa..c8971854 100644 --- a/include/game/game_handler.hpp +++ b/include/game/game_handler.hpp @@ -1989,7 +1989,13 @@ public: // UI error frame: prominent on-screen error messages (spell can't be cast, etc.) using UIErrorCallback = std::function; void setUIErrorCallback(UIErrorCallback cb) { uiErrorCallback_ = std::move(cb); } - void addUIError(const std::string& msg) { if (uiErrorCallback_) uiErrorCallback_(msg); } + void addUIError(const std::string& msg) { + if (uiErrorCallback_) uiErrorCallback_(msg); + if (addonEventCallback_) addonEventCallback_("UI_ERROR_MESSAGE", {msg}); + } + void addUIInfoMessage(const std::string& msg) { + if (addonEventCallback_) addonEventCallback_("UI_INFO_MESSAGE", {msg}); + } // Reputation change toast: factionName, delta, new standing using RepChangeCallback = std::function; diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index cf3b2d51..e648c2b4 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -5714,6 +5714,10 @@ void GameHandler::handlePacket(network::Packet& packet) { } else { addSystemChatMessage("Quest removed (ID " + std::to_string(questId) + ")."); } + if (addonEventCallback_) { + addonEventCallback_("QUEST_LOG_UPDATE", {}); + addonEventCallback_("QUEST_REMOVED", {std::to_string(questId)}); + } } break; } @@ -21883,6 +21887,10 @@ void GameHandler::abandonQuest(uint32_t questId) { if (localIndex >= 0) { questLog_.erase(questLog_.begin() + static_cast(localIndex)); + if (addonEventCallback_) { + addonEventCallback_("QUEST_LOG_UPDATE", {}); + addonEventCallback_("QUEST_REMOVED", {std::to_string(questId)}); + } } // Remove any quest POI minimap markers for this quest.