[Logger] Add iw4x_onelog dvar

This commit is contained in:
momo5502 2017-02-25 01:17:11 +01:00
parent fe126a4308
commit 86e1f6f807
2 changed files with 45 additions and 0 deletions

View File

@ -195,8 +195,50 @@ namespace Components
Logger::MessageMutex.unlock(); Logger::MessageMutex.unlock();
} }
void Logger::RedirectOSPath(const char* file, char* folder)
{
if (Dvar::Var("g_log").get<std::string>() == file)
{
if (folder != "userraw"s)
{
if (Dvar::Var("g_log").get<bool>())
{
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() Logger::Logger()
{ {
Dvar::Register<bool>("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); Logger::PipeOutput(nullptr);
QuickPatch::OnFrame(Logger::Frame); QuickPatch::OnFrame(Logger::Frame);

View File

@ -39,6 +39,9 @@ namespace Components
static void PrintMessagePipe(const char* data); static void PrintMessagePipe(const char* data);
static void EnqueueMessage(std::string message); 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 void NetworkLog(const char* data, bool gLog);
static std::string Format(const char** message); static std::string Format(const char** message);