[Logger] Decouple NetworkLog from the logFile
This commit is contained in:
parent
8ee1bc1ed9
commit
e2170e96c2
@ -153,22 +153,30 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void Logger::GameLogStub()
|
||||
void Logger::G_LogPrintfStub(const char* fmt, ...)
|
||||
{
|
||||
__asm
|
||||
char string[1024];
|
||||
char string2[1024];
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf_s(string2, _TRUNCATE, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
const auto min = Game::level->time / 1000 / 60;
|
||||
const auto tens = Game::level->time / 1000 % 60 / 10;
|
||||
const auto sec = Game::level->time / 1000 % 60 % 10;
|
||||
|
||||
_snprintf_s(string, _TRUNCATE, "%3i:%i%i %s",
|
||||
min, tens, sec, string2);
|
||||
|
||||
if (Game::level->logFile != nullptr)
|
||||
{
|
||||
pushad
|
||||
|
||||
push 1
|
||||
push [esp + 28h]
|
||||
call Logger::NetworkLog
|
||||
add esp, 8h
|
||||
|
||||
popad
|
||||
|
||||
push 4576C0h
|
||||
retn
|
||||
Game::FS_Write(string, &string[std::strlen(string) + 1] - &string[1], reinterpret_cast<int>(Game::level->logFile));
|
||||
}
|
||||
|
||||
// Allow the network log to run even if logFile was not opened
|
||||
Logger::NetworkLog(string, true);
|
||||
}
|
||||
|
||||
__declspec(naked) void Logger::PrintMessageStub()
|
||||
@ -361,7 +369,7 @@ namespace Components
|
||||
|
||||
Scheduler::Loop(Logger::Frame, Scheduler::Pipeline::SERVER);
|
||||
|
||||
Utils::Hook(0x4B0218, Logger::GameLogStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(Game::G_LogPrintf, Logger::G_LogPrintfStub, HOOK_JUMP).install()->quick();
|
||||
Utils::Hook(Game::Com_PrintMessage, Logger::PrintMessageStub, HOOK_JUMP).install()->quick();
|
||||
|
||||
if (Loader::IsPerformingUnitTests())
|
||||
|
@ -100,7 +100,7 @@ namespace Components
|
||||
static void(*PipeCallback)(const std::string&);
|
||||
|
||||
static void Frame();
|
||||
static void GameLogStub();
|
||||
static void G_LogPrintfStub(const char* fmt, ...);
|
||||
static void PrintMessageStub();
|
||||
static void PrintMessagePipe(const char* data);
|
||||
static void EnqueueMessage(const std::string& message);
|
||||
|
@ -19,7 +19,7 @@ namespace Components
|
||||
void Theatre::RecordGamestateStub()
|
||||
{
|
||||
int sequence = (*Game::serverMessageSequence - 1);
|
||||
Game::FS_Write(&sequence, 4, *Game::demoFile);
|
||||
Game::FS_WriteToDemo(&sequence, 4, *Game::demoFile);
|
||||
}
|
||||
|
||||
void Theatre::StoreBaseline(PBYTE snapshotMsg)
|
||||
@ -62,10 +62,10 @@ namespace Components
|
||||
int byte8 = 8;
|
||||
char byte0 = 0;
|
||||
|
||||
Game::FS_Write(&byte0, 1, *Game::demoFile);
|
||||
Game::FS_Write(Game::serverMessageSequence, 4, *Game::demoFile);
|
||||
Game::FS_Write(&fileCompressedSize, 4, *Game::demoFile);
|
||||
Game::FS_Write(&byte8, 4, *Game::demoFile);
|
||||
Game::FS_WriteToDemo(&byte0, 1, *Game::demoFile);
|
||||
Game::FS_WriteToDemo(Game::serverMessageSequence, 4, *Game::demoFile);
|
||||
Game::FS_WriteToDemo(&fileCompressedSize, 4, *Game::demoFile);
|
||||
Game::FS_WriteToDemo(&byte8, 4, *Game::demoFile);
|
||||
|
||||
for (int i = 0; i < compressedSize; i += 1024)
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace Components
|
||||
break;
|
||||
}
|
||||
|
||||
Game::FS_Write(&cmpData[i], size, *Game::demoFile);
|
||||
Game::FS_WriteToDemo(&cmpData[i], size, *Game::demoFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,8 @@ namespace Game
|
||||
FS_FOpenFileReadForThread_t FS_FOpenFileReadForThread = FS_FOpenFileReadForThread_t(0x643270);
|
||||
FS_FCloseFile_t FS_FCloseFile = FS_FCloseFile_t(0x462000);
|
||||
FS_WriteFile_t FS_WriteFile = FS_WriteFile_t(0x426450);
|
||||
FS_Write_t FS_Write = FS_Write_t(0x4C06E0);
|
||||
FS_WriteToDemo_t FS_WriteToDemo = FS_WriteToDemo_t(0x4C06E0);
|
||||
FS_Write_t FS_Write = FS_Write_t(0x4576C0);
|
||||
FS_Printf_t FS_Printf = FS_Printf_t(0x459320);
|
||||
FS_Read_t FS_Read = FS_Read_t(0x4A04C0);
|
||||
FS_Seek_t FS_Seek = FS_Seek_t(0x4A63D0);
|
||||
|
@ -365,10 +365,13 @@ namespace Game
|
||||
typedef bool(__cdecl * FS_FileExists_t)(const char* file);
|
||||
extern FS_FileExists_t FS_FileExists;
|
||||
|
||||
typedef bool(__cdecl * FS_WriteFile_t)(char* filename, char* folder, void* buffer, int size);
|
||||
typedef bool(__cdecl * FS_WriteFile_t)(const char* filename, const char* folder, const void* buffer, int size);
|
||||
extern FS_WriteFile_t FS_WriteFile;
|
||||
|
||||
typedef int(__cdecl * FS_Write_t)(const void* buffer, size_t size, int file);
|
||||
typedef int(__cdecl * FS_WriteToDemo_t)(const void* buffer, int size, int file);
|
||||
extern FS_WriteToDemo_t FS_WriteToDemo;
|
||||
|
||||
typedef int(__cdecl * FS_Write_t)(const void* buffer, int len, int h);
|
||||
extern FS_Write_t FS_Write;
|
||||
|
||||
typedef int(__cdecl * FS_Printf_t)(int file, const char* fmt, ...);
|
||||
|
Loading…
Reference in New Issue
Block a user