fix missing pairs for loop

This commit is contained in:
Jrc13245
2026-01-10 11:17:59 -05:00
parent 1160baedc9
commit 95e58f6d7d
2 changed files with 26 additions and 2 deletions
+25 -1
View File
@@ -58,6 +58,7 @@ function CleveRoids.RegisterExtension(name)
eventHandlers = {},
hooks = {},
memberHooks = {},
activeHooks = {}, -- Re-entrancy guard: tracks hooks currently executing
},
}
@@ -89,18 +90,41 @@ function CleveRoids.RegisterExtension(name)
-- This is a function wrapper that we swap with the function that we want to hook
-- @return Value of Callback() or Origininal() if dontCallOriginal is false
extension.internal.OnHook = function(object, functionName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
local hook
-- Generate a unique key for this hook (handles both global and method hooks)
local hookKey = tostring(object or "global") .. ":" .. functionName
-- Re-entrancy guard: if this hook is already executing, call original directly
if extension.internal.activeHooks[hookKey] then
local hook
if object then
hook = extension.internal.memberHooks[object][functionName]
else
hook = extension.internal.hooks[functionName]
end
if hook and hook.original then
return hook.original(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
end
return
end
local hook
if object then
hook = extension.internal.memberHooks[object][functionName]
else
hook = extension.internal.hooks[functionName]
end
-- Mark this hook as active
extension.internal.activeHooks[hookKey] = true
local retval = hook.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
if not hook.dontCallOriginal then
retval = hook.original(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
end
-- Mark this hook as inactive
extension.internal.activeHooks[hookKey] = nil
return retval
end
+1 -1
View File
@@ -285,7 +285,7 @@ do
local function getBest()
local bestSource, bestUnit, bestP = nil, nil, -1
for source, unit in CleveRoids.__mo.sources do
for source, unit in pairs(CleveRoids.__mo.sources) do
if unit and unit ~= "" then
local p = getPriority(source)
if p > bestP then