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
|
2024-04-05 16:45:05 +02:00
|
|
|
|
#include "windows/id3dx.h"
|
|
|
|
|
#include "geforce/reflex.h"
|
2022-09-11 23:48:11 +02:00
|
|
|
|
#include "vgui/vgui_debugpanel.h"
|
2023-12-25 19:23:01 +01:00
|
|
|
|
#include <materialsystem/cmaterialsystem.h>
|
2022-09-11 23:48:11 +02:00
|
|
|
|
#endif // !DEDICATED
|
2022-08-19 21:33:31 +02:00
|
|
|
|
|
2023-09-17 16:44:18 +02:00
|
|
|
|
CCommonHostState* g_pCommonHostState = nullptr;
|
|
|
|
|
|
|
|
|
|
void CCommonHostState::SetWorldModel(model_t* pModel)
|
|
|
|
|
{
|
|
|
|
|
if (worldmodel == pModel)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
worldmodel = pModel;
|
|
|
|
|
if (pModel)
|
|
|
|
|
{
|
|
|
|
|
worldbrush = pModel->brush.pShared;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
worldbrush = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-05 16:45:05 +02:00
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
Host_CountRealTimePackets
|
|
|
|
|
|
|
|
|
|
Counts the number of
|
|
|
|
|
packets in non-prescaled
|
|
|
|
|
clock frames (does not
|
|
|
|
|
count for bots or Terminal
|
|
|
|
|
Services environments)
|
|
|
|
|
==================
|
|
|
|
|
*/
|
|
|
|
|
void Host_CountRealTimePackets()
|
|
|
|
|
{
|
|
|
|
|
v_Host_CountRealTimePackets();
|
2023-12-27 13:22:33 +01:00
|
|
|
|
#ifndef DEDICATED
|
2023-12-25 19:23:01 +01:00
|
|
|
|
GFX_SetLatencyMarker(D3D11Device(), SIMULATION_START, MaterialSystem()->GetCurrentFrameCount());
|
2023-12-27 13:22:33 +01:00
|
|
|
|
#endif // !DEDICATED
|
2024-04-05 16:45:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-19 21:33:31 +02:00
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
_Host_RunFrame
|
|
|
|
|
|
|
|
|
|
Runs all active servers
|
|
|
|
|
==================
|
|
|
|
|
*/
|
|
|
|
|
void _Host_RunFrame(void* unused, float time)
|
|
|
|
|
{
|
2024-02-28 00:43:57 +01:00
|
|
|
|
for (IFrameTask* const& task : g_TaskQueueList)
|
2022-08-19 21:33:31 +02:00
|
|
|
|
{
|
|
|
|
|
task->RunFrame();
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 00:43:57 +01:00
|
|
|
|
g_TaskQueueList.erase(std::remove_if(g_TaskQueueList.begin(), g_TaskQueueList.end(), [](const IFrameTask* task)
|
2022-08-19 21:33:31 +02:00
|
|
|
|
{
|
|
|
|
|
return task->IsFinished();
|
2024-02-28 00:43:57 +01:00
|
|
|
|
}), g_TaskQueueList.end());
|
2022-08-19 21:33:31 +02:00
|
|
|
|
|
2022-09-11 23:48:11 +02:00
|
|
|
|
#ifndef DEDICATED
|
2024-01-21 21:29:23 +01:00
|
|
|
|
g_TextOverlay.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-11-26 13:21:20 +01:00
|
|
|
|
void _Host_Error(const char* error, ...)
|
2023-02-19 09:43:12 +01:00
|
|
|
|
{
|
|
|
|
|
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-11-26 13:21:20 +01:00
|
|
|
|
void VHost::Detour(const bool bAttach) const
|
2022-08-19 21:33:31 +02:00
|
|
|
|
{
|
2023-11-26 13:21:20 +01:00
|
|
|
|
DetourSetup(&v_Host_RunFrame, &_Host_RunFrame, bAttach);
|
2024-04-05 16:45:05 +02:00
|
|
|
|
DetourSetup(&v_Host_CountRealTimePackets, &Host_CountRealTimePackets, bAttach);
|
2023-02-19 09:43:12 +01:00
|
|
|
|
|
|
|
|
|
#ifndef DEDICATED // Dedicated already logs this!
|
2023-11-26 13:21:20 +01:00
|
|
|
|
DetourSetup(&v_Host_Error, &_Host_Error, bAttach);
|
2023-02-19 09:43:12 +01:00
|
|
|
|
#endif // !DEDICATED
|
2022-08-19 21:33:31 +02:00
|
|
|
|
}
|