2022-05-20 11:52:19 +02:00
|
|
|
//=============================================================================//
|
2021-12-25 22:36:38 +01:00
|
|
|
//
|
2022-05-20 11:52:19 +02:00
|
|
|
// Purpose:
|
2021-12-25 22:36:38 +01:00
|
|
|
//
|
2022-05-20 11:52:19 +02:00
|
|
|
// $NoKeywords: $
|
|
|
|
//
|
|
|
|
//=============================================================================//
|
|
|
|
// clientstate.cpp: implementation of the CClientState class.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
2021-12-25 22:36:38 +01:00
|
|
|
#include "core/stdafx.h"
|
2022-01-04 11:53:54 +01:00
|
|
|
#include "client/cdll_engine_int.h"
|
2022-08-18 02:15:23 +02:00
|
|
|
#include "engine/host.h"
|
2022-05-20 11:52:19 +02:00
|
|
|
#include "engine/client/clientstate.h"
|
2022-01-04 11:53:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Purpose: returns true if client simulation is paused
|
|
|
|
//------------------------------------------------------------------------------
|
2022-05-20 11:52:19 +02:00
|
|
|
bool CClientState::IsPaused()
|
2022-01-04 11:53:54 +01:00
|
|
|
{
|
2022-05-20 20:14:39 +02:00
|
|
|
return m_bPaused;
|
2022-01-04 11:53:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Purpose: gets the client time
|
2022-02-19 02:31:16 +01:00
|
|
|
// Technically doesn't belong here
|
2022-01-04 11:53:54 +01:00
|
|
|
//------------------------------------------------------------------------------
|
2022-05-20 11:52:19 +02:00
|
|
|
float CClientState::GetClientTime()
|
2022-01-04 11:53:54 +01:00
|
|
|
{
|
2022-08-18 02:15:23 +02:00
|
|
|
if (m_bClockCorrectionEnabled)
|
2022-01-04 11:53:54 +01:00
|
|
|
{
|
2022-08-18 02:15:23 +02:00
|
|
|
return (float)m_ClockDriftMgr.m_nSimulationTick * (*(float*)&interval_per_tick); // VERIFY DEREF
|
2022-01-04 11:53:54 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-18 11:35:32 +02:00
|
|
|
return m_flClockDriftFrameTime;
|
2022-01-04 11:53:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2022-07-03 11:03:25 +02:00
|
|
|
// Purpose: gets the simulation tick count
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
int CClientState::GetTick() const
|
|
|
|
{
|
|
|
|
return m_ClockDriftMgr.m_nSimulationTick;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Purpose: gets the last-received server tick count
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
int CClientState::GetServerTickCount() const
|
|
|
|
{
|
|
|
|
return m_ClockDriftMgr.m_nServerTick;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Purpose: sets the server tick count
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void CClientState::SetServerTickCount(int tick)
|
|
|
|
{
|
|
|
|
m_ClockDriftMgr.m_nServerTick = tick;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Purpose: gets the client tick count
|
2022-01-04 11:53:54 +01:00
|
|
|
//------------------------------------------------------------------------------
|
2022-05-20 11:52:19 +02:00
|
|
|
int CClientState::GetClientTickCount() const
|
2022-01-04 11:53:54 +01:00
|
|
|
{
|
2022-05-20 20:14:39 +02:00
|
|
|
return m_ClockDriftMgr.m_nClientTick;
|
2022-01-04 11:53:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2022-07-03 11:03:25 +02:00
|
|
|
// Purpose: sets the client tick count
|
2022-01-04 11:53:54 +01:00
|
|
|
//------------------------------------------------------------------------------
|
2022-05-20 11:52:19 +02:00
|
|
|
void CClientState::SetClientTickCount(int tick)
|
2022-01-04 11:53:54 +01:00
|
|
|
{
|
2022-05-20 20:14:39 +02:00
|
|
|
m_ClockDriftMgr.m_nClientTick = tick;
|
2022-01-04 11:53:54 +01:00
|
|
|
}
|
|
|
|
|
2022-05-20 20:14:39 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
CClientState* g_pClientState = nullptr;
|
2022-08-18 02:15:23 +02:00
|
|
|
CClientState** g_pClientState_Shifted = nullptr;
|