diff --git a/DLL_README.md b/DLL_README.md index 68ba4f0..232482c 100644 --- a/DLL_README.md +++ b/DLL_README.md @@ -115,15 +115,18 @@ Logs\\\WoWCombatLog_YYYYMMDD_HHMMSS.txt Logs\\\WoWRawCombatLog_YYYYMMDD_HHMMSS.txt (superwow only) ``` -Session markers are written as the first line of each log file: -- `COMBATLOG_SESSION: ` in combat and raw combat logs -- `CHAT_SESSION: ` in chat logs +Each new game session begins with a marker line (`COMBATLOG_SESSION` or `CHAT_SESSION`) identifying the character and realm. If a log file for the same character was written to within the last 30 minutes, the session continues into the same file instead of creating a new one. -If a log file for the same character was written to within the last 30 minutes, the session continues into the same file instead of creating a new one. This consolidates brief relogs into a single file. +Like any normal log use, logging must be enabled in-game for files to appear: +- **Combat log**: `/combatlog` in chat, or `LoggingCombat(1)` from a macro/addon +- **Chat log**: `/chatlog` in chat, or `LoggingChat(1)` from a macro/addon -Character and realm names are resolved from the character select screen when you click Enter World, so paths are ready before any logging begins. On character logout the session state resets, so the next login gets fresh paths and markers. +Lua API for addon developers: -No configuration needed, install and forget. +- `GetCombatLogPath()` -- returns the current combat log file path +- `GetChatLogPath()` -- returns the current chat log file path + +No other configuration needed, install and forget. **DLL:** `combatlog.dll` diff --git a/src/combatlog/combatlog.zig b/src/combatlog/combatlog.zig index bd1aedd..911dcce 100644 --- a/src/combatlog/combatlog.zig +++ b/src/combatlog/combatlog.zig @@ -14,6 +14,7 @@ const std = @import("std"); const hook = @import("zhook"); const con = @import("../console.zig"); +const lua = @import("../lua.zig"); const o = @import("offsets.zig"); const sc = std.builtin.CallingConvention{ .x86_stdcall = .{} }; @@ -475,6 +476,30 @@ pub fn onShutdown() void { restorePathPointers(); } +// ============================================================================= +// Lua API — log path accessors +// ============================================================================= + +/// GetCombatLogPath() → string or nil +pub fn luaGetCombatLogPath(L: lua.State) callconv(.c) u32 { + if (g_combat_path_len > 0) { + lua.pushstring(L, @ptrCast(g_combat_path[0..g_combat_path_len :0])); + } else { + lua.pushnil(L); + } + return 1; +} + +/// GetChatLogPath() → string or nil +pub fn luaGetChatLogPath(L: lua.State) callconv(.c) u32 { + if (g_chat_path_len > 0) { + lua.pushstring(L, @ptrCast(g_chat_path[0..g_chat_path_len :0])); + } else { + lua.pushnil(L); + } + return 1; +} + // ============================================================================= // Install / remove hooks // ============================================================================= diff --git a/src/core/addon/WeirdUtils.lua b/src/core/addon/WeirdUtils.lua index ae6f403..e5ddf43 100644 --- a/src/core/addon/WeirdUtils.lua +++ b/src/core/addon/WeirdUtils.lua @@ -10,6 +10,14 @@ frame:RegisterEvent("PLAYER_LOGIN") frame:SetScript("OnEvent", function() if event == "PLAYER_LOGIN" then DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00WeirdUtils|r v" .. WEIRDUTILS_VERSION .. " core loaded") + + -- Update log path globals to show actual redirected paths (English locale only) + if GetCombatLogPath and COMBATLOGENABLED == "Combat being logged to Logs\\WoWCombatLog.txt" then + COMBATLOGENABLED = "Combat being logged to " .. GetCombatLogPath() + end + if GetChatLogPath and CHATLOGENABLED == "Chat being logged to Logs\\WoWChatLog.txt" then + CHATLOGENABLED = "Chat being logged to " .. GetChatLogPath() + end end end) diff --git a/src/main.zig b/src/main.zig index 48190dc..52b57c7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -108,6 +108,10 @@ fn registerLuaFunctions() void { if (build_opts.outline) { registerFunction("OutlineCommand", @intFromPtr(&outline.outlineCommand)); } + if (build_opts.combatlog) { + registerFunction("GetCombatLogPath", @intFromPtr(&combatlog.luaGetCombatLogPath)); + registerFunction("GetChatLogPath", @intFromPtr(&combatlog.luaGetChatLogPath)); + } if (build_opts.worldmarkers and markers.isActive()) { // User-facing functions stay global registerFunction("WorldMarker", @intFromPtr(&markers.luaWorldMarker));