From 3ff43a530f63c0ef234de2bad2a81af29a1b65fb Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 20 Mar 2026 13:27:27 -0700 Subject: [PATCH] feat: add hooksecurefunc, UIParent, and noop stubs for addon compat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - hooksecurefunc(tblOrName, name, hook) — hook any function to run additional code after it executes without replacing the original. Supports both global and table method forms. - UIParent, WorldFrame — standard parent frames that many addons reference as parents for their own frames. - Noop stubs: SetDesaturation, SetPortraitTexture, PlaySound, PlaySoundFile — prevent errors from addons that call these visual/audio functions which don't have implementations yet. --- src/addons/lua_engine.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index dc224549..b0b524d5 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -932,6 +932,36 @@ void LuaEngine::registerCoreAPI() { "end\n" "ChatFrame1 = DEFAULT_CHAT_FRAME\n" ); + + // hooksecurefunc — hook a function to run additional code after it + luaL_dostring(L_, + "function hooksecurefunc(tblOrName, nameOrFunc, funcOrNil)\n" + " local tbl, name, hook\n" + " if type(tblOrName) == 'table' then\n" + " tbl, name, hook = tblOrName, nameOrFunc, funcOrNil\n" + " else\n" + " tbl, name, hook = _G, tblOrName, nameOrFunc\n" + " end\n" + " local orig = tbl[name]\n" + " if type(orig) ~= 'function' then return end\n" + " tbl[name] = function(...)\n" + " local r = {orig(...)}\n" + " hook(...)\n" + " return unpack(r)\n" + " end\n" + "end\n" + ); + + // Noop stubs for commonly called functions that don't need implementation + luaL_dostring(L_, + "function SetDesaturation() end\n" + "function SetPortraitTexture() end\n" + "function PlaySound() end\n" + "function PlaySoundFile() end\n" + "function UIParent_OnEvent() end\n" + "UIParent = CreateFrame('Frame', 'UIParent')\n" + "WorldFrame = CreateFrame('Frame', 'WorldFrame')\n" + ); } // ---- Event System ----