2022-08-19 21:33:31 +02:00
|
|
|
|
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ========//
|
|
|
|
|
//
|
|
|
|
|
// Purpose:
|
|
|
|
|
//
|
|
|
|
|
// $NoKeywords: $
|
|
|
|
|
//=============================================================================//
|
|
|
|
|
|
|
|
|
|
#include "core/stdafx.h"
|
|
|
|
|
#include "tier0/frametask.h"
|
|
|
|
|
#include "engine/host.h"
|
2022-09-11 23:48:11 +02:00
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
#include "vgui/vgui_debugpanel.h"
|
|
|
|
|
#endif // !DEDICATED
|
2022-08-19 21:33:31 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
_Host_RunFrame
|
|
|
|
|
|
|
|
|
|
Runs all active servers
|
|
|
|
|
==================
|
|
|
|
|
*/
|
|
|
|
|
void _Host_RunFrame(void* unused, float time)
|
|
|
|
|
{
|
2022-09-11 23:48:11 +02:00
|
|
|
|
for (IFrameTask* const& task : g_FrameTasks)
|
2022-08-19 21:33:31 +02:00
|
|
|
|
{
|
|
|
|
|
task->RunFrame();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_FrameTasks.erase(std::remove_if(g_FrameTasks.begin(), g_FrameTasks.end(), [](const IFrameTask* task)
|
|
|
|
|
{
|
|
|
|
|
return task->IsFinished();
|
|
|
|
|
}), g_FrameTasks.end());
|
|
|
|
|
|
2022-09-11 23:48:11 +02:00
|
|
|
|
#ifndef DEDICATED
|
2022-10-26 01:55:36 +02:00
|
|
|
|
g_pOverlay->ShouldDraw(time);
|
2022-09-11 23:48:11 +02:00
|
|
|
|
#endif // !DEDICATED
|
|
|
|
|
|
2022-08-19 21:33:31 +02:00
|
|
|
|
return v_Host_RunFrame(unused, time);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-19 09:43:12 +01:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-19 21:33:31 +02:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-01-25 02:26:52 +01:00
|
|
|
|
void VHost::Attach() const
|
2022-08-19 21:33:31 +02:00
|
|
|
|
{
|
|
|
|
|
DetourAttach((LPVOID*)&v_Host_RunFrame, &_Host_RunFrame);
|
2023-02-19 09:43:12 +01:00
|
|
|
|
|
|
|
|
|
#ifndef DEDICATED // Dedicated already logs this!
|
|
|
|
|
DetourAttach((LPVOID*)&v_Host_Error, &_Host_Error);
|
|
|
|
|
#endif // !DEDICATED
|
2022-08-19 21:33:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-25 02:26:52 +01:00
|
|
|
|
void VHost::Detach() const
|
2022-08-19 21:33:31 +02:00
|
|
|
|
{
|
|
|
|
|
DetourDetach((LPVOID*)&v_Host_RunFrame, &_Host_RunFrame);
|
2023-02-19 09:43:12 +01:00
|
|
|
|
|
|
|
|
|
#ifndef DEDICATED // Dedicated already logs this!
|
|
|
|
|
DetourDetach((LPVOID*)&v_Host_Error, &_Host_Error);
|
|
|
|
|
#endif // !DEDICATED
|
2022-08-19 21:33:31 +02:00
|
|
|
|
}
|