From a638c51ab904b97389adc31b0a5e6863fb2dcfc7 Mon Sep 17 00:00:00 2001 From: Kamay Xutax Date: Wed, 11 Sep 2024 05:01:02 +0200 Subject: [PATCH] Some improvements on ducking and fixed angles not being aligned with prediction --- engine/host.cpp | 27 +++++++++---------------- game/client/c_baseentity.cpp | 4 ++-- game/client/prediction.cpp | 2 +- game/server/playerlocaldata.cpp | 8 ++++---- game/shared/cstrike/cs_gamemovement.cpp | 6 +++--- game/shared/gamemovement.cpp | 24 +--------------------- 6 files changed, 20 insertions(+), 51 deletions(-) diff --git a/engine/host.cpp b/engine/host.cpp index 63e97db4f8..f72c074c3b 100644 --- a/engine/host.cpp +++ b/engine/host.cpp @@ -3238,6 +3238,15 @@ void _Host_RunFrame (float time) cl.SetFrameTime(host_frametime); #ifndef SWDS g_ClientGlobalVariables.next_interpolation_amount = cl.m_tickRemainder / host_state.interval_per_tick; + + // TODO_ENHANCED: + // Update the mouse as last so we can get the right viewangles while taking screenshot. + // The mouse is always simulated for the current frame's time + // This makes updates smooth in every case + // continuous controllers affecting the view are also simulated this way + // but they have a cap applied by IN_SetSampleTime() so they are not also + // simulated during input gathering + CL_ExtraMouseUpdate( g_ClientGlobalVariables.frametime ); #endif for ( int tick = 0; tick < numticks; tick++ ) { @@ -3384,15 +3393,6 @@ void _Host_RunFrame (float time) CL_RunPrediction( PREDICTION_NORMAL ); CL_ApplyAddAngle(); - - // TODO_ENHANCED: - // Update the mouse as last so we can get the right viewangles while taking screenshot. - // The mouse is always simulated for the current frame's time - // This makes updates smooth in every case - // continuous controllers affecting the view are also simulated this way - // but they have a cap applied by IN_SetSampleTime() so they are not also - // simulated during input gathering - CL_ExtraMouseUpdate( g_ClientGlobalVariables.frametime ); } #endif #if defined( REPLAY_ENABLED ) @@ -3515,15 +3515,6 @@ void _Host_RunFrame (float time) Host_SetClientInSimulation( false ); - // TODO_ENHANCED: - // Update the mouse as last so we can get the right viewangles while taking screenshot. - // The mouse is always simulated for the current frame's time - // This makes updates smooth in every case - // continuous controllers affecting the view are also simulated this way - // but they have a cap applied by IN_SetSampleTime() so they are not also - // simulated during input gathering - CL_ExtraMouseUpdate( g_ClientGlobalVariables.frametime ); - g_ClientGlobalVariables.tickcount = saveTick; numticks_last_frame = numticks; host_remainder_last_frame = host_remainder; diff --git a/game/client/c_baseentity.cpp b/game/client/c_baseentity.cpp index b9588d7db1..4240201be3 100644 --- a/game/client/c_baseentity.cpp +++ b/game/client/c_baseentity.cpp @@ -440,14 +440,14 @@ BEGIN_PREDICTION_DATA_NO_BASE( C_BaseEntity ) DEFINE_PRED_FIELD( m_MoveCollide, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ), DEFINE_FIELD( m_vecAbsVelocity, FIELD_VECTOR ), - DEFINE_PRED_FIELD_TOL( m_vecVelocity, FIELD_VECTOR, FTYPEDESC_INSENDTABLE, 0.5f ), + DEFINE_PRED_FIELD_TOL( m_vecVelocity, FIELD_VECTOR, FTYPEDESC_INSENDTABLE, coordTolerance ), // DEFINE_PRED_FIELD( m_fEffects, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_nRenderMode, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_nRenderFX, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ), // DEFINE_PRED_FIELD( m_flAnimTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ), // DEFINE_PRED_FIELD( m_flSimulationTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_fFlags, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ), - DEFINE_PRED_FIELD_TOL( m_vecViewOffset, FIELD_VECTOR, FTYPEDESC_INSENDTABLE, 0.25f ), + DEFINE_PRED_FIELD_TOL( m_vecViewOffset, FIELD_VECTOR, FTYPEDESC_INSENDTABLE, coordTolerance ), DEFINE_PRED_FIELD( m_nModelIndex, FIELD_SHORT, FTYPEDESC_INSENDTABLE | FTYPEDESC_MODELINDEX ), DEFINE_PRED_FIELD( m_flFriction, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_iTeamNum, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ), diff --git a/game/client/prediction.cpp b/game/client/prediction.cpp index c4bbde42cd..da66b7b120 100644 --- a/game/client/prediction.cpp +++ b/game/client/prediction.cpp @@ -630,7 +630,7 @@ void CPrediction::SetupMove( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper * move->m_bGameCodeMovedPlayer = true; } - move->m_nPlayerHandle = player->GetClientHandle(); + move->m_nPlayerHandle = player; move->m_vecVelocity = player->GetAbsVelocity(); move->SetAbsOrigin( player->GetLocalOrigin() ); move->m_vecOldAngles = move->m_vecAngles; diff --git a/game/server/playerlocaldata.cpp b/game/server/playerlocaldata.cpp index c2a43b00ff..ad655869a2 100644 --- a/game/server/playerlocaldata.cpp +++ b/game/server/playerlocaldata.cpp @@ -30,9 +30,9 @@ BEGIN_SEND_TABLE_NOBASE( CPlayerLocalData, DT_Local ) SendPropInt (SENDINFO(m_bDucked), 1, SPROP_UNSIGNED ), SendPropInt (SENDINFO(m_bDucking), 1, SPROP_UNSIGNED ), SendPropInt (SENDINFO(m_bInDuckJump), 1, SPROP_UNSIGNED ), - SendPropFloat (SENDINFO(m_flDucktime), 12, 0, 0.0f, 1000.0f ), - SendPropFloat (SENDINFO(m_flDuckJumpTime), 12, 0, 0.0f, 1000.0f ), - SendPropFloat (SENDINFO(m_flJumpTime), 12, 0, 0.0f, 1000.0f ), + SendPropFloat (SENDINFO(m_flDucktime) ), + SendPropFloat (SENDINFO(m_flDuckJumpTime) ), + SendPropFloat (SENDINFO(m_flJumpTime)), #if PREDICTION_ERROR_CHECK_LEVEL > 1 SendPropFloat (SENDINFO(m_flFallVelocity), 32, SPROP_NOSCALE ), @@ -53,7 +53,7 @@ BEGIN_SEND_TABLE_NOBASE( CPlayerLocalData, DT_Local ) SendPropInt (SENDINFO(m_bWearingSuit), 1, SPROP_UNSIGNED ), SendPropBool (SENDINFO(m_bPoisoned)), - SendPropFloat (SENDINFO(m_flStepSize), 16, SPROP_ROUNDUP, 0.0f, 128.0f ), + SendPropFloat (SENDINFO(m_flStepSize)), SendPropInt (SENDINFO(m_bAllowAutoMovement),1, SPROP_UNSIGNED ), // 3d skybox data diff --git a/game/shared/cstrike/cs_gamemovement.cpp b/game/shared/cstrike/cs_gamemovement.cpp index d5507d0846..6f1a7ff542 100644 --- a/game/shared/cstrike/cs_gamemovement.cpp +++ b/game/shared/cstrike/cs_gamemovement.cpp @@ -379,7 +379,7 @@ void CCSGameMovement::PlayerMove() vHullMin.z = 0.0f; Vector vHullMax = GetPlayerMaxs( player->m_Local.m_bDucked ); - Vector start = player->GetAbsOrigin(); + Vector start = mv->GetAbsOrigin(); start.z += vHullMax.z; Vector end = start; end.z += eyeClearance - vHullMax.z; @@ -398,7 +398,7 @@ void CCSGameMovement::PlayerMove() if ( trace.fraction < 1.0f ) { - float est = start.z + trace.fraction * (end.z - start.z) - player->GetAbsOrigin().z - eyeClearance; + float est = start.z + trace.fraction * (end.z - start.z) - mv->GetAbsOrigin().z - eyeClearance; if ( ( player->GetFlags() & FL_DUCKING ) == 0 && !player->m_Local.m_bDucking && !player->m_Local.m_bDucked ) { offset.z = est; @@ -893,7 +893,7 @@ void CCSGameMovement::FinishUnDuck( void ) //----------------------------------------------------------------------------- void CCSGameMovement::FinishDuck( void ) { - + Vector hullSizeNormal = VEC_HULL_MAX_SCALED( player ) - VEC_HULL_MIN_SCALED( player ); Vector hullSizeCrouch = VEC_DUCK_HULL_MAX_SCALED( player ) - VEC_DUCK_HULL_MIN_SCALED( player ); diff --git a/game/shared/gamemovement.cpp b/game/shared/gamemovement.cpp index c1aa00d518..4e750c637f 100644 --- a/game/shared/gamemovement.cpp +++ b/game/shared/gamemovement.cpp @@ -4113,17 +4113,6 @@ void CGameMovement::FinishUnDuck( void ) mv->SetAbsOrigin( newOrigin ); -#ifdef CLIENT_DLL -#ifdef STAGING_ONLY - if ( debug_latch_reset_onduck.GetBool() ) - { - player->ResetLatched(); - } -#else - player->ResetLatched(); -#endif -#endif // CLIENT_DLL - // Recategorize position since ducking can change origin CategorizePosition(); } @@ -4217,17 +4206,6 @@ void CGameMovement::FinishDuck( void ) Vector out; VectorAdd( mv->GetAbsOrigin(), viewDelta, out ); mv->SetAbsOrigin( out ); - -#ifdef CLIENT_DLL -#ifdef STAGING_ONLY - if ( debug_latch_reset_onduck.GetBool() ) - { - player->ResetLatched(); - } -#else - player->ResetLatched(); -#endif -#endif // CLIENT_DLL } // See if we are stuck? @@ -4488,7 +4466,7 @@ void CGameMovement::Duck( void ) float flDuckSeconds = flDuckMilliseconds * 0.001f; // Finish ducking immediately if duck time is over or not on ground - if ( flDuckSeconds > TIME_TO_UNDUCK || ( bInAir && !bDuckJump ) ) + if ( flDuckSeconds >= TIME_TO_UNDUCK || ( bInAir && !bDuckJump ) ) { FinishUnDuck(); }