diff --git a/src/Components/Modules/Logger.cpp b/src/Components/Modules/Logger.cpp index f632a6c3..c9dcd920 100644 --- a/src/Components/Modules/Logger.cpp +++ b/src/Components/Modules/Logger.cpp @@ -195,8 +195,50 @@ namespace Components Logger::MessageMutex.unlock(); } + void Logger::RedirectOSPath(const char* file, char* folder) + { + if (Dvar::Var("g_log").get() == file) + { + if (folder != "userraw"s) + { + if (Dvar::Var("g_log").get()) + { + strcpy_s(folder, 256, "userraw"); + } + } + } + } + + __declspec(naked) void Logger::BuildOSPathStub() + { + __asm + { + pushad + + push [esp + 28h] + push [esp + 30h] + + call Logger::RedirectOSPath + + add esp, 8h + + popad + + mov eax, [esp + 8h] + push ebp + push esi + mov esi, [esp + 0Ch] + + push 64213Fh + retn + } + } + Logger::Logger() { + Dvar::Register("iw4x_onelog", false, Game::dvar_flag::DVAR_FLAG_LATCHED | Game::dvar_flag::DVAR_FLAG_SAVED, "Only write the game log to the 'userraw' OS folder"); + Utils::Hook(0x642139, Logger::BuildOSPathStub, HOOK_JUMP).install()->quick(); + Logger::PipeOutput(nullptr); QuickPatch::OnFrame(Logger::Frame); diff --git a/src/Components/Modules/Logger.hpp b/src/Components/Modules/Logger.hpp index eabab8fa..accafa62 100644 --- a/src/Components/Modules/Logger.hpp +++ b/src/Components/Modules/Logger.hpp @@ -39,6 +39,9 @@ namespace Components static void PrintMessagePipe(const char* data); static void EnqueueMessage(std::string message); + static void BuildOSPathStub(); + static void RedirectOSPath(const char* file, char* folder); + static void NetworkLog(const char* data, bool gLog); static std::string Format(const char** message);