Fix crash when loggers are used before detour init

'v_Plat_FloatTime' is only initialized during detour init. Using the loggers before will cause a crash. Code now logs 0.0 when v_Plat_FloatTime is nullptr. Showing 0.0 at this stage is correct as the game dll isn't initialized by then.
This commit is contained in:
Kawe Mazidjatari 2022-12-02 21:54:34 +01:00
parent b90d6f929c
commit 75ae4d2bcf

View File

@ -26,7 +26,7 @@ uint64_t Plat_MSTime()
const char* Plat_GetProcessUpTime()
{
static char szBuf[4096];
sprintf_s(szBuf, sizeof(szBuf), "[%.3f] ", Plat_FloatTime());
sprintf_s(szBuf, sizeof(szBuf), "[%.3f] ", v_Plat_FloatTime ? Plat_FloatTime() : 0.0);
return szBuf;
}
@ -38,5 +38,5 @@ const char* Plat_GetProcessUpTime()
//-----------------------------------------------------------------------------
void Plat_GetProcessUpTime(char* szBuf, size_t nSize)
{
sprintf_s(szBuf, nSize, "[%.3f] ", Plat_FloatTime());
sprintf_s(szBuf, nSize, "[%.3f] ", v_Plat_FloatTime ? Plat_FloatTime() : 0.0);
}