void __cdecl C_Hooks::hkSimulationTime( CRecvProxyData* Proxy, void* pStruct, void* pOut )
{
/* Get entity */
C_BaseEntity* pEntity = static_cast < C_BaseEntity* > ( pStruct );
if ( !pEntity || !pEntity->IsPlayer( ) )
return Hooks::m_SimulationTimeProxy->GetOriginal( )( Proxy, pStruct, pOut );
/* Decode player's tickbase */
int nPlayerTickBase = Proxy->m_Value.m_Int + SDK::Interfaces::GlobalVars->GetNetworkBase( SDK::Interfaces::GlobalVars->m_iTickCount, pEntity->EntIndex( ) );
while ( nPlayerTickBase < SDK::Interfaces::GlobalVars->m_iTickCount + 127 )
nPlayerTickBase += 256;
while ( nPlayerTickBase > SDK::Interfaces::GlobalVars->m_iTickCount + 127 )
nPlayerTickBase -= 256;
/* Change the time and handle time changing */
float flPlayerSimulationTime = g_Utils->TicksToTime( nPlayerTickBase );
if ( flPlayerSimulationTime != pEntity->m_flSimulationTime( ) )
{
pEntity->OnSimulationTimeChanging( pEntity->m_flSimulationTime( ), flPlayerSimulationTime );
pEntity->m_flSimulationTime( ) = flPlayerSimulationTime;
}
}