Hook 'Host_Error'

'Host_Error' messages were never getting logged until now.
This commit is contained in:
Kawe Mazidjatari 2023-02-19 09:43:12 +01:00
parent 020986fc3b
commit 9e61db4b60
2 changed files with 27 additions and 2 deletions

View File

@ -38,13 +38,38 @@ void _Host_RunFrame(void* unused, float time)
return v_Host_RunFrame(unused, time);
}
void _Host_Error(char* error, ...)
{
char buf[1024];
{/////////////////////////////
va_list args{};
va_start(args, error);
vsnprintf(buf, sizeof(buf), error, args);
buf[sizeof(buf) - 1] = '\0';
va_end(args);
}/////////////////////////////
Error(eDLL_T::ENGINE, NO_ERROR, "Host_Error: %s", buf);
v_Host_Error(buf);
}
///////////////////////////////////////////////////////////////////////////////
void VHost::Attach() const
{
DetourAttach((LPVOID*)&v_Host_RunFrame, &_Host_RunFrame);
#ifndef DEDICATED // Dedicated already logs this!
DetourAttach((LPVOID*)&v_Host_Error, &_Host_Error);
#endif // !DEDICATED
}
void VHost::Detach() const
{
DetourDetach((LPVOID*)&v_Host_RunFrame, &_Host_RunFrame);
#ifndef DEDICATED // Dedicated already logs this!
DetourDetach((LPVOID*)&v_Host_Error, &_Host_Error);
#endif // !DEDICATED
}

View File

@ -7,7 +7,7 @@ inline auto v_Host_RunFrame = p_Host_RunFrame.RCast<void(*)(void* unused, float
//inline auto v_Host_RunFrame_Render = p_Host_RunFrame_Render.RCast<void(*)(void)>();
inline CMemory p_Host_Error;
inline auto v_Host_Error = p_Host_Error.RCast<int(*)(const char* error, ...)>();
inline auto v_Host_Error = p_Host_Error.RCast<void(*)(const char* error, ...)>();
//inline CMemory p_VCR_EnterPausedState; // DEDICATED PATCH!
//inline auto v_VCR_EnterPausedState = p_VCR_EnterPausedState.RCast<void(*)(void)>();
@ -47,7 +47,7 @@ class VHost : public IDetour
v_Host_RunFrame = p_Host_RunFrame.RCast<void(*)(void*, float)>();
//v_Host_RunFrame_Render = p_Host_Error.RCast<void(*)(void)>();
v_Host_Error = p_Host_Error.RCast<int(*)(const char*, ...)>();
v_Host_Error = p_Host_Error.RCast<void(*)(const char*, ...)>();
//v_VCR_EnterPausedState = p_VCR_EnterPausedState.RCast<void(*)(void)>();
}
virtual void GetVar(void) const