Skip to content

Commit 2d0807c

Browse files
committed
game\client&server: Invalidate bone cache same way in server and client + prevent future bone cache times
See ValveSoftware/source-sdk-2013#891
1 parent 50dbe72 commit 2d0807c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

game/client/c_baseanimating.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,9 @@ CBoneCache *C_BaseAnimating::GetBoneCache( CStudioHdr *pStudioHdr )
23322332
CBoneCache *pcache = Studio_GetBoneCache( m_hitboxBoneCacheHandle );
23332333
if ( pcache )
23342334
{
2335-
if ( pcache->IsValid( gpGlobals->curtime, 0.0 ) )
2335+
// dimhotepus: Use default 0.1 jitter as server does and ensure (as server does) bone cache
2336+
// is not from future (due to prediction).
2337+
if ( pcache->IsValid( gpGlobals->curtime ) && pcache->m_timeValid <= gpGlobals->curtime )
23362338
{
23372339
// in memory and still valid, use it!
23382340
return pcache;

game/server/baseanimating.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ void CBaseAnimating::StudioFrameAdvanceInternal( CStudioHdr *pStudioHdr, float f
455455
void CBaseAnimating::InvalidateBoneCacheIfOlderThan( float deltaTime )
456456
{
457457
CBoneCache *pcache = Studio_GetBoneCache( m_boneCacheHandle );
458-
if ( !pcache || !pcache->IsValid( gpGlobals->curtime, deltaTime ) )
458+
// dimhotepus: Invalidate bone cache if its old or in the future.
459+
if ( !pcache || !pcache->IsValid( gpGlobals->curtime, deltaTime ) || pcache->m_timeValid > gpGlobals->curtime )
459460
{
460461
InvalidateBoneCache();
461462
}
@@ -2623,6 +2624,7 @@ CBoneCache *CBaseAnimating::GetBoneCache( void )
26232624
#endif
26242625
if ( pcache )
26252626
{
2627+
// dimhotepus: If you change this, sync with C_BaseAnimating::GetBoneCache
26262628
if ( pcache->IsValid( gpGlobals->curtime ) && (pcache->m_boneMask & boneMask) == boneMask && pcache->m_timeValid <= gpGlobals->curtime)
26272629
{
26282630
// Msg("%s:%s:%s (%x:%x:%8.4f) cache\n", GetClassname(), GetDebugName(), STRING(GetModelName()), boneMask, pcache->m_boneMask, pcache->m_timeValid );

0 commit comments

Comments
 (0)