Some improvements on ducking and fixed angles not being aligned with prediction

This commit is contained in:
Kamay Xutax 2024-09-11 05:01:02 +02:00 committed by unknown
parent d750216b3d
commit 67ed5669c0
6 changed files with 20 additions and 51 deletions

View file

@ -3238,6 +3238,15 @@ void _Host_RunFrame (float time)
cl.SetFrameTime(host_frametime); cl.SetFrameTime(host_frametime);
#ifndef SWDS #ifndef SWDS
g_ClientGlobalVariables.next_interpolation_amount = cl.m_tickRemainder / host_state.interval_per_tick; 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( host_frametime );
#endif #endif
for ( int tick = 0; tick < numticks; tick++ ) for ( int tick = 0; tick < numticks; tick++ )
{ {
@ -3384,15 +3393,6 @@ void _Host_RunFrame (float time)
CL_RunPrediction( PREDICTION_NORMAL ); CL_RunPrediction( PREDICTION_NORMAL );
CL_ApplyAddAngle(); 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 #endif
#if defined( REPLAY_ENABLED ) #if defined( REPLAY_ENABLED )
@ -3515,15 +3515,6 @@ void _Host_RunFrame (float time)
Host_SetClientInSimulation( false ); 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; g_ClientGlobalVariables.tickcount = saveTick;
numticks_last_frame = numticks; numticks_last_frame = numticks;
host_remainder_last_frame = host_remainder; host_remainder_last_frame = host_remainder;

View file

@ -440,14 +440,14 @@ BEGIN_PREDICTION_DATA_NO_BASE( C_BaseEntity )
DEFINE_PRED_FIELD( m_MoveCollide, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_MoveCollide, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ),
DEFINE_FIELD( m_vecAbsVelocity, FIELD_VECTOR ), 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_fEffects, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_nRenderMode, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_nRenderMode, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_nRenderFX, 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_flAnimTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
// DEFINE_PRED_FIELD( m_flSimulationTime, 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( 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_nModelIndex, FIELD_SHORT, FTYPEDESC_INSENDTABLE | FTYPEDESC_MODELINDEX ),
DEFINE_PRED_FIELD( m_flFriction, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_flFriction, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_iTeamNum, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_iTeamNum, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),

View file

@ -630,7 +630,7 @@ void CPrediction::SetupMove( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *
move->m_bGameCodeMovedPlayer = true; move->m_bGameCodeMovedPlayer = true;
} }
move->m_nPlayerHandle = player->GetClientHandle(); move->m_nPlayerHandle = player;
move->m_vecVelocity = player->GetAbsVelocity(); move->m_vecVelocity = player->GetAbsVelocity();
move->SetAbsOrigin( player->GetLocalOrigin() ); move->SetAbsOrigin( player->GetLocalOrigin() );
move->m_vecOldAngles = move->m_vecAngles; move->m_vecOldAngles = move->m_vecAngles;

View file

@ -30,9 +30,9 @@ BEGIN_SEND_TABLE_NOBASE( CPlayerLocalData, DT_Local )
SendPropInt (SENDINFO(m_bDucked), 1, SPROP_UNSIGNED ), SendPropInt (SENDINFO(m_bDucked), 1, SPROP_UNSIGNED ),
SendPropInt (SENDINFO(m_bDucking), 1, SPROP_UNSIGNED ), SendPropInt (SENDINFO(m_bDucking), 1, SPROP_UNSIGNED ),
SendPropInt (SENDINFO(m_bInDuckJump), 1, SPROP_UNSIGNED ), SendPropInt (SENDINFO(m_bInDuckJump), 1, SPROP_UNSIGNED ),
SendPropFloat (SENDINFO(m_flDucktime), 12, 0, 0.0f, 1000.0f ), SendPropFloat (SENDINFO(m_flDucktime) ),
SendPropFloat (SENDINFO(m_flDuckJumpTime), 12, 0, 0.0f, 1000.0f ), SendPropFloat (SENDINFO(m_flDuckJumpTime) ),
SendPropFloat (SENDINFO(m_flJumpTime), 12, 0, 0.0f, 1000.0f ), SendPropFloat (SENDINFO(m_flJumpTime)),
#if PREDICTION_ERROR_CHECK_LEVEL > 1 #if PREDICTION_ERROR_CHECK_LEVEL > 1
SendPropFloat (SENDINFO(m_flFallVelocity), 32, SPROP_NOSCALE ), 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 ), SendPropInt (SENDINFO(m_bWearingSuit), 1, SPROP_UNSIGNED ),
SendPropBool (SENDINFO(m_bPoisoned)), 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 ), SendPropInt (SENDINFO(m_bAllowAutoMovement),1, SPROP_UNSIGNED ),
// 3d skybox data // 3d skybox data

View file

@ -379,7 +379,7 @@ void CCSGameMovement::PlayerMove()
vHullMin.z = 0.0f; vHullMin.z = 0.0f;
Vector vHullMax = GetPlayerMaxs( player->m_Local.m_bDucked ); Vector vHullMax = GetPlayerMaxs( player->m_Local.m_bDucked );
Vector start = player->GetAbsOrigin(); Vector start = mv->GetAbsOrigin();
start.z += vHullMax.z; start.z += vHullMax.z;
Vector end = start; Vector end = start;
end.z += eyeClearance - vHullMax.z; end.z += eyeClearance - vHullMax.z;
@ -398,7 +398,7 @@ void CCSGameMovement::PlayerMove()
if ( trace.fraction < 1.0f ) 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 ) if ( ( player->GetFlags() & FL_DUCKING ) == 0 && !player->m_Local.m_bDucking && !player->m_Local.m_bDucked )
{ {
offset.z = est; offset.z = est;
@ -893,7 +893,7 @@ void CCSGameMovement::FinishUnDuck( void )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CCSGameMovement::FinishDuck( void ) void CCSGameMovement::FinishDuck( void )
{ {
Vector hullSizeNormal = VEC_HULL_MAX_SCALED( player ) - VEC_HULL_MIN_SCALED( player ); 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 ); Vector hullSizeCrouch = VEC_DUCK_HULL_MAX_SCALED( player ) - VEC_DUCK_HULL_MIN_SCALED( player );

View file

@ -4113,17 +4113,6 @@ void CGameMovement::FinishUnDuck( void )
mv->SetAbsOrigin( newOrigin ); 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 // Recategorize position since ducking can change origin
CategorizePosition(); CategorizePosition();
} }
@ -4217,17 +4206,6 @@ void CGameMovement::FinishDuck( void )
Vector out; Vector out;
VectorAdd( mv->GetAbsOrigin(), viewDelta, out ); VectorAdd( mv->GetAbsOrigin(), viewDelta, out );
mv->SetAbsOrigin( 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? // See if we are stuck?
@ -4488,7 +4466,7 @@ void CGameMovement::Duck( void )
float flDuckSeconds = flDuckMilliseconds * 0.001f; float flDuckSeconds = flDuckMilliseconds * 0.001f;
// Finish ducking immediately if duck time is over or not on ground // 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(); FinishUnDuck();
} }