Skip to content

Commit

Permalink
If we teleported or PostThink decided to modify viewoffset
Browse files Browse the repository at this point in the history
Let it do it because interpolation will be reset
  • Loading branch information
XutaxKamay committed Sep 14, 2024
1 parent 72aea29 commit 8596379
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions game/client/prediction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,9 @@ void CPrediction::StartInterpolatingPlayer( C_BasePlayer *player )

player->SetLocalOrigin( vecNewLocalOrigin );
player->SetViewOffset( vecNewViewOffset );

InterpolationContexts[BEFORE_POST_THINK].m_vecLocalOrigin = player->GetLocalOrigin();
InterpolationContexts[BEFORE_POST_THINK].m_vecViewOffset = player->GetViewOffset();
#endif
}

Expand All @@ -874,6 +877,13 @@ void CPrediction::FinishInterpolatingPlayer( C_BasePlayer* player )
#if !defined( NO_ENTITY_PREDICTION )
VPROF( "CPrediction::FinishInterpolatingPlayer" );

// We probably teleported or something.
if ( InterpolationContexts[BEFORE_POST_THINK].m_vecLocalOrigin != player->GetLocalOrigin()
|| InterpolationContexts[BEFORE_POST_THINK].m_vecViewOffset != player->GetViewOffset() )
{
return;
}

player->SetLocalOrigin( InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin );
player->SetViewOffset( InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset );
#endif
Expand Down
1 change: 1 addition & 0 deletions game/client/prediction.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class CPrediction : public IPrediction
enum INTERPOLATION_CONTEXT
{
BEFORE_MOVEMENT,
BEFORE_POST_THINK,
AFTER_MOVEMENT,
INTERPOLATION_CONTEXT_MAX
};
Expand Down
10 changes: 10 additions & 0 deletions game/server/player_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,22 @@ void CPlayerMove::StartInterpolatingPlayer( CBasePlayer *player )

player->SetLocalOrigin( vecNewLocalOrigin );
player->SetViewOffset( vecNewViewOffset );

InterpolationContexts[BEFORE_POST_THINK].m_vecLocalOrigin = player->GetLocalOrigin();
InterpolationContexts[BEFORE_POST_THINK].m_vecViewOffset = player->GetViewOffset();
}

void CPlayerMove::FinishInterpolatingPlayer( CBasePlayer* player )
{
VPROF( "CPlayerMove::FinishInterpolatingPlayer" );

// We probably teleported or something.
if ( InterpolationContexts[BEFORE_POST_THINK].m_vecLocalOrigin != player->GetLocalOrigin()
|| InterpolationContexts[BEFORE_POST_THINK].m_vecViewOffset != player->GetViewOffset() )
{
return;
}

player->SetLocalOrigin( InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin );
player->SetViewOffset( InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset );
}
Expand Down
1 change: 1 addition & 0 deletions game/server/player_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CPlayerMove
enum INTERPOLATION_CONTEXT
{
BEFORE_MOVEMENT,
BEFORE_POST_THINK,
AFTER_MOVEMENT,
INTERPOLATION_CONTEXT_MAX
};
Expand Down

0 comments on commit 8596379

Please sign in to comment.