mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Utilize the new IDetour::DetourSetup() code, IDetour::Attach and IDetour::Detach have been removed in favor of this (significantly reduces chance of user error). Since the template check happens in the idetour header, it is much more aggressive on type mismatches, such as a difference in parameter types, between the function and detour, will now raise a compile time error. As a result, some type mismatches have been fixed in this commit as well.
38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
#include "core/stdafx.h"
|
|
#include "tier1/cvar.h"
|
|
#include "sys_engine.h"
|
|
#ifdef DEDICATED
|
|
#include "game/shared/shareddefs.h"
|
|
#endif // DEDICATED
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
CEngine* g_pEngine = nullptr;
|
|
IEngine::QuitState_t* gsm_Quitting = nullptr;
|
|
|
|
bool CEngine::_Frame(CEngine* thisp)
|
|
{
|
|
#ifdef DEDICATED
|
|
|
|
// The first engine frame is ran before the global variables are initialized.
|
|
// By default, the tick interval is set to '0.0f'; we can't divide by zero.
|
|
if (TICK_INTERVAL > 0.0f)
|
|
{
|
|
int nTickRate = TIME_TO_TICKS(1.0f);
|
|
if (fps_max->GetInt() != nTickRate)
|
|
{
|
|
// Clamp the framerate of the server to its simulation tick rate.
|
|
// This saves a significant amount of CPU time in CEngine::Frame,
|
|
// as the engine uses this to decided when to run a new frame.
|
|
fps_max->SetValue(nTickRate);
|
|
}
|
|
}
|
|
|
|
#endif // DEDICATED
|
|
return v_CEngine_Frame(thisp);
|
|
}
|
|
|
|
void VEngine::Detour(const bool bAttach) const
|
|
{
|
|
DetourSetup(&v_CEngine_Frame, &CEngine::_Frame, bAttach);
|
|
}
|