mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Move simple task to global fixed frame
Avoids having to create threads for tiny little things.
This commit is contained in:
parent
1c29d5aed5
commit
0f488c685c
@ -78,6 +78,7 @@
|
||||
#ifndef CLIENT_DLL
|
||||
#include "engine/server/sv_main.h"
|
||||
#endif // !CLIENT_DLL
|
||||
#include "engine/sdk_dll.h"
|
||||
#include "engine/sys_dll.h"
|
||||
#include "engine/sys_dll2.h"
|
||||
#include "engine/sys_engine.h"
|
||||
@ -242,6 +243,9 @@ void Systems_Init()
|
||||
#endif // DEDICATED
|
||||
|
||||
SpdLog_PostInit();
|
||||
|
||||
std::thread fixed(&CEngineSDK::FixedFrame, g_EngineSDK);
|
||||
fixed.detach();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -5,4 +5,28 @@
|
||||
//=============================================================================//
|
||||
|
||||
#include "core/stdafx.h"
|
||||
#include "tier1/cvar.h"
|
||||
#include "engine/sdk_dll.h"
|
||||
#ifndef DEDICATED
|
||||
#include "gameui/IBrowser.h"
|
||||
#include "gameui/IConsole.h"
|
||||
#endif // !DEDICATED
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEngineSDK::FixedFrame()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
#ifndef DEDICATED
|
||||
g_pBrowser->Think();
|
||||
g_pConsole->Think();
|
||||
#endif // !DEDICATED
|
||||
|
||||
std::chrono::duration<float, std::deci> interval{ sdk_fixedframe_tickinterval->GetFloat()};
|
||||
std::this_thread::sleep_for(interval);
|
||||
}
|
||||
}
|
||||
|
||||
CEngineSDK* g_EngineSDK = new CEngineSDK();
|
||||
|
@ -1,5 +1,12 @@
|
||||
#ifndef SDK_DLL_H
|
||||
#define SDK_DLL_H
|
||||
|
||||
class CEngineSDK
|
||||
{
|
||||
public:
|
||||
void FixedFrame();
|
||||
};
|
||||
|
||||
extern CEngineSDK* g_EngineSDK;
|
||||
|
||||
#endif // SDK_DLL_H
|
||||
|
@ -150,20 +150,16 @@ void CBrowser::RunTask()
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBrowser::Think(void)
|
||||
{
|
||||
for (;;) // Loop running at 100-tps.
|
||||
if (m_bActivate)
|
||||
{
|
||||
if (m_bActivate)
|
||||
if (m_flFadeAlpha <= 1.f)
|
||||
{
|
||||
if (m_flFadeAlpha <= 1.f)
|
||||
{
|
||||
m_flFadeAlpha += .05f;
|
||||
}
|
||||
m_flFadeAlpha += .05f;
|
||||
}
|
||||
else // Reset to full transparent.
|
||||
{
|
||||
m_flFadeAlpha = 0.f;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
else // Reset to full transparent.
|
||||
{
|
||||
m_flFadeAlpha = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,9 +41,6 @@ CConsole::CConsole(void)
|
||||
m_vCommands.push_back("HISTORY");
|
||||
|
||||
snprintf(m_szSummary, sizeof(m_szSummary), "%zu history items", m_vHistory.size());
|
||||
|
||||
std::thread think(&CConsole::Think, this);
|
||||
think.detach(); // !FIXME: Run from SDK MainFrame when finished.
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -151,21 +148,17 @@ void CConsole::RunTask()
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::Think(void)
|
||||
{
|
||||
for (;;) // Loop running at 100-tps.
|
||||
if (m_bActivate)
|
||||
{
|
||||
if (m_bActivate)
|
||||
if (m_flFadeAlpha <= 1.f)
|
||||
{
|
||||
if (m_flFadeAlpha <= 1.f)
|
||||
{
|
||||
m_flFadeAlpha += .05f;
|
||||
}
|
||||
m_flFadeAlpha += .05f;
|
||||
}
|
||||
else // Reset to full transparent.
|
||||
{
|
||||
m_flFadeAlpha = 0.f;
|
||||
m_bReclaimFocus = true;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
else // Reset to full transparent.
|
||||
{
|
||||
m_flFadeAlpha = 0.f;
|
||||
m_bReclaimFocus = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ cl_threaded_bone_setup "0" // Has to be disabled on
|
||||
//////////////////////////
|
||||
cl_predict_cmdlimit "5000" // Num client frames since last valid snapshot before pauzing simulation.
|
||||
cl_updaterate_mp "20" // Sets the num delta ticks per second.
|
||||
base_tickinterval_mp "0.0500" // Sets the num simulation frames per second.
|
||||
base_tickinterval_mp "0.05" // Sets the num simulation frames per second.
|
||||
|
||||
//////////////////////////
|
||||
//// PLATFORM ////
|
||||
|
@ -11,7 +11,7 @@ sv_requireOriginToken "0" // Enables origin token verification on th
|
||||
//// SIMULATION //// !!WARNING!!: CHANGING THESE CAN CAUSE SIMULATION ISSUES. DO NOT CHANGE FOR NON-DEBUG ACTIVITY!
|
||||
//////////////////////////
|
||||
sv_updaterate_mp "20" // Sets the num delta ticks per second.
|
||||
base_tickinterval_mp "0.0500" // Sets the num simulation frames per second.
|
||||
base_tickinterval_mp "0.05" // Sets the num simulation frames per second.
|
||||
|
||||
//////////////////////////
|
||||
//// DEBUG DRAW ////
|
||||
|
@ -65,7 +65,8 @@ void ConVar::Init(void) const
|
||||
{
|
||||
//-------------------------------------------------------------------------
|
||||
// ENGINE |
|
||||
hostdesc = ConVar::Create("hostdesc", "", FCVAR_RELEASE, "Host game server description.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
hostdesc = ConVar::Create("hostdesc", "", FCVAR_RELEASE, "Host game server description.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
sdk_fixedframe_tickinterval = ConVar::Create("sdk_fixedframe_tickinterval", "0.05", FCVAR_RELEASE, "The tick interval used by the SDK fixed frame.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
staticProp_defaultBuildFrustum = ConVar::Create("staticProp_defaultBuildFrustum", "0", FCVAR_DEVELOPMENTONLY, "Use the old solution for building static prop frustum culling.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
|
||||
cm_unset_all_cmdquery = ConVar::Create("cm_unset_all_cmdquery" , "0", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Returns false on every ConVar/ConCommand query ( !warning! ).", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ENGINE |
|
||||
ConVar* sdk_fixedframe_tickinterval = nullptr;
|
||||
ConVar* single_frame_shutdown_for_reload = nullptr;
|
||||
ConVar* old_gather_props = nullptr;
|
||||
ConVar* enable_debug_overlays = nullptr;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// ENGINE |
|
||||
extern ConVar* sdk_fixedframe_tickinterval;
|
||||
extern ConVar* single_frame_shutdown_for_reload;
|
||||
extern ConVar* old_gather_props;
|
||||
extern ConVar* enable_debug_overlays;
|
||||
|
Loading…
x
Reference in New Issue
Block a user