From 94490807885c9a69f3ef36392ab882613d806e02 Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Tue, 1 Sep 2026 16:13:53 +0200 Subject: [PATCH] Support Modernization Tool data directory --- src/WowPresence.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/WowPresence.c b/src/WowPresence.c index b10cceb..e0afa75 100644 --- a/src/WowPresence.c +++ b/src/WowPresence.c @@ -3,8 +3,8 @@ * Read-only WoW 1.12.1 (build 5875) status sampler for WowPresence. * * Runtime contract: - * \WowPresence\discord_wow_status.json - * \WowPresence\discord_broadcast_flags + * standalone: \WowPresence\... + * Modernization Tool: \.modernization_tool\WowPresence\... * * Discord IPC is intentionally out of process. After the first sample, this * DLL starts WowPresence.exe from its worker thread and passes the exact @@ -541,11 +541,34 @@ static int game_folder(char *output, size_t output_size) { return 1; } +static int directory_exists(const char *path) { + DWORD attrs; + if (!path || !path[0]) return 0; + attrs = GetFileAttributesA(path); + return attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY); +} + static int support_folder(char *output, size_t output_size) { - char root[MAX_PATH]; + char root[MAX_PATH], managed[MAX_PATH]; int count; if (!game_folder(root, sizeof(root))) return 0; + /* Modernization Tool creates this directory before WoW starts. Prefer it + * when present so the same binaries can use the tool-managed location. */ + count = _snprintf( + managed, + sizeof(managed), + "%s\\.modernization_tool\\WowPresence", + root + ); + managed[sizeof(managed) - 1] = 0; + if (count >= 0 && (size_t)count < sizeof(managed) && directory_exists(managed)) { + if (strlen(managed) + 1u > output_size) return 0; + lstrcpynA(output, managed, (int)output_size); + return 1; + } + + /* Standalone installs keep their data in \\WowPresence. */ count = _snprintf(output, output_size, "%s\\WowPresence", root); if (output_size) output[output_size - 1] = 0; if (count < 0 || (size_t)count >= output_size) return 0;