fix: hook the real class table via metatable.__index (getmetatable may return a wrapper whose raw fields are invisible to instance lookups) + pointer-trace diag to prove hook actually sits on the call path

This commit is contained in:
2026-10-03 15:37:48 -04:00
parent dfcafb9f4a
commit c274d177ec
@@ -43,6 +43,9 @@ local function ensure_automark_tag_hook()
return
end
local cls = getmetatable(smart_tag_system)
if type(cls) == "table" and rawget(cls, "set_tag") == nil then
cls = rawget(cls, "__index") or cls
end
if type(cls) == "table" and cls.set_tag ~= nil then
mod:hook(cls, "set_tag", function(previous_hook, self, template_name, tagger_unit, target_unit, target_location)
if template_name == HACK_TAG_NAME and mod_settings.debug_mode and not mod.omni_hack_hook_fired then
@@ -74,8 +77,9 @@ local function ensure_automark_tag_hook()
return previous_hook(self, template_name, tagger_unit, target_unit, target_location)
end)
mod.omni_hack_tag_hooked = true
mod.omni_hack_hooked_ptr = tostring(cls.set_tag)
if mod_settings.debug_mode then
mod:diag("OMNI-HACK-DIAG set_tag hook INSTALLED")
mod:diag("OMNI-HACK-DIAG set_tag hook INSTALLED cls_ptr=", tostring(cls.set_tag), " sys_ptr=", tostring(smart_tag_system.set_tag), " same_sys_obj=", tostring(smart_tag_system == context.smart_tag_system))
end
elseif mod_settings.debug_mode and not mod.omni_hack_taghook_fail_logged then
mod.omni_hack_taghook_fail_logged = true
@@ -389,6 +393,10 @@ function mod:auto_hack(dt, t, fixed_frame)
if not target_unit then
return
end
if mod_settings.debug_mode and not mod.omni_hack_ptr_logged then
mod.omni_hack_ptr_logged = true
mod:diag("OMNI-HACK-DIAG call-site sys_ptr=", tostring(smart_tag_system.set_tag), " hooked_ptr=", tostring(mod.omni_hack_hooked_ptr))
end
local target_tag = smart_tag_system:unit_tag(target_unit)
local tagger_player = target_tag and target_tag._tagger_player