Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/game/server/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ static ConVar sv_maxusrcmdprocessticks( "sv_maxusrcmdprocessticks", "24", FCVAR_
static ConVar old_armor( "player_old_armor", "0" );

static ConVar physicsshadowupdate_render( "physicsshadowupdate_render", "0" );
#ifdef NEO
static ConVar sv_neo_block_physics_warp( "sv_neo_block_physics_warp", "1", FCVAR_NONE, "Attempt to prevent players from being teleported through walls by some physics objects" );
#endif
bool IsInCommentaryMode( void );
bool IsListeningToCommentary( void );

Expand Down Expand Up @@ -8756,6 +8759,41 @@ void CBasePlayer::VPhysicsShadowUpdate( IPhysicsObject *pPhysics )
{
if ( m_touchedPhysObject || pPhysGround )
{
#ifdef NEO
// Attempt to fix warping through walls.
// Rather than trusting whatever vphysics says, lets check if the
// player could have actually launched that far with that velocity
bool bBlockedWarp = false;
if ( sv_neo_block_physics_warp.GetBool() )
{
float flPhysDelta = TICK_INTERVAL * phys_timescale.GetFloat();
if ( flPhysDelta <= 0.0f )
{
flPhysDelta = TICK_INTERVAL;
}

const Vector vecWarp = newPosition - GetAbsOrigin();
const float flWarpDist = vecWarp.Length();
const float flValidSpeed = Max( newVelocity.Length(), GetAbsVelocity().Length() );

const float flMaxValidDist = ( flValidSpeed * flPhysDelta * 4.0f /* vphys leeway */ ) + 32.0f /* Dist tolerance gap before it looks sus */;
if ( flWarpDist > flMaxValidDist )
{
bBlockedWarp = true;

DevMsg( "VPhysicsShadowUpdate: Prevented warp for \"%s\" (Would've moved %.1f units, but only <%.1f was acceptable)\n", GetPlayerName(), flWarpDist, flMaxValidDist );

pPhysics->SetPosition( GetAbsOrigin(), vec3_angle, true );
const Vector vel = GetAbsVelocity();
pPhysics->SetVelocity( &vel, NULL );
UpdateVPhysicsPosition( GetAbsOrigin(), vel, 0.0f );
lastValidPosition = GetAbsOrigin();
}
}

if ( !bBlockedWarp )
{
#endif
// BUGBUG: Rewrite this code using fixed timestep
if ( deltaV >= maxVelErrorSqr && !m_bPhysicsWasFrozen )
{
Expand Down Expand Up @@ -8795,6 +8833,9 @@ void CBasePlayer::VPhysicsShadowUpdate( IPhysicsObject *pPhysics )
{
SetAbsOrigin( newPosition );
}
#ifdef NEO
}
#endif
}
else
{
Expand Down