Properly implement 'CClientState::IsPaused()'

Should check if host is initialized, and if the VGui system is paused as well. Also added 'CClientState::GetFrameTime()'.
This commit is contained in:
Kawe Mazidjatari 2023-06-03 18:06:35 +02:00
parent 19df5a188b
commit cef62d7f4d
2 changed files with 19 additions and 3 deletions

View File

@ -12,6 +12,7 @@
#include "engine/host.h" #include "engine/host.h"
#include "clientstate.h" #include "clientstate.h"
#include "cdll_engine_int.h" #include "cdll_engine_int.h"
#include "vgui/vgui_baseui_interface.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -19,7 +20,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool CClientState::IsPaused() const bool CClientState::IsPaused() const
{ {
return m_bPaused; return m_bPaused || !*host_initialized || g_pEngineVGui->ShouldPause();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -102,6 +103,19 @@ void CClientState::SetClientTickCount(int tick)
m_ClockDriftMgr.m_nClientTick = tick; m_ClockDriftMgr.m_nClientTick = tick;
} }
//------------------------------------------------------------------------------
// Purpose: gets the client frame time
//------------------------------------------------------------------------------
float CClientState::GetFrameTime() const
{
if (IsPaused())
{
return 0.0f;
}
return m_flFrameTime;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Purpose: // Purpose:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -42,6 +42,8 @@ public:
int GetClientTickCount() const; // Get the client tick count. int GetClientTickCount() const; // Get the client tick count.
void SetClientTickCount(int tick); void SetClientTickCount(int tick);
float GetFrameTime(void) const;
int m_Socket; int m_Socket;
int _padding_maybe; int _padding_maybe;
CNetChan* m_NetChannel; CNetChan* m_NetChannel;
@ -113,9 +115,9 @@ public:
char error_message[512]; char error_message[512];
_BYTE gap18CA1[3]; _BYTE gap18CA1[3];
_DWORD last_usercmd_time_from_server_maybe; _DWORD last_usercmd_time_from_server_maybe;
CFrameSnapshot* prev_frame_maybe; CFrameSnapshot* m_PrevFrameSnapshot;
_QWORD qword18CB0; _QWORD qword18CB0;
CFrameSnapshot* current_frame_maybe; CFrameSnapshot* m_CurrFrameSnapshot;
_BYTE gap18CC0[8]; _BYTE gap18CC0[8];
char m_bClockCorrectionEnabled; char m_bClockCorrectionEnabled;
char m_b_unknown; char m_b_unknown;