Files
sacred_k/src/re/log.cpp
T
khallaandClaude Opus 5.5 d9f5c85430 Initial sacred_re scaffold with borderless fullscreen mod
- Launcher (sacred_re.exe) starts sacred.exe with sacred_re.dll injected
  via Detours; the DLL verifies the Sacred Gold 2.28 build before hooking.
- Hook framework: RE_HOOK for game addresses, RE_HOOK_API for Windows
  APIs, per-hook enable/disable in sacred_re.ini, sacred_re.log.
- Game code: Log (0x66f1c0) hooked, CmdLineHasFlag (0x813140) rewritten.
- Borderless mod: forces windowed mode, covers the monitor, scales the
  1024x768 image aspect-correct, remaps mouse input, keeps running in the
  background with keyboard input hidden while unfocused.
- CMake/Ninja/MSVC x86 build, VS Code setup, disasm tool, function map.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 23:55:50 +02:00

46 lines
865 B
C++

#include "re/log.h"
#include <cstdarg>
#include <cstdio>
#include <mutex>
#include <windows.h>
namespace re {
namespace {
std::mutex g_mutex;
FILE* g_file = nullptr;
} // namespace
void OpenLog(const wchar_t* path) {
std::lock_guard lock(g_mutex);
if (!g_file) {
g_file = _wfsopen(path, L"w", _SH_DENYWR);
}
}
void Log(const char* fmt, ...) {
char message[1024];
va_list args;
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);
SYSTEMTIME t;
GetLocalTime(&t);
char line[1100];
snprintf(line, sizeof(line), "%02d:%02d:%02d.%03d %s\n", t.wHour, t.wMinute, t.wSecond, t.wMilliseconds,
message);
OutputDebugStringA(line);
std::lock_guard lock(g_mutex);
if (g_file) {
fputs(line, g_file);
fflush(g_file);
}
}
} // namespace re