r5sdk/r5dev/engine/host.cpp
Kawe Mazidjatari 6764b5e56e Implement frame tasks
Run all Cbuf_Execute calls in the main thread. This should fix every problem related to (but not only):
* Connecting to server while RUI dialogue is still open.
* Connecting to server while in an active game.
* Running 'weapon_reparse'.
2022-08-19 21:33:31 +02:00

43 lines
937 B
C++
Raw Blame History

//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ========//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "core/stdafx.h"
#include "tier0/frametask.h"
#include "engine/host.h"
/*
==================
_Host_RunFrame
Runs all active servers
==================
*/
void _Host_RunFrame(void* unused, float time)
{
for (const auto& task : g_FrameTasks)
{
task->RunFrame();
}
g_FrameTasks.erase(std::remove_if(g_FrameTasks.begin(), g_FrameTasks.end(), [](const IFrameTask* task)
{
return task->IsFinished();
}), g_FrameTasks.end());
return v_Host_RunFrame(unused, time);
}
///////////////////////////////////////////////////////////////////////////////
void Host_Attach()
{
DetourAttach((LPVOID*)&v_Host_RunFrame, &_Host_RunFrame);
}
void Host_Detach()
{
DetourDetach((LPVOID*)&v_Host_RunFrame, &_Host_RunFrame);
}