Hook WriteFormattedLogMessage to inject session marker before first combat log write

Instead of hooking EnableChatLogging or SignalEvent (which fire too late
or before the log file is open), hook WriteFormattedLogMessage directly.
On the first write to the combat log, prepend COMBATLOG_SESSION with the
player name resolved via the name cache. This guarantees the session
marker is the very first line in the file.

Also add World_HandleLogoutCleanup (0x491180) hook to reset per-session
state on real logout/disconnect (not /reload), and move remove_on_shutdown
cleanup from shutdownDetour to logoutDetour.
This commit is contained in:
MarcelineVQ
2026-03-03 17:38:25 -08:00
parent 049f6cd851
commit 11851c4ece
4 changed files with 130 additions and 84 deletions
-9
View File
@@ -22,15 +22,6 @@ pub const COMBAT_LOG_HANDLE: usize = 0x00b50544;
/// Writes a timestamped, formatted line to the log buffer. Auto-flushes at 48KB.
pub const FN_WRITE_FMT_LOG_MSG: usize = 0x0065ac20;
// =============================================================================
// Combat log enable
// =============================================================================
/// EnableChatLogging — __fastcall(ECX=lua_State, EDX=index).
/// index 0=chat, 1=combat. Called by LoggingCombat()/LoggingChat() Lua functions.
/// Reads path from path_table[index] and opens log file on first enable.
pub const FN_ENABLE_CHAT_LOGGING: usize = 0x0049fe50;
// =============================================================================
// Player identity
// =============================================================================