From 189b040bf337a79559fb8821839b361c62933752 Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Sat, 29 Aug 2026 10:32:33 +0200 Subject: [PATCH] V35: add automatic target sync Lua callback --- src/outline/outline.zig | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/outline/outline.zig b/src/outline/outline.zig index 36a5889..24bad8f 100644 --- a/src/outline/outline.zig +++ b/src/outline/outline.zig @@ -152,12 +152,9 @@ pub fn outlineCommand(L: lua.State) callconv(.{ .x86_thiscall = .{} }) u32 { return 1; } -/// Return a compact sticky diagnostic line for in-game testing. -/// Usage: -/// /run DEFAULT_CHAT_FRAME:AddMessage(OutlineDebug()) -pub fn outlineDebug(L: lua.State) callconv(.{ .x86_thiscall = .{} }) u32 { - // Capture player/target from the context where GetGUIDFromName is known to - // work on this client, then pin the resolved objects for the render thread. +fn syncTargetFromLuaContext() void { + // WoW unit/object helpers are reliable from the Lua/main-thread context. + // Publish the current player/target pointers atomically for the render thread. const player_guid = wow.unitGUID("player"); const target_guid = wow.unitGUID("target"); const player_obj = if (player_guid != 0) wow.getObjectByGUID(player_guid) else 0; @@ -166,6 +163,22 @@ pub fn outlineDebug(L: lua.State) callconv(.{ .x86_thiscall = .{} }) u32 { if (player_guid != 0) tracker.debug_unit_player_guid_seen = true; if (target_guid != 0) tracker.debug_unit_target_guid_seen = true; +} + +/// Synchronize the selected target from the safe Lua/main-thread context. +/// Called automatically by the embedded addon on PLAYER_LOGIN and +/// PLAYER_TARGET_CHANGED; no user command is required. +pub fn outlineSyncTarget(_: lua.State) callconv(.{ .x86_thiscall = .{} }) u32 { + syncTargetFromLuaContext(); + return 0; +} + +/// Return a compact sticky diagnostic line for in-game testing. +/// Usage: +/// /run DEFAULT_CHAT_FRAME:AddMessage(OutlineDebug()) +pub fn outlineDebug(L: lua.State) callconv(.{ .x86_thiscall = .{} }) u32 { + // Keep debug useful, but normal operation no longer depends on it. + syncTargetFromLuaContext(); _ = d3d9_hook.lateRehookIfLost(); const live = d3d9_hook.getLiveHookState();