-
Автор темы
- #1
C++:
void C_LagCompensation::SetupLerpTime( ) {
const float updaterate = g_Vars.cl_updaterate->GetFloat( );
const float min_update_rate = g_Vars.sv_minupdaterate->GetFloat( );
const float max_update_rate = g_Vars.sv_maxupdaterate->GetFloat( );
const float min_interp_ratio = g_Vars.sv_client_min_interp_ratio->GetFloat( );
const float max_interp_ratio = g_Vars.sv_client_max_interp_ratio->GetFloat( );
const float interp_amount = g_Vars.cl_interp->GetFloat( );
float interp_ratio = g_Vars.cl_interp_ratio->GetFloat( );
if ( interp_ratio == 0.0f ) {
interp_ratio = 1.0f;
}
else {
interp_ratio = std::clamp( interp_ratio, min_interp_ratio, max_interp_ratio );
}
const float update_rate = std::clamp( updaterate, min_update_rate, max_update_rate );
const float lerp_time = std::max( interp_amount, interp_ratio / update_rate );
lagData->m_flLerpTime = lerp_time;
auto net_channel = Encrypted_t<INetChannel>( Interfaces::m_pEngine->GetNetChannelInfo( ) );
const float outgoing_latency = net_channel->GetLatency( FLOW_OUTGOING );
const float incoming_latency = net_channel->GetLatency( FLOW_INCOMING );
lagData->m_flOutLatency = outgoing_latency;
lagData->m_flServerLatency = incoming_latency;
}